@@ -24,7 +24,7 @@ import {
24
24
import { saveFile } from '../shared/filesystem.js' ;
25
25
26
26
let jcrPages = [ ] ;
27
- const IMAGE_MAPPING_FILE = 'image -mappings.json' ;
27
+ const ASSET_MAPPING_FILE = 'asset -mappings.json' ;
28
28
29
29
const init = ( ) => {
30
30
jcrPages = [ ] ;
@@ -40,10 +40,10 @@ const addPage = async (page, dir, prefix, zip) => {
40
40
* @param {string } xml - The xml content of the page
41
41
* @param {string } pageUrl - The url of the site page
42
42
* @param {string } assetFolderName - The name of the asset folder(s) in AEM
43
- * @param {Map } imageMappings - A map to store the image urls and their corresponding jcr paths
43
+ * @param {Map } assetMappings - A map to store the asset urls and their corresponding jcr paths
44
44
* @returns {Promise<*|string> } - The updated xml content
45
45
*/
46
- export const updateAssetReferences = async ( xml , pageUrl , assetFolderName , imageMappings ) => {
46
+ export const updateAssetReferences = async ( xml , pageUrl , assetFolderName , assetMappings ) => {
47
47
let doc ;
48
48
try {
49
49
doc = getParsedXml ( xml ) ;
@@ -54,14 +54,14 @@ export const updateAssetReferences = async (xml, pageUrl, assetFolderName, image
54
54
}
55
55
56
56
// Start traversal from the document root and update the asset references
57
- traverseAndUpdateAssetReferences ( doc . documentElement , pageUrl , assetFolderName , imageMappings ) ;
57
+ traverseAndUpdateAssetReferences ( doc . documentElement , pageUrl , assetFolderName , assetMappings ) ;
58
58
59
59
const serializer = new XMLSerializer ( ) ;
60
60
return serializer . serializeToString ( doc ) ;
61
61
} ;
62
62
63
63
// eslint-disable-next-line max-len
64
- export const getJcrPages = async ( pages , siteFolderName , assetFolderName , imageMappings ) => Promise . all ( pages . map ( async ( page ) => ( {
64
+ export const getJcrPages = async ( pages , siteFolderName , assetFolderName , assetMappings ) => Promise . all ( pages . map ( async ( page ) => ( {
65
65
path : page . path ,
66
66
sourceXml : page . data ,
67
67
pageProperties : getPageProperties ( page . data ) ,
@@ -70,7 +70,7 @@ export const getJcrPages = async (pages, siteFolderName, assetFolderName, imageM
70
70
page . data ,
71
71
page . url ,
72
72
assetFolderName ,
73
- imageMappings ,
73
+ assetMappings ,
74
74
) ,
75
75
jcrPath : getJcrPagePath ( page . path , siteFolderName ) ,
76
76
contentXmlPath : `jcr_root${ getJcrPagePath ( page . path , siteFolderName ) } /.content.xml` ,
@@ -120,31 +120,31 @@ const getEmptyAncestorPages = (pages) => {
120
120
} ;
121
121
122
122
/**
123
- * Save the image mappings to a file.
124
- * @param {Map } imageMappings - A map of image urls and their corresponding jcr paths
123
+ * Save the asset mappings to a file.
124
+ * @param {Map } assetMappings - A map of asset urls and their corresponding jcr paths
125
125
* @param {* } outputDirectory - The directory handle
126
126
*/
127
- const saveImageMappings = async ( imageMappings , outputDirectory ) => {
127
+ const saveAssetMappings = async ( assetMappings , outputDirectory ) => {
128
128
// Convert Map to a plain object
129
- const obj = Object . fromEntries ( imageMappings ) ;
129
+ const obj = Object . fromEntries ( assetMappings ) ;
130
130
131
- // Save the updated image mapping content into a file
132
- await saveFile ( outputDirectory , IMAGE_MAPPING_FILE , JSON . stringify ( obj , null , 2 ) ) ;
131
+ // Save the updated asset mapping content into a file
132
+ await saveFile ( outputDirectory , ASSET_MAPPING_FILE , JSON . stringify ( obj , null , 2 ) ) ;
133
133
} ;
134
134
135
135
/**
136
136
* Creates a JCR content package from a directory containing pages.
137
137
* @param {* } outputDirectory - The directory handle
138
138
* @param {Array } pages - An array of pages
139
- * @param {Array<string> } imageUrls - An array of image urls that were found in the markdown.
139
+ * @param {Array<string> } assetUrls - An array of asset urls that were found in the markdown.
140
140
* @param {string } siteFolderName - The name of the site folder(s) in AEM
141
141
* @param {string } assetFolderName - The name of the asset folder(s) in AEM
142
142
* @returns {Promise } The file handle for the generated package.
143
143
*/
144
144
export const createJcrPackage = async (
145
145
outputDirectory ,
146
146
pages ,
147
- imageUrls ,
147
+ assetUrls ,
148
148
siteFolderName ,
149
149
assetFolderName ,
150
150
) => {
@@ -158,10 +158,10 @@ export const createJcrPackage = async (
158
158
const prefix = 'jcr' ;
159
159
160
160
// create a map using the provided asset urls as keys (values will be populated later)
161
- const imageMappings = new Map ( imageUrls . map ( ( url ) => [ url , '' ] ) ) ;
161
+ const assetMappings = new Map ( assetUrls . map ( ( url ) => [ url , '' ] ) ) ;
162
162
163
163
// add the pages
164
- jcrPages = await getJcrPages ( pages , siteFolderName , assetFolderName , imageMappings ) ;
164
+ jcrPages = await getJcrPages ( pages , siteFolderName , assetFolderName , assetMappings ) ;
165
165
for ( let i = 0 ; i < jcrPages . length ; i += 1 ) {
166
166
const page = jcrPages [ i ] ;
167
167
// eslint-disable-next-line no-await-in-loop
@@ -188,5 +188,5 @@ export const createJcrPackage = async (
188
188
await zip . generateAsync ( { type : outputType } )
189
189
. then ( async ( blob ) => saveFile ( outputDirectory , `${ packageName } .zip` , blob ) ) ;
190
190
191
- await saveImageMappings ( imageMappings , outputDirectory ) ;
191
+ await saveAssetMappings ( assetMappings , outputDirectory ) ;
192
192
} ;
0 commit comments