From 880a13c294292d5594002bc5526e237a5fa16ec3 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:32:44 -0500 Subject: [PATCH] refactor: use components for repeated sections, cleanup --- src/components/postlist.vto | 17 ++++++++ src/components/postslist.vto | 33 ---------------- src/components/projectlist.vto | 35 +++++++++++++++++ src/components/projectslist.vto | 34 ---------------- src/components/tags.vto | 13 +++++++ src/components/time.vto | 12 ++++++ src/generated/feed.xml.vto | 38 +++++++++--------- src/layouts/base.vto | 24 +++++++----- src/layouts/post.vto | 69 +++++++++++++-------------------- src/posts/index.vto | 4 +- src/projects.vto | 6 +-- src/tags.vto | 6 +-- 12 files changed, 147 insertions(+), 144 deletions(-) create mode 100644 src/components/postlist.vto delete mode 100644 src/components/postslist.vto create mode 100644 src/components/projectlist.vto delete mode 100644 src/components/projectslist.vto create mode 100644 src/components/tags.vto create mode 100644 src/components/time.vto diff --git a/src/components/postlist.vto b/src/components/postlist.vto new file mode 100644 index 00000000..234afde0 --- /dev/null +++ b/src/components/postlist.vto @@ -0,0 +1,17 @@ +{{ import { Time } from './time.vto' }} +{{ import { Tags } from './tags.vto' }} + +{{ export function PostList(posts) }} + {{- for index, post of posts -}} +
+

+ {{ post.data.title }} +

+
+ {{ Time(post.data.date, post.data.edited) }} + {{ Tags(post.data.tags) }} +
+

{{ post.data.description }}

+
+ {{- /for -}} +{{ /export }} diff --git a/src/components/postslist.vto b/src/components/postslist.vto deleted file mode 100644 index e44c401c..00000000 --- a/src/components/postslist.vto +++ /dev/null @@ -1,33 +0,0 @@ -{{ export function PostsList(posts) }} - {{- for index, post of posts -}} -
-

- {{ post.data.title }} -

-
- {{- if post.data.date -}} - - {{ set date = post.data.date |> toShortDate }} - {{ set edited = post.data.edited |> toShortDate }} - - {{- if post.data.edited && (edited !== date) -}} -  (last edited ) - {{- /if -}} - - {{- /if -}} - {{- if post.data.tags -}} - · -
- {{- for index, tag of post.data.tags -}} - - {{ tag }} - {{- index != (post.data.tags.length - 1) ? ',' : '' -}} - - {{- /for -}} -
- {{- /if -}} -
-

{{ post.data.description }}

-
- {{- /for -}} -{{ /export }} diff --git a/src/components/projectlist.vto b/src/components/projectlist.vto new file mode 100644 index 00000000..0eec180f --- /dev/null +++ b/src/components/projectlist.vto @@ -0,0 +1,35 @@ +{{ export async function ProjectList(projects) }} +
+ {{- for project of projects -}} + +
+

{{ project.name }}

+

{{ project.description }}

+
+
+ {{ set classes = 'block w-5 h-5 text-text align-baseline' }} +
+ {{ for item of project.stack }} + {{- icon "si:" + item, { class: classes } -}} + {{ /for }} +
+
+
{{- icon "si:github", { class: classes } -}}
+ {{ if project.live && !project.live.startsWith("https://crates.io") }} + {{- if project.live.startsWith("https://discord.gg") -}} + {{- set liveIcon = 'si:discord' -}} + {{- else if project.live.startsWith("https://npmjs.com") || project.live.startsWith("https://www.npmjs.com") -}} + {{- set liveIcon = 'si:npm' -}} + {{ else if project.live.startsWith("https://chrome.google.com/webstore") || project.live.startsWith("https://chromewebstore.google.com") }} + {{- set liveIcon = 'si:chromewebstore' -}} + {{- else -}} + {{- set liveIcon = 'lucide:globe' -}} + {{- /if -}} +
{{- icon liveIcon, { class: classes } -}}
+ {{ /if }} +
+
+
+ {{ /for }} +
+{{ /export }} diff --git a/src/components/projectslist.vto b/src/components/projectslist.vto deleted file mode 100644 index 2431034b..00000000 --- a/src/components/projectslist.vto +++ /dev/null @@ -1,34 +0,0 @@ -{{ export async function ProjectsList(projects) }} -
- {{- for project of projects -}} - -
-

{{ project.name }}

-

{{ project.description }}

-
-
-
- {{ for item of project.stack }} - {{- icon "si:" + item, { class: 'block w-5 h-5 text-text align-baseline' } -}} - {{ /for }} -
-
-
{{- icon "si:github", { class: 'block w-5 h-5 text-text align-baseline' } -}}
- {{ if project.live && !project.live.startsWith("https://crates.io") }} - {{- if project.live.startsWith("https://discord.gg") -}} - {{- set liveIcon = 'si:discord' -}} - {{- else if project.live.startsWith("https://npmjs.com") || project.live.startsWith("https://www.npmjs.com") -}} - {{- set liveIcon = 'si:npm' -}} - {{ else if project.live.startsWith("https://chrome.google.com/webstore") || project.live.startsWith("https://chromewebstore.google.com") }} - {{- set liveIcon = 'si:chromewebstore' -}} - {{- else -}} - {{- set liveIcon = 'lucide:globe' -}} - {{- /if -}} -
{{- icon liveIcon, { class: 'block w-5 h-5 text-text align-baseline' } -}}
- {{ /if }} -
-
-
- {{ /for }} -
-{{ /export }} diff --git a/src/components/tags.vto b/src/components/tags.vto new file mode 100644 index 00000000..0883164a --- /dev/null +++ b/src/components/tags.vto @@ -0,0 +1,13 @@ +{{ export function Tags(tags) }} +{{- if tags -}} + · +
+ {{- for index, tag of tags -}} + + {{ tag }} + {{- index != (tags.length - 1) ? ',' : '' -}} + + {{- /for -}} +
+{{- /if -}} +{{ /export }} diff --git a/src/components/time.vto b/src/components/time.vto new file mode 100644 index 00000000..dc7712c9 --- /dev/null +++ b/src/components/time.vto @@ -0,0 +1,12 @@ +{{ export function Time(written, edited) }} +{{ if written }} + + {{ set shortWritten = written |> toShortDate }} + {{ set shortEdited = edited |> toShortDate }} + + {{- if edited && (edited !== written) -}} +  (last edited ) + {{- /if -}} + +{{ /if }} +{{ /export }} diff --git a/src/generated/feed.xml.vto b/src/generated/feed.xml.vto index 6636540f..09053dc2 100644 --- a/src/generated/feed.xml.vto +++ b/src/generated/feed.xml.vto @@ -3,23 +3,23 @@ permalink: /feed.xml eleventyExcludeFromCollections: false --- - {{ site.domain }} - {{ site.feed.description }} - - - {{ collections.posts |> getNewestCollectionItemDate |> dateToRfc3339 }} - {{ site.url }} - - {{ site.author.name }} - - {{- for post of collections.posts.toReversed() }} - {{- set url = post.url |> url }} - - {{ post.data.title }} - - {{ post.date |> dateToRfc3339 }} - {{ url }} - {{ post.content |> await htmlToAbsoluteUrls(url) |> escape }} - - {{ /for }} + {{ site.domain }} + {{ site.feed.description }} + + + {{ collections.posts |> getNewestCollectionItemDate |> dateToRfc3339 }} + {{ site.url }} + + {{ site.author.name }} + + {{- for post of collections.posts.toReversed() }} + {{- set url = post.url |> url }} + + {{ post.data.title }} + + {{ post.date |> dateToRfc3339 }} + {{ url }} + {{ post.content |> await htmlToAbsoluteUrls(url) |> escape }} + + {{- /for }} diff --git a/src/layouts/base.vto b/src/layouts/base.vto index 3e9bfdb5..778a7ec5 100644 --- a/src/layouts/base.vto +++ b/src/layouts/base.vto @@ -15,6 +15,16 @@ footerLinks: url: /privacy/ - title: Sitemap url: /sitemap.xml +socialLinks: + - title: GitHub + slug: github + icon: github + - title: Bluesky + slug: bluesky + icon: bluesky + - title: Mastodon + slug: mastodon + icon: mastodon --- {{ set title = title ? (title + " - " + site.domain) : site.domain }} @@ -107,15 +117,11 @@ footerLinks: