From b559425c7b725ce35d1bfd638f9e44df05fc3787 Mon Sep 17 00:00:00 2001 From: Utsob Roy Date: Thu, 23 Feb 2023 16:34:43 +0600 Subject: [PATCH 1/5] footnote fix via better way --- .eleventy.js | 19 +++------------ package-lock.json | 60 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 78a23b722..45cdf6846 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -18,6 +18,9 @@ module.exports = function (eleventyConfig) { breaks: true, html: true, }) + .use(require("markdown-it-anchor"), { + slugify: headerToId, + }) .use(require("markdown-it-mark")) .use(require("markdown-it-footnote")) .use(function (md) { @@ -140,22 +143,6 @@ module.exports = function (eleventyConfig) { return defaultLinkRule(tokens, idx, options, env, self); }; - // Footnote heading fix (till the upstream releases the fix) - md.renderer.rules.render_footnote_anchor_name = ( - tokens, - idx, - options, - env - ) => { - var n = Number(tokens[idx].meta.id + 1).toString(); - var prefix = ""; - - if (env && typeof env.docId === "string") { - prefix = "-" + env.docId + "-"; - } - - return prefix + n; - }; }); eleventyConfig.setLibrary("md", markdownLib); diff --git a/package-lock.json b/package-lock.json index 21de14f3b..bba0f7804 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "gray-matter": "^4.0.3", "lunr": "^2.3.9", "markdown-it": "^13.0.1", + "markdown-it-anchor": "^8.6.7", "markdown-it-attrs": "^4.1.6", "markdown-it-footnote": "^3.0.3", "markdown-it-mark": "^3.0.1", @@ -520,6 +521,28 @@ "node": ">=8" } }, + "node_modules/@types/linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", + "peer": true + }, + "node_modules/@types/markdown-it": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", + "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "peer": true, + "dependencies": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", + "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", + "peer": true + }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -2903,6 +2926,15 @@ "markdown-it": "bin/markdown-it.js" } }, + "node_modules/markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, "node_modules/markdown-it-attrs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz", @@ -5738,6 +5770,28 @@ } } }, + "@types/linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", + "peer": true + }, + "@types/markdown-it": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", + "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "peer": true, + "requires": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "@types/mdurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", + "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", + "peer": true + }, "@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -7561,6 +7615,12 @@ } } }, + "markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "requires": {} + }, "markdown-it-attrs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz", diff --git a/package.json b/package.json index 519e166b9..e0b3ad2e2 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "gray-matter": "^4.0.3", "lunr": "^2.3.9", "markdown-it": "^13.0.1", + "markdown-it-anchor": "^8.6.7", "markdown-it-attrs": "^4.1.6", "markdown-it-footnote": "^3.0.3", "markdown-it-mark": "^3.0.1", From e1342e7eb7a8680657ab046e4734f03120cb3ef3 Mon Sep 17 00:00:00 2001 From: 12-VidE <76615801+12-VidE@users.noreply.github.com> Date: Thu, 2 Mar 2023 08:11:57 +0100 Subject: [PATCH 2/5] Add new attribute to tags (#84) The new attribute makes it easier to apply custom styles to specific tags with CSS --- .eleventy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eleventy.js b/.eleventy.js index 45cdf6846..f0b3da42f 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -198,7 +198,7 @@ module.exports = function (eleventyConfig) { return ( str && str.replace(tagRegex, function (match, precede, tag) { - return `${precede}${tag}`; + return `${precede}${tag}`; }) ); }); From 6698edf2629fea0eeac4e0ed478e43ecd64bd6e8 Mon Sep 17 00:00:00 2001 From: Utsob Roy Date: Thu, 2 Mar 2023 13:18:16 +0600 Subject: [PATCH 3/5] allow users to put scripts in src/site/scripts folder (#93) --- .eleventy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eleventy.js b/.eleventy.js index f0b3da42f..3344e842c 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -284,6 +284,7 @@ module.exports = function (eleventyConfig) { }); eleventyConfig.addPassthroughCopy("src/site/img"); + eleventyConfig.addPassthroughCopy("src/site/scripts"); eleventyConfig.addPassthroughCopy("src/site/styles/_theme.*.css"); eleventyConfig.addPlugin(faviconPlugin, { destination: "dist" }); eleventyConfig.addPlugin(tocPlugin, { From 809118c68be7cd1efde6674f83ba47e547f1bf5f Mon Sep 17 00:00:00 2001 From: Utsob Roy Date: Mon, 6 Mar 2023 13:31:42 +0600 Subject: [PATCH 4/5] single homepage rendering (#88) --- .eleventy.js | 3 ++ plugin-info.json | 10 ++-- src/site/_data/filetree.js | 3 ++ src/site/{ => _includes/layouts}/index.njk | 6 +-- src/site/index.11tydata.js | 59 ---------------------- src/site/notes/notes.11tydata.js | 12 +++++ src/site/notes/notes.json | 5 +- 7 files changed, 28 insertions(+), 70 deletions(-) rename src/site/{ => _includes/layouts}/index.njk (92%) delete mode 100644 src/site/index.11tydata.js diff --git a/.eleventy.js b/.eleventy.js index 3344e842c..25b7adf52 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -180,6 +180,9 @@ module.exports = function (eleventyConfig) { if (frontMatter.data.permalink) { permalink = frontMatter.data.permalink; } + if (frontMatter.data.tags.indexOf("gardenEntry") != -1) { + permalink = "/"; + } if (frontMatter.data.noteIcon) { noteIcon = frontMatter.data.noteIcon; } diff --git a/plugin-info.json b/plugin-info.json index 43683acae..a568c9cee 100644 --- a/plugin-info.json +++ b/plugin-info.json @@ -1,6 +1,8 @@ { "filesToDelete": [ - "src/site/styles/style.css" + "src/site/styles/style.css", + "src/site/index.njk", + "src/site/index.11tydata.js" ], "filesToAdd": [ "src/site/styles/custom-style.scss", @@ -10,7 +12,8 @@ "src/site/img/tree-1.svg", "src/site/img/tree-2.svg", "src/site/img/tree-3.svg", - "src/helpers/userUtils.js" + "src/helpers/userUtils.js", + "src/site/_includes/layouts/index.njk" ], "filesToModify": [ ".eleventy.js", @@ -20,9 +23,7 @@ "package-lock.json", "package.json", "src/site/404.njk", - "src/site/index.njk", "src/site/sitemap.njk", - "src/site/index.11tydata.js", "src/site/versionednote.njk", "src/site/styles/style.scss", "src/site/styles/digital-garden-base.scss", @@ -30,6 +31,7 @@ "src/site/notes/notes.json", "src/site/notes/notes.11tydata.js", "src/site/_includes/layouts/note.njk", + "src/site/_includes/layouts/index.njk", "src/site/_includes/layouts/versionednote.njk", "src/site/_includes/components/notegrowthhistory.njk", "src/site/_includes/components/pageheader.njk", diff --git a/src/site/_data/filetree.js b/src/site/_data/filetree.js index 714d7cf12..51b4f9c7c 100644 --- a/src/site/_data/filetree.js +++ b/src/site/_data/filetree.js @@ -52,6 +52,9 @@ function getPermalinkMeta(path, key) { if (frontMatter.data.permalink) { permalink = frontMatter.data.permalink; } + if (frontMatter.data.tags.indexOf("gardenEntry") != -1) { + permalink = "/"; + } if (frontMatter.data.title) { name = frontMatter.data.title; } diff --git a/src/site/index.njk b/src/site/_includes/layouts/index.njk similarity index 92% rename from src/site/index.njk rename to src/site/_includes/layouts/index.njk index b8442bec0..25eeacce4 100644 --- a/src/site/index.njk +++ b/src/site/_includes/layouts/index.njk @@ -1,7 +1,7 @@ - {{ noteTitle }} + {% if title %}{{ title }}{% else %}{{ page.fileSlug }}{% endif %} {%include "components/pageheader.njk"%} {% for imp in dynamics.common.head %} {% include imp %} @@ -52,9 +52,7 @@ {% for imp in dynamics.index.beforeContent %} {% include imp %} {% endfor %} - {%- for garden in collections.gardenEntry -%} - {{garden.templateContent | hideDataview | link | taggify | safe }} - {%- endfor -%} + {{ content | hideDataview | link | taggify | safe}} {% for imp in dynamics.common.afterContent %} {% include imp %} {% endfor %} diff --git a/src/site/index.11tydata.js b/src/site/index.11tydata.js deleted file mode 100644 index b38ca197e..000000000 --- a/src/site/index.11tydata.js +++ /dev/null @@ -1,59 +0,0 @@ -require("dotenv").config(); -const settings = require("../helpers/constants"); - -const markdownIt = require("markdown-it"); -const md = markdownIt({ - html: true, -}).use(require("../helpers/utils").namedHeadingsFilter); -const allSettings = settings.ALL_NOTE_SETTINGS; - -module.exports = { - eleventyComputed: { - settings: (data) => { - const currentnote = - data.collections.gardenEntry && data.collections.gardenEntry[0]; - if (currentnote && currentnote.data) { - const noteSettings = {}; - allSettings.forEach((setting) => { - let noteSetting = currentnote.data[setting]; - let globalSetting = process.env[setting]; - - let settingValue = - noteSetting || (globalSetting === "true" && noteSetting !== false); - noteSettings[setting] = settingValue; - }); - return noteSettings; - } - return {}; - }, - noteTitle: (data) => { - const currentnote = - data.collections.gardenEntry && data.collections.gardenEntry[0]; - if (currentnote && currentnote.data) { - return currentnote.data.title || currentnote.data.page.fileSlug; - } - return ""; - }, - tags: (data) => { - const currentnote = - data.collections.gardenEntry && data.collections.gardenEntry[0]; - if (currentnote && currentnote.data) { - return currentnote.data.tags; - } - return []; - }, - content: (data) => { - const currentnote = - data.collections.gardenEntry && data.collections.gardenEntry[0]; - if ( - currentnote && - currentnote.template && - currentnote.template.frontMatter && - currentnote.template.frontMatter.content - ) { - return md.render(currentnote.template.frontMatter.content); - } - return ""; - }, - }, -}; diff --git a/src/site/notes/notes.11tydata.js b/src/site/notes/notes.11tydata.js index c036a7454..4c8985f97 100644 --- a/src/site/notes/notes.11tydata.js +++ b/src/site/notes/notes.11tydata.js @@ -5,6 +5,18 @@ const allSettings = settings.ALL_NOTE_SETTINGS; module.exports = { eleventyComputed: { + layout: (data) => { + if (data.tags.indexOf("gardenEntry") != -1) { + return "layouts/index.njk"; + } + return "layouts/note.njk"; + }, + permalink: (data) => { + if (data.tags.indexOf("gardenEntry") != -1) { + return "/"; + } + return data.permalink || undefined; + }, settings: (data) => { const noteSettings = {}; allSettings.forEach((setting) => { diff --git a/src/site/notes/notes.json b/src/site/notes/notes.json index 781c64cfd..dd1976e73 100644 --- a/src/site/notes/notes.json +++ b/src/site/notes/notes.json @@ -1,5 +1,4 @@ { - "layout" : "layouts/note.njk", - "tags" : "note", + "tags": "note", "templateEngineOverride": "njk,md" - } \ No newline at end of file +} \ No newline at end of file From 2adca7b085c0baaea503588616f28ccfc9995c99 Mon Sep 17 00:00:00 2001 From: Ole Eskild Steensen Date: Mon, 6 Mar 2023 08:35:40 +0100 Subject: [PATCH 5/5] Remove layout from files to add. It is already added to filesToModify --- plugin-info.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin-info.json b/plugin-info.json index a568c9cee..7e4340850 100644 --- a/plugin-info.json +++ b/plugin-info.json @@ -12,8 +12,7 @@ "src/site/img/tree-1.svg", "src/site/img/tree-2.svg", "src/site/img/tree-3.svg", - "src/helpers/userUtils.js", - "src/site/_includes/layouts/index.njk" + "src/helpers/userUtils.js" ], "filesToModify": [ ".eleventy.js", @@ -63,4 +62,4 @@ "src/site/_data/eleventyComputed.js", "src/site/graph.njk" ] -} \ No newline at end of file +}