Skip to content

Commit

Permalink
#1270: extract preheader code into html file to make parsing easier
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 23, 2024
1 parent 5fade72 commit 1987f5a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,33 @@ class Asset extends MetadataType {
});
}
}
// metadata.views.html.content (optional)
// the main content can be empty (=not set up yet) hence check if we did extract sth or else readFile() will print error msgs
const fileName2 = 'views.preheader.content' + subtypeExtension;
if (
(await File.pathExists(
File.normalizePath([...readDirArr, `${fileName2}.html`])
)) &&
metadata.views.preheader
) {
if (!fileListOnly) {
metadata.views.preheader.content = await File.readFilteredFilename(
readDirArr,
fileName2,
'html'
);
}

if (templateName) {
// to use this method in templating, store a copy of the info in fileList
fileList.push({
subFolder: [...subDirArr, templateFileName],
fileName: fileName2,
fileExt: 'html',
content: metadata.views.preheader.content,
});
}
}

// metadata.views.html.slots.<>.blocks.<>.content (optional)
if (metadata?.views?.html?.slots) {
Expand Down Expand Up @@ -1401,6 +1428,16 @@ class Asset extends MetadataType {
});
delete metadata.views.html.content;
}
// metadata.views.html.content (optional)
if (metadata.views?.preheader?.content?.length) {
codeArr.push({
subFolder: null,
fileName: 'views.preheader.content',
fileExt: 'html',
content: metadata.views.preheader.content,
});
delete metadata.views.preheader.content;
}

// metadata.views.html.slots.<>.blocks.<>.content (optional)
if (metadata.views?.html?.slots) {
Expand Down

0 comments on commit 1987f5a

Please sign in to comment.