Files
blog/packages/@zblog/toolchain/src/start-page-plugin.ts
wholteza 63a240a8fe Styled note template
Fixed link regex
Fixed pre width

Squashed commit of the following:

commit 20038e290a
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 20:55:21 2025 +0200

    Fix width of pre element

commit 52b49e18a2
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:59:36 2025 +0200

    Fix link regexp

commit 5036b3bca6
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:53:00 2025 +0200

    Changed font size

commit 5063c088eb
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:52:22 2025 +0200

    Fixed margins

commit acd6ed63e1
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:51:03 2025 +0200

    Add leading space to links

commit 8b3c7871ab
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:50:38 2025 +0200

    Add color to links

commit 2658d688ca
Author: wholteza <zackarias@montell.se>
Date:   Sat Sep 20 18:45:49 2025 +0200

    Fixed reloading of browser when developing

commit 03e2361798
Author: wholteza <zackarias@montell.se>
Date:   Fri Sep 19 21:45:40 2025 +0200

    Change header line height

commit a1f6994c02
Author: wholteza <zackarias@montell.se>
Date:   Fri Sep 19 21:42:08 2025 +0200

    Align note with index
2025-09-20 20:57:17 +02:00

34 lines
1.1 KiB
TypeScript

import { IPluginBuilder, Plugin } from "./typings.js";
import { readFileAsText, writeTextAsFile } from "./toolchain-helpers.js";
type StartPagePluginOptions = {
indexTemplatePath: string;
contentTemplateTag: string;
};
export class StartPagePlugin implements IPluginBuilder {
options: StartPagePluginOptions;
constructor(options: StartPagePluginOptions) {
this.options = options;
}
build(): Plugin {
return (builderContext) => {
let htmlTemplate = readFileAsText(this.options.indexTemplatePath);
const links = builderContext.menuManifest
.map((m) => {
const name = m.name.slice(m.name.indexOf("-") + 1).replaceAll("-", " ");
return `<div class="entry"><h2>${name}</h2><a href='${m.link}'>Read here!</a></div>`
})
.reverse();
const html = `
${links.join("")}
`;
htmlTemplate = htmlTemplate.replace("{{content}}", html);
console.log("Generating index", this.options.indexTemplatePath);
writeTextAsFile(
`${builderContext.outputDirectory}/index.html`,
htmlTemplate
);
};
}
}