diff --git a/.eleventy.js b/.eleventy.js index 4e79e52..8ec34bc 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -11,6 +11,9 @@ const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils"); const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g; module.exports = function (eleventyConfig) { + eleventyConfig.setLiquidOptions({ + dynamicPartials: true, + }); let markdownLib = markdownIt({ breaks: true, html: true, diff --git a/src/site/_data/dynamics.js b/src/site/_data/dynamics.js new file mode 100644 index 0000000..5aa87d2 --- /dev/null +++ b/src/site/_data/dynamics.js @@ -0,0 +1,33 @@ +const fsFileTree = require("fs-file-tree"); + +const BASE_PATH = "src/site/_includes/components/user" +const NAMESPACES = ["index", "notes", "common"]; +const SLOTS = ["header", "afterContent", "footer"] + +const generateComponentPaths = async (namespace) => { + const data = {}; + for (let index = 0; index < SLOTS.length; index++) { + const slot = SLOTS[index]; + try { + console.log(`${BASE_PATH}/${namespace}/${slot}`); + const tree = await fsFileTree(`${BASE_PATH}/${namespace}/${slot}`); + let comps = Object.keys(tree).filter((p) => p.indexOf(".njk") != -1).map((p) => `components/user/${namespace}/${slot}/${p}`); + comps.sort() + data[slot] = comps; + } catch { + data[slot] = []; + } + } + return data; +} + + +module.exports = async () => { + const data = {}; + for (let index = 0; index < NAMESPACES.length; index++) { + const ns = NAMESPACES[index]; + data[ns] = await generateComponentPaths(ns); + } + console.log(data); + return data; +} \ No newline at end of file diff --git a/src/site/_includes/layouts/note.njk b/src/site/_includes/layouts/note.njk index aa428e1..247bd27 100644 --- a/src/site/_includes/layouts/note.njk +++ b/src/site/_includes/layouts/note.njk @@ -38,8 +38,20 @@ permalink: "notes/{{ page.fileSlug | slugify }}/" {% endif %} + {% for imp in dynamics.common.header %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.notes.header %} + {% include imp %} + {% endfor %} {{ content | hideDataview | link | taggify | highlight | safe}} + {% for imp in dynamics.common.afterContent %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.notes.afterContent %} + {% include imp %} + {% endfor %} {% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%} @@ -50,5 +62,11 @@ permalink: "notes/{{ page.fileSlug | slugify }}/" {%include "components/linkPreview.njk"%} {% endif %} {% include "components/references.njk" %} + {% for imp in dynamics.common.footer %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.notes.footer %} + {% include imp %} + {% endfor %} diff --git a/src/site/index.njk b/src/site/index.njk index f753a53..8c8a0a8 100644 --- a/src/site/index.njk +++ b/src/site/index.njk @@ -33,10 +33,22 @@ {% endif %} + {% for imp in dynamics.common.header %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.index.header %} + {% include imp %} + {% endfor %} {%- for garden in collections.gardenEntry -%} {{garden.templateContent | hideDataview | link | taggify | highlight | safe }} {%- endfor -%} + {% for imp in dynamics.common.afterContent %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.index.afterContent %} + {% include imp %} + {% endfor %} {% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%} @@ -46,5 +58,11 @@ {% if settings.dgLinkPreview === true %} {%include "components/linkPreview.njk"%} {% endif %} + {% for imp in dynamics.common.footer %} + {% include imp %} + {% endfor %} + {% for imp in dynamics.index.footer %} + {% include imp %} + {% endfor %}