A simple, folder-driven static-site engine.
bun ssg fs
at dev 32 lines 1.1 kB view raw
1export default { 2 pluginId: "demo", 3 4 onResolved(site, ctx) { 5 // Add a small callout block to the "enriched by a plugin" entry 6 for (const collection of site.collections ?? []) { 7 for (const entry of collection.entries) { 8 if ((entry.slug || entry.id) === "enriched-by-a-plugin") { 9 const noteBlock = { 10 id: "plugin-note", 11 rawName: "plugin-note.md", 12 type: "markdown", 13 name: "Plugin note", 14 slug: "plugin-note", 15 ext: ".md", 16 path: `${entry.path}/plugin-note.md`, 17 content: { 18 raw: "> Added by demo plugin - showing transform hooks and prune whitelist.", 19 html: "<blockquote>Added by demo plugin - showing transform hooks and prune whitelist.</blockquote>", 20 }, 21 }; 22 entry.blocks = [...entry.blocks, noteBlock]; 23 } 24 } 25 } 26 27 // Whitelist a plugin assets folder (even if empty) so prune keeps it 28 ctx.addExpectedDir("assets/images/plugins/demo"); 29 30 ctx.logger.info("plugin.demo.enriched"); 31 }, 32};