mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-07 13:15:20 +00:00
dynamic import implementation
This commit is contained in:
parent
818ae56774
commit
705e80e5f2
@ -11,6 +11,9 @@ const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils");
|
|||||||
const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g;
|
const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g;
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
|
eleventyConfig.setLiquidOptions({
|
||||||
|
dynamicPartials: true,
|
||||||
|
});
|
||||||
let markdownLib = markdownIt({
|
let markdownLib = markdownIt({
|
||||||
breaks: true,
|
breaks: true,
|
||||||
html: true,
|
html: true,
|
||||||
|
33
src/site/_data/dynamics.js
Normal file
33
src/site/_data/dynamics.js
Normal file
@ -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;
|
||||||
|
}
|
@ -38,8 +38,20 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% for imp in dynamics.common.header %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.notes.header %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</header>
|
</header>
|
||||||
{{ content | hideDataview | link | taggify | highlight | safe}}
|
{{ content | hideDataview | link | taggify | highlight | safe}}
|
||||||
|
{% for imp in dynamics.common.afterContent %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.notes.afterContent %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%}
|
{% 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"%}
|
{%include "components/linkPreview.njk"%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "components/references.njk" %}
|
{% include "components/references.njk" %}
|
||||||
|
{% for imp in dynamics.common.footer %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.notes.footer %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -33,10 +33,22 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% for imp in dynamics.common.header %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.index.header %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</header>
|
</header>
|
||||||
{%- for garden in collections.gardenEntry -%}
|
{%- for garden in collections.gardenEntry -%}
|
||||||
{{garden.templateContent | hideDataview | link | taggify | highlight | safe }}
|
{{garden.templateContent | hideDataview | link | taggify | highlight | safe }}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
{% for imp in dynamics.common.afterContent %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.index.afterContent %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%}
|
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%}
|
||||||
@ -46,5 +58,11 @@
|
|||||||
{% if settings.dgLinkPreview === true %}
|
{% if settings.dgLinkPreview === true %}
|
||||||
{%include "components/linkPreview.njk"%}
|
{%include "components/linkPreview.njk"%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% for imp in dynamics.common.footer %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for imp in dynamics.index.footer %}
|
||||||
|
{% include imp %}
|
||||||
|
{% endfor %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user