From 47fec185516ce5af5ba619b1e61a59fbace3ba44 Mon Sep 17 00:00:00 2001 From: Gil Date: Thu, 22 May 2025 02:35:14 -0500 Subject: [PATCH] Snippets + note permalinks --- .eleventy.js | 10 +++++- .vscode/gil.ink.code-snippets | 53 ++++++++++++++++++++++++++++ src/_components/snippets/socials.njk | 2 +- src/_components/snippets/updates.njk | 6 ++-- src/_data/socials.json | 8 ++--- src/_data/updates.json | 10 ++++-- src/about.md | 2 +- src/updates.njk | 27 ++++++++++++++ 8 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 .vscode/gil.ink.code-snippets create mode 100644 src/updates.njk diff --git a/.eleventy.js b/.eleventy.js index 81579b4..033e759 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -38,7 +38,7 @@ export default function (eleventyConfig) { subtitle: "Gil's personal website", base: "https://gil.ink/", author: { - name: "Gil Caley", + name: "Gil C.", email: "hello@gil.ink", }, }, @@ -62,10 +62,18 @@ export default function (eleventyConfig) { return DateTime.fromJSDate(date).toFormat(format); }); + eleventyConfig.addFilter("formatDateIso", function (date, format) { + return DateTime.fromISO(date).toFormat(format); + }); + eleventyConfig.addFilter("formatDateRel", function (date) { return DateTime.fromJSDate(date).toRelative(); }); + eleventyConfig.addFilter("formatDateIsoRel", function (date) { + return DateTime.fromISO(date).toRelative(); + }); + eleventyConfig.addFilter("md", function (content = "") { return md.render(content); }); diff --git a/.vscode/gil.ink.code-snippets b/.vscode/gil.ink.code-snippets new file mode 100644 index 0000000..9aa67f8 --- /dev/null +++ b/.vscode/gil.ink.code-snippets @@ -0,0 +1,53 @@ +{ + "Frontmatter: Datetime": { + "scope": "json,liquid,markdown,njk,yaml", + "prefix": "fmdt", + "body": [ + "${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}.00${CURRENT_TIMEZONE_OFFSET}" + ], + "description": "Current datetime (for last modified date)" + }, + "Frontmatter: Post": { + "scope": "markdown,njk", + "prefix": "fmpost", + "body": [ + "---", + "title: \"$1\"", + "date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}.00${CURRENT_TIMEZONE_OFFSET}", + "lastmod: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}.00${CURRENT_TIMEZONE_OFFSET}", + "categories:$2", + "tags:", + " - post$3", + "elsewhere:", + " ghost:$4", + "---", + "$0" + ], + "description": "Frontmatter template for posts" + }, + "Frontmatter: Single": { + "scope": "markdown,njk", + "prefix": "fmsg", + "body": [ + "---", + "layout: single", + "title: \"$1\"", + "date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}.00${CURRENT_TIMEZONE_OFFSET}", + "lastmod: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}.00${CURRENT_TIMEZONE_OFFSET}", + "---", + "$0" + ], + "description": "Frontmatter template for single layout" + }, + "Json: Update": { + "scope": "json", + "prefix": "jsnote", + "body": [ + "{", + " \"date\": \"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}\",", + " \"slug\": \"${1:a}\",", + " \"content\": \"$0\"", + "}" + ] + } +} diff --git a/src/_components/snippets/socials.njk b/src/_components/snippets/socials.njk index 22cf75c..d273d6a 100644 --- a/src/_components/snippets/socials.njk +++ b/src/_components/snippets/socials.njk @@ -4,7 +4,7 @@ {{ social.label }}
- {{ social.handle }} + {{ social.handle }} {% if social.note %} {{ social.note }} {% endif %} diff --git a/src/_components/snippets/updates.njk b/src/_components/snippets/updates.njk index 427e608..e421e05 100644 --- a/src/_components/snippets/updates.njk +++ b/src/_components/snippets/updates.njk @@ -1,6 +1,6 @@

- {% for update in updates %} - / - {{ update.content | safe }}
+ {% for update in updates | reverse %} + {{ update.date | formatDateIso('yyyy-MM-dd') }} + / {{ update.content | safe }}
{% endfor %}

\ No newline at end of file diff --git a/src/_data/socials.json b/src/_data/socials.json index ac49da5..de41258 100644 --- a/src/_data/socials.json +++ b/src/_data/socials.json @@ -26,12 +26,12 @@ }, { "label": "Bluesky", - "link": "https://bsky.app/profile/kalanggam.bsky.social", - "handle": "kalanggam.bsky.social" + "link": "https://bsky.app/profile/gil.ink", + "handle": "bsky.app/profile/gil.ink" }, { "label": "Newsletter", - "link": "https://gilosophies.ghost.io/", - "handle": "gilosophies.ghost.io" + "link": "https://ghost.gil.ink/", + "handle": "ghost.gil.ink" } ] diff --git a/src/_data/updates.json b/src/_data/updates.json index 6128ca8..2fd0f35 100644 --- a/src/_data/updates.json +++ b/src/_data/updates.json @@ -1,6 +1,12 @@ [ { - "date": "2025-02-20", - "content": "Hello world!" + "date": "2025-05-21T12:15:00.00-05:00", + "slug": "a", + "content": "Officially finished migrating from gils.nexus to gil.ink!" + }, + { + "date": "2025-05-22T02:30:05.00-05:00", + "slug": "a", + "content": "These notes now have permalinks" } ] diff --git a/src/about.md b/src/about.md index 14017b5..76caed5 100644 --- a/src/about.md +++ b/src/about.md @@ -1,7 +1,7 @@ --- title: "About" layout: about -lastmod: 2025-02-20T02:11:25.00-06:00 +lastmod: 2025-05-21T23:14:05.00-05:00 eleventyNavigation: key: "About" order: 0 diff --git a/src/updates.njk b/src/updates.njk new file mode 100644 index 0000000..8d58302 --- /dev/null +++ b/src/updates.njk @@ -0,0 +1,27 @@ +--- +layout: single +permalink: "/note/{{ update.date | formatDateIso('yyyy-MM-dd') }}{{ update.slug }}/index.html" +pagination: + data: updates + size: 1 + alias: update +title: "Note" +--- + +
+

Note {{ update.date | formatDateIso('yyyy-MM-dd') }}{{ update.slug }}

+

Posted {{ update.date | formatDateIsoRel }} +

+
+

{{ update.content | safe }}

+{% if pagination.href.previous or pagination.href.next %} +

+ {% if pagination.href.previous %} + ← prev + {% endif %} + {% if pagination.href.previous and pagination.href.next %}|{% endif %} + {% if pagination.href.next %} + next → + {% endif %} +

+{% endif %}