Fixed link regex Fixed pre width Squashed commit of the following: commit20038e290aAuthor: wholteza <zackarias@montell.se> Date: Sat Sep 20 20:55:21 2025 +0200 Fix width of pre element commit52b49e18a2Author: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:59:36 2025 +0200 Fix link regexp commit5036b3bca6Author: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:53:00 2025 +0200 Changed font size commit5063c088ebAuthor: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:52:22 2025 +0200 Fixed margins commitacd6ed63e1Author: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:51:03 2025 +0200 Add leading space to links commit8b3c7871abAuthor: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:50:38 2025 +0200 Add color to links commit2658d688caAuthor: wholteza <zackarias@montell.se> Date: Sat Sep 20 18:45:49 2025 +0200 Fixed reloading of browser when developing commit03e2361798Author: wholteza <zackarias@montell.se> Date: Fri Sep 19 21:45:40 2025 +0200 Change header line height commita1f6994c02Author: wholteza <zackarias@montell.se> Date: Fri Sep 19 21:42:08 2025 +0200 Align note with index
34 lines
1.1 KiB
TypeScript
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
|
|
);
|
|
};
|
|
}
|
|
}
|