Image link support
This commit is contained in:
16
build.js
16
build.js
@@ -30,6 +30,7 @@ const manifest = directoryNames.map((noteDirectory) => ({
|
|||||||
{ encoding: "utf-8" }
|
{ encoding: "utf-8" }
|
||||||
),
|
),
|
||||||
assetDirectoryPath: `${paths.notes.root}/${noteDirectory}/${paths.notes.assets}`,
|
assetDirectoryPath: `${paths.notes.root}/${noteDirectory}/${paths.notes.assets}`,
|
||||||
|
publicAssetDirectoryPath: `/${noteDirectory}_`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
manifest.forEach((m) => {
|
manifest.forEach((m) => {
|
||||||
@@ -37,11 +38,24 @@ manifest.forEach((m) => {
|
|||||||
let htmlTemplate = fs.readFileSync(notePath, {
|
let htmlTemplate = fs.readFileSync(notePath, {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
});
|
});
|
||||||
htmlTemplate = htmlTemplate.replace("{{markdown}}", toHtml(m.markdown));
|
htmlTemplate = htmlTemplate.replace(
|
||||||
|
"{{markdown}}",
|
||||||
|
toHtml(m.markdown, m.publicAssetDirectoryPath)
|
||||||
|
);
|
||||||
fs.writeFileSync(`${paths.output}/${m.directoryName}.html`, htmlTemplate, {
|
fs.writeFileSync(`${paths.output}/${m.directoryName}.html`, htmlTemplate, {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
flag: "ax",
|
flag: "ax",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!fs.existsSync(m.assetDirectoryPath)) return;
|
||||||
|
const assetsList = fs.readdirSync(m.assetDirectoryPath);
|
||||||
|
console.log(assetsList);
|
||||||
|
assetsList.forEach((assetName) =>
|
||||||
|
fs.cpSync(
|
||||||
|
`${m.assetDirectoryPath}/${assetName}`,
|
||||||
|
`${paths.output}/${m.name}_${assetName}`
|
||||||
|
)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
[paths.templates.notFound].forEach((filename) => {
|
[paths.templates.notFound].forEach((filename) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user