From 6c636111986928d9f630caa956c6e38158bc938a Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 1 Mar 2024 14:00:31 -0800 Subject: [PATCH] feat: design + perf + tags etc. --- .eleventy.js | 4 +- _redirects | 3 +- config/collections/index.js | 17 ++ config/filters/index.js | 12 +- package.json | 2 +- src/_data/nav.js | 3 +- src/_includes/main.liquid | 2 +- src/_includes/now.liquid | 2 +- src/_includes/partials/banners/npm.liquid | 7 + .../old-post.liquid} | 4 +- src/_includes/partials/footer.liquid | 8 +- src/_includes/partials/header.liquid | 2 +- src/_includes/partials/nav/menu.liquid | 2 +- src/_includes/partials/now/media-grid.liquid | 2 +- src/_includes/partials/now/topper.liquid | 14 +- src/_includes/partials/paginator.liquid | 20 +- src/_includes/partials/post-tags.liquid | 9 - src/_includes/partials/share-button.liquid | 2 +- src/_includes/partials/tags.liquid | 3 + src/_includes/post.liquid | 16 +- src/_includes/webrings/css-joy.liquid | 3 +- src/_includes/webrings/the-claw.liquid | 6 +- .../{banner-old-post.css => banners.css} | 21 +- src/assets/styles/components/forms.css | 30 ++- .../styles/components/mastodon-post.css | 4 +- src/assets/styles/components/media-grid.css | 3 +- src/assets/styles/components/pagefind.css | 8 +- src/assets/styles/components/paginator.css | 4 +- .../styles/components/popular-posts.css | 3 +- src/assets/styles/index.css | 209 +++++++----------- src/assets/styles/pages/about.css | 6 +- src/assets/styles/pages/contact.css | 5 + src/assets/styles/pages/now.css | 3 +- src/assets/styles/pages/post.css | 4 +- src/index.html | 28 +-- src/pages/404.html | 9 +- src/pages/contact-success.html | 9 +- src/pages/contact.md | 4 +- src/pages/search.html | 3 +- src/pages/stats.html | 2 + src/pages/{tagList.md => tag-list.html} | 14 +- src/pages/tags.md | 16 -- .../building-a-theme-toggle-web-component.md | 2 +- src/posts/2024/everything-is-a-checklist.md | 48 ++-- 44 files changed, 279 insertions(+), 299 deletions(-) create mode 100644 src/_includes/partials/banners/npm.liquid rename src/_includes/partials/{banner-old-post.liquid => banners/old-post.liquid} (75%) delete mode 100644 src/_includes/partials/post-tags.liquid create mode 100644 src/_includes/partials/tags.liquid rename src/assets/styles/components/{banner-old-post.css => banners.css} (50%) rename src/pages/{tagList.md => tag-list.html} (75%) delete mode 100644 src/pages/tags.md diff --git a/.eleventy.js b/.eleventy.js index 86609794..68dad7df 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,6 +1,5 @@ import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight' import tablerIcons from 'eleventy-plugin-tabler-icons' -import pluginRss from '@11ty/eleventy-plugin-rss' import postGraph from '@rknightuk/eleventy-plugin-post-graph' import embedEverything from 'eleventy-plugin-embed-everything' @@ -12,7 +11,7 @@ import htmlmin from 'html-minifier-terser' import filters from './config/filters/index.js' import { slugifyString } from './config/utils/index.js' import { svgToJpeg } from './config/events/index.js' -import { tagList, tagMap, postStats } from './config/collections/index.js' +import { tagList, tagMap, postStats, tagsSortedByCount } from './config/collections/index.js' import { img } from './config/shortcodes/index.js' import { execSync } from 'child_process' @@ -84,6 +83,7 @@ export default async function (eleventyConfig) { eleventyConfig.addCollection('tagList', tagList) eleventyConfig.addCollection('tagMap', tagMap) eleventyConfig.addCollection('postStats', postStats) + eleventyConfig.addCollection('tagsSortedByCount', tagsSortedByCount) const md = markdownIt({ html: true, linkify: true }) md.use(markdownItAnchor, { diff --git a/_redirects b/_redirects index d7d38dca..0952c0a6 100644 --- a/_redirects +++ b/_redirects @@ -30,6 +30,7 @@ /tags/.env /tags/env 301! # 404s +/sitemap.txt /sitemap.xml 301! /assets/img/social-preview/adding-a-light/dark-theme-toggle-preview.jpeg /assets/img/social-preview/adding-a-light-dark-theme-toggle-preview.jpeg 301! /assets/img/social-card.jpg /assets/img/ogi/default.jpg 301! /posts / 301! @@ -48,7 +49,7 @@ # general /articles/ / 301! -/sitemap.txt /sitemap.xml 301! +/tags /search 301! /mastodon https://social.lol/@cory 301! /coffee https://www.buymeacoffee.com/cory 301! /speedlify https://speedlify.coryd.dev 301! diff --git a/config/collections/index.js b/config/collections/index.js index acc15b61..d959e182 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -38,6 +38,23 @@ export const tagMap = (collection) => { return tags } +export const tagsSortedByCount = (collectionApi) => { + const tagStats = {}; + const posts = collectionApi.getFilteredByGlob('src/posts/**/*.md').sort((a, b) => { + return a.date - b.date; + }); + posts.forEach((post) => { + post.data.tags.forEach((tag) => { + if (!tagStats[tag]) tagStats[tag] = 1; + if (tagStats[tag]) tagStats[tag] = tagStats[tag] + 1; + }); + }); + const deletedTags = ['posts', 'politics', 'net neutrality']; + deletedTags.forEach(tag => delete tagStats[tag]); + const tagStatsArr = Object.entries(tagStats); + return tagStatsArr.sort((a, b) => b[1] - a[1]).map(([key, value]) => `${key}`); +} + export const postStats = (collectionApi) => { const oneDayMilliseconds = 1000 * 60 * 60 * 24 const statsObject = { diff --git a/config/filters/index.js b/config/filters/index.js index 1ffbe5c3..24aa04fd 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -184,4 +184,14 @@ export default { } return normalized }), -} + + // posts + formatTag: (string) => { + const capitalizeFirstLetter = (string) => { + return string.charAt(0).toUpperCase() + string.slice(1); + } + if (string === 'iOS' || string === 'macOS') return `#${string}` + if (!string.includes(' ')) return `#${capitalizeFirstLetter(string)}` + return `#${string.split(' ').map(s => capitalizeFirstLetter(s)).join('')}` + } +} \ No newline at end of file diff --git a/package.json b/package.json index 261f0b40..5874011f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "6.9.7", + "version": "7.0.0", "description": "The source for my personal site. Built using 11ty and hosted on Netlify.", "type": "module", "scripts": { diff --git a/src/_data/nav.js b/src/_data/nav.js index 8e87ba41..be6e9a27 100644 --- a/src/_data/nav.js +++ b/src/_data/nav.js @@ -11,8 +11,7 @@ export default async function () { { name: 'Now' }, { name: 'About' }, { name: 'Links', icon: 'link' }, - { name: 'Tags', icon: 'tags' }, - { name: 'Search', icon: 'search', class: 'client-side' }, + { name: 'Search', icon: 'search' }, { name: 'Feeds', icon: 'rss' }, { name: 'Mastodon', icon: 'brand-mastodon' }, ], diff --git a/src/_includes/main.liquid b/src/_includes/main.liquid index 98eb0ae5..c5afe542 100644 --- a/src/_includes/main.liquid +++ b/src/_includes/main.liquid @@ -5,5 +5,5 @@ layout: base
{{ content }}
- {% render "partials/footer.liquid", page: page, nav: nav %} + {% render "partials/footer.liquid", page:page, nav:nav %} \ No newline at end of file diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index ae692425..608401c9 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -8,7 +8,7 @@ layout: default {% endcapture %} {{ content }} -{% render "partials/now/media-grid.liquid", data:artists, icon: "microphone-2", title: "Artists", shape: "square", count: 8, loading: 'eager' %} +{% render "partials/now/media-grid.liquid", data:artists, icon: "microphone-2", title: "Artists", shape: "square", count: 8, loading: "eager" %} {% render "partials/now/media-grid.liquid", data:albums, icon: "vinyl", title: "Albums", shape: "square", count: 8 %} {% render "partials/now/albumReleases.liquid", albumReleases:albumReleases %} {% render "partials/now/media-grid.liquid", data:books, icon: "books", title: "Books", shape: "vertical", count: 6 %} diff --git a/src/_includes/partials/banners/npm.liquid b/src/_includes/partials/banners/npm.liquid new file mode 100644 index 00000000..2c42c94b --- /dev/null +++ b/src/_includes/partials/banners/npm.liquid @@ -0,0 +1,7 @@ +{% capture css %} + {% render "../../../assets/styles/components/banners.css" %} +{% endcapture %} + + \ No newline at end of file diff --git a/src/_includes/partials/banner-old-post.liquid b/src/_includes/partials/banners/old-post.liquid similarity index 75% rename from src/_includes/partials/banner-old-post.liquid rename to src/_includes/partials/banners/old-post.liquid index 42a57b05..99dee011 100644 --- a/src/_includes/partials/banner-old-post.liquid +++ b/src/_includes/partials/banners/old-post.liquid @@ -1,10 +1,10 @@ {% assign isOldPost = date | oldPost %} {% if isOldPost %} {% capture css %} - {% render "../../assets/styles/components/banner-old-post.css" %} + {% render "../../../assets/styles/components/banners.css" %} {% endcapture %} - \ No newline at end of file diff --git a/src/_includes/partials/nav/menu.liquid b/src/_includes/partials/nav/menu.liquid index 0a261733..5272e72f 100644 --- a/src/_includes/partials/nav/menu.liquid +++ b/src/_includes/partials/nav/menu.liquid @@ -2,7 +2,7 @@