Snippets + note permalinks

This commit is contained in:
Gil 2025-05-22 02:35:14 -05:00
parent 3ec03a9a30
commit 47fec18551
8 changed files with 106 additions and 12 deletions

View file

@ -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);
});

53
.vscode/gil.ink.code-snippets vendored Normal file
View file

@ -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\"",
"}"
]
}
}

View file

@ -4,7 +4,7 @@
<em>{{ social.label }}</em>
</dt>
<dd>
<a href="{{ social.link }}" rel="me">{{ social.handle }}</a>
<a href="{{ social.link }}" rel="me noopener noreferrer" target="_blank">{{ social.handle }}</a>
{% if social.note %}
<em>{{ social.note }}</em>
{% endif %}

View file

@ -1,6 +1,6 @@
<p>
{% for update in updates %}
<time class="muted" datetime="{{ update.date }}">{{ update.date }}</time> /
{{ update.content | safe }}<br/>
{% for update in updates | reverse %}
<a href="/note/{{ update.date | formatDateIso('yyyy-MM-dd') }}{{ update.slug }}/">{{ update.date | formatDateIso('yyyy-MM-dd') }}</a>
/ {{ update.content | safe }}<br/>
{% endfor %}
</p>

View file

@ -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"
}
]

View file

@ -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"
}
]

View file

@ -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

27
src/updates.njk Normal file
View file

@ -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"
---
<header>
<h1>Note {{ update.date | formatDateIso('yyyy-MM-dd') }}{{ update.slug }}</h1>
<p>Posted {{ update.date | formatDateIsoRel }}</time>
</p>
</header>
<p>{{ update.content | safe }}</p>
{% if pagination.href.previous or pagination.href.next %}
<p>
{% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}">&larr; prev</a>
{% endif %}
{% if pagination.href.previous and pagination.href.next %}|{% endif %}
{% if pagination.href.next %}
<a href="{{ pagination.href.next }}">next &rarr;</a>
{% endif %}
</p>
{% endif %}