From dd88c311caf93d6f8f82123f8a045a3ed82e9934 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Mon, 8 Jan 2024 21:53:16 -0800 Subject: [PATCH 01/11] swap comments to use utteranc.es, remove outdated components --- src/lib/components/Comment.svelte | 79 ------------------------ src/lib/components/Comments.svelte | 86 ++++----------------------- src/lib/components/PostItem.svelte | 6 -- src/lib/components/Reactions.svelte | 34 ----------- src/lib/content.js | 27 +-------- src/lib/utils.js | 24 ++++++++ src/routes/(main)/[slug]/+page.svelte | 20 +------ 7 files changed, 39 insertions(+), 237 deletions(-) delete mode 100644 src/lib/components/Comment.svelte delete mode 100644 src/lib/components/Reactions.svelte create mode 100644 src/lib/utils.js diff --git a/src/lib/components/Comment.svelte b/src/lib/components/Comment.svelte deleted file mode 100644 index 763314b..0000000 --- a/src/lib/components/Comment.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - -
-
- {@html body} - - -
-
- - diff --git a/src/lib/components/Comments.svelte b/src/lib/components/Comments.svelte index 9207611..024796f 100644 --- a/src/lib/components/Comments.svelte +++ b/src/lib/components/Comments.svelte @@ -1,80 +1,14 @@ -{#if data.length} -

Comments:

-{/if} -
- {#each data as comment} - - {/each} -
- - Leave a new comment! - - - +
+ +
diff --git a/src/lib/components/PostItem.svelte b/src/lib/components/PostItem.svelte index 5c59287..6318c3a 100644 --- a/src/lib/components/PostItem.svelte +++ b/src/lib/components/PostItem.svelte @@ -29,12 +29,6 @@ > {new Date(item.date).toISOString().slice(0, 10)}

- - {#if item.ghMetadata && item.ghMetadata.reactions.total_count} -

- {item.ghMetadata.reactions.total_count} โ™ฅ -

- {/if} diff --git a/src/lib/components/Reactions.svelte b/src/lib/components/Reactions.svelte deleted file mode 100644 index ae66bd0..0000000 --- a/src/lib/components/Reactions.svelte +++ /dev/null @@ -1,34 +0,0 @@ - - -{#if reactions.total_count > 0} - - {#each Object.keys(reactions) as reaction} - {#if Object.keys(emojiMap).includes(reaction) && reactions[reaction] > 0} - - - {emojiMap[reaction]} - {reactions[reaction]} - - - {/if} - {/each} - -{/if} diff --git a/src/lib/content.js b/src/lib/content.js index 752dabc..c79b9c3 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -8,6 +8,7 @@ import { GH_PUBLISHED_TAGS, REPO_OWNER } from './siteConfig'; +import { slugify, readingTime } from './utils' import parse from 'parse-link-header'; import { remark } from 'remark'; import remarkParse from 'remark-parse'; @@ -32,31 +33,6 @@ const rehypePlugins = [ let allBlogposts = []; // let etag = null // todo - implmement etag header -/** - * @param {string | number} text - * @returns {string} - */ -function slugify(text) { - return text - .toString() // Cast to string (optional) - .normalize('NFKD') // The normalize() using NFKD method returns the Unicode Normalization Form of a given string. - .toLowerCase() // Convert the string to lowercase letters - .trim() // Remove whitespace from both sides of a string (optional) - .replace(/\s+/g, '-') // Replace spaces with hyphen - .replace(/[^\w-]+/g, '') // Remove all non-word chars - .replace(/--+/g, '-') // Replace multiple hyphen with single hyphen - .replace(/(^-|-$)/g, ''); // Remove leading or trailing hyphen -} - -/** - * @param {string} text - * @returns {string} - */ -function readingTime(text) { - let minutes = Math.ceil(text.trim().split(' ').length / 225); - return minutes > 1 ? `${minutes} minutes` : `${minutes} minute`; -} - export async function listContent() { // use a diff var so as to not have race conditions while fetching // TODO: make sure to handle this better when doing etags or cache restore @@ -243,6 +219,7 @@ function parseIssue(issue) { return { type: 'blog', // futureproof in case you want to add other types of content + issueNumber: issue.number, content, frontmatter: data, title, diff --git a/src/lib/utils.js b/src/lib/utils.js new file mode 100644 index 0000000..18587f6 --- /dev/null +++ b/src/lib/utils.js @@ -0,0 +1,24 @@ +/** + * @param {string} text + * @returns {string} + */ +export function readingTime(text) { + let minutes = Math.ceil(text.trim().split(' ').length / 225); + return minutes > 1 ? `${minutes} minutes` : `${minutes} minute`; +} + +/** + * @param {string | number} text + * @returns {string} + */ +export function slugify(text) { + return text + .toString() // Cast to string (optional) + .normalize('NFKD') // The normalize() using NFKD method returns the Unicode Normalization Form of a given string. + .toLowerCase() // Convert the string to lowercase letters + .trim() // Remove whitespace from both sides of a string (optional) + .replace(/\s+/g, '-') // Replace spaces with hyphen + .replace(/[^\w-]+/g, '') // Remove all non-word chars + .replace(/--+/g, '-') // Replace multiple hyphen with single hyphen + .replace(/(^-|-$)/g, ''); // Remove leading or trailing hyphen +} diff --git a/src/routes/(main)/[slug]/+page.svelte b/src/routes/(main)/[slug]/+page.svelte index fa06f6b..6542e2f 100644 --- a/src/routes/(main)/[slug]/+page.svelte +++ b/src/routes/(main)/[slug]/+page.svelte @@ -77,23 +77,9 @@ $: canonical = SITE_URL + $page.url.pathname;
- -
- {#if json.ghMetadata.reactions.total_count > 0} - Reactions: - {:else} - Leave a reaction - if you liked this post! ๐Ÿงก - {/if} -
+
+
- +
- -
From 72eff0decd45a6643e5b404d7611d9cce426fc79 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 20:54:31 -0800 Subject: [PATCH 02/11] fix typo --- src/lib/content/work/google.svx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/content/work/google.svx b/src/lib/content/work/google.svx index 42dc06f..32160c6 100644 --- a/src/lib/content/work/google.svx +++ b/src/lib/content/work/google.svx @@ -11,4 +11,4 @@ As part of a 5-person team at Instrument, I created re-usable templates and styl This website uses several proprietary systems internal to Google and the component templates were written with Jinja2 and SASS to support that. Javascript was required to follow Google's strict internal code quality standards for TypeScript. At one point, those standards changed in-between rounds of client Gerrit reviews, and we were not supplied the updated standards... that was fun. -I wrote a good chunk of the custom templates, styles, and nearly all of the TypeScript found througout the site, including listeners for scroll-based animations, keyboard-accessible modals, slideshows, and filtering. +I wrote a good chunk of the custom templates, styles, and nearly all of the TypeScript found throughout the site, including listeners for scroll-based animations, keyboard-accessible modals, slideshows, and filtering. From aedd124c51b8db37e682a5047df71e006d601b2c Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 21:38:57 -0800 Subject: [PATCH 03/11] actually use the og images for non-blog pages --- src/routes/(main)/[slug]/+page.svelte | 15 ++++++++------- src/routes/(main)/about/+page.svx | 3 +++ src/routes/(main)/blog/+page.svelte | 3 +++ src/routes/(main)/resume/+page.svelte | 5 ++++- src/routes/(main)/work/+page.svelte | 3 +++ src/routes/(nowrapper)/christmas/+page.svelte | 4 ++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/routes/(main)/[slug]/+page.svelte b/src/routes/(main)/[slug]/+page.svelte index 6542e2f..509e2e2 100644 --- a/src/routes/(main)/[slug]/+page.svelte +++ b/src/routes/(main)/[slug]/+page.svelte @@ -3,7 +3,6 @@ import { MY_TWITTER_HANDLE, SITE_URL } from '$lib/siteConfig'; import Comments from '$lib/components/Comments.svelte'; import 'prism-themes/themes/prism-shades-of-purple.min.css'; -import Reactions from '$lib/components/Reactions.svelte'; import { page } from '$app/stores'; /** @type {import('./$types').PageData} */ @@ -55,12 +54,14 @@ $: canonical = SITE_URL + $page.url.pathname; >

tjheffner

- - {json.ghMetadata.reactions.total_count} - {#if json.ghMetadata.reactions.total_count === 1}reaction{:else}reactions{/if} - + {#if json.ghMetadata.reactions.total_count > 0} + + {json.ghMetadata.reactions.total_count} + {#if json.ghMetadata.reactions.total_count === 1}reaction{:else}reactions{/if} + + {/if} {new Date(json.date).toISOString().slice(0, 10)}

diff --git a/src/routes/(main)/about/+page.svx b/src/routes/(main)/about/+page.svx index 50e3602..40801ea 100644 --- a/src/routes/(main)/about/+page.svx +++ b/src/routes/(main)/about/+page.svx @@ -5,6 +5,9 @@ heffner.dev | about + + +

about

diff --git a/src/routes/(main)/blog/+page.svelte b/src/routes/(main)/blog/+page.svelte index c916b5e..8953586 100644 --- a/src/routes/(main)/blog/+page.svelte +++ b/src/routes/(main)/blog/+page.svelte @@ -111,6 +111,9 @@ heffner.dev | posts + + + diff --git a/src/routes/(main)/resume/+page.svelte b/src/routes/(main)/resume/+page.svelte index 5207cef..aefa6b8 100644 --- a/src/routes/(main)/resume/+page.svelte +++ b/src/routes/(main)/resume/+page.svelte @@ -5,7 +5,10 @@ import { SITE_DESCRIPTION } from '$lib/siteConfig'; Tanner Heffner's Resume - + + + +
diff --git a/src/routes/(main)/work/+page.svelte b/src/routes/(main)/work/+page.svelte index 95183bc..d8afe2f 100644 --- a/src/routes/(main)/work/+page.svelte +++ b/src/routes/(main)/work/+page.svelte @@ -8,6 +8,9 @@ {SITE_TITLE} | Work + + +
diff --git a/src/routes/(nowrapper)/christmas/+page.svelte b/src/routes/(nowrapper)/christmas/+page.svelte index 001e837..33b88fc 100644 --- a/src/routes/(nowrapper)/christmas/+page.svelte +++ b/src/routes/(nowrapper)/christmas/+page.svelte @@ -110,6 +110,10 @@ + + + + From 3ed73915f4dd89ed4e2ff15f077628233d87794d Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 21:45:41 -0800 Subject: [PATCH 04/11] fix rss feed --- src/routes/api/rss.xml/+server.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/routes/api/rss.xml/+server.js b/src/routes/api/rss.xml/+server.js index e2d850a..9aced2b 100644 --- a/src/routes/api/rss.xml/+server.js +++ b/src/routes/api/rss.xml/+server.js @@ -21,21 +21,12 @@ export async function GET() { }); }); - throw new Error("@migration task: Migrate this return statement (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292701)"); - // Suggestion (check for correctness before using): - // return new Response(feed.xml({ indent: true }), { - // headers: { - // 'Cache-Control': `max-age=0, s-maxage=${600}`, // 10 minutes - // 'Content-Type': 'application/rss+xml' - // } - // }); - return { - body: feed.xml({ indent: true }), // todo - nonindent if not human + return new Response(feed.xml({ indent: true }), { headers: { 'Cache-Control': `max-age=0, s-maxage=${600}`, // 10 minutes 'Content-Type': 'application/rss+xml' } - }; + }); } // misc notes for future users From 0cf765b677d750655c2b0b9e02eca7d8f8d16b81 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 21:54:25 -0800 Subject: [PATCH 05/11] add link to rss from blog list --- src/routes/(main)/blog/+page.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/(main)/blog/+page.svelte b/src/routes/(main)/blog/+page.svelte index 8953586..ba89cc7 100644 --- a/src/routes/(main)/blog/+page.svelte +++ b/src/routes/(main)/blog/+page.svelte @@ -249,4 +249,8 @@ {:else}
Search something else!
{/if} + +
From d276b1828f9d2eccc1280ea3385c34cfea1137e9 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 22:23:19 -0800 Subject: [PATCH 06/11] add blogroll page, move rss --- src/routes/(main)/blog/+page.svelte | 2 +- src/routes/(main)/blogroll/+page.svx | 15 +++++++++++++++ src/routes/{api => }/rss.xml/+server.js | 0 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/routes/(main)/blogroll/+page.svx rename src/routes/{api => }/rss.xml/+server.js (100%) diff --git a/src/routes/(main)/blog/+page.svelte b/src/routes/(main)/blog/+page.svelte index ba89cc7..498472e 100644 --- a/src/routes/(main)/blog/+page.svelte +++ b/src/routes/(main)/blog/+page.svelte @@ -251,6 +251,6 @@ {/if}
diff --git a/src/routes/(main)/blogroll/+page.svx b/src/routes/(main)/blogroll/+page.svx new file mode 100644 index 0000000..ff92874 --- /dev/null +++ b/src/routes/(main)/blogroll/+page.svx @@ -0,0 +1,15 @@ + + heffner.dev | blogroll + + + + + + +

blogroll

+ +- [randi bolt](https://www.rbolt.me/) +- [nug doug](https://darkdell.net) +- [defector](https://defector.com) +- [bright side](https://www.brightsideofthesun.com/) +- [fujichia](https://www.fujichia.com/) diff --git a/src/routes/api/rss.xml/+server.js b/src/routes/rss.xml/+server.js similarity index 100% rename from src/routes/api/rss.xml/+server.js rename to src/routes/rss.xml/+server.js From 74dbeb64414bb4a099e04abb1f59c50df39d75d1 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 22:28:39 -0800 Subject: [PATCH 07/11] small adjustment to rss --- src/routes/rss.xml/+server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/rss.xml/+server.js b/src/routes/rss.xml/+server.js index 9aced2b..171bdb6 100644 --- a/src/routes/rss.xml/+server.js +++ b/src/routes/rss.xml/+server.js @@ -8,7 +8,7 @@ export async function GET() { const feed = new RSS({ title: SITE_TITLE + ' RSS Feed', site_url: SITE_URL, - feed_url: SITE_URL + '/api/rss.xml' + feed_url: SITE_URL + '/rss.xml' }); const allBlogs = await listContent(); From 6f87f352e2b1d965245a34d54053506151b3a6be Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 12 Jan 2024 22:55:45 -0800 Subject: [PATCH 08/11] update homepage, remove snippets category --- src/routes/(main)/+page.svelte | 29 ++++++++++++++++++----------- src/routes/(main)/blog/+page.svelte | 17 +---------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/routes/(main)/+page.svelte b/src/routes/(main)/+page.svelte index bc7b43a..4705d06 100644 --- a/src/routes/(main)/+page.svelte +++ b/src/routes/(main)/+page.svelte @@ -35,25 +35,32 @@ - -

this site is perpetually under construction but coming along :)

+ +

This site is perpetually under construction but coming along :)

-

it's mostly a reminder of past work and a place for me to post recipes I like, with the occasional technical post or personal blog mixed in.

+

It's mostly a place for me to post recipes I like, with the occasional technical post or personal blog mixed in. Some work-related stuff can be found here too, but that's not what I want to talk about.

-

thanks for stopping by, check out the links that work

+

Thanks for stopping by, check out the links that work โœŒ๏ธ

- + + +

๐ŸŽถ - Stove God Cooks, Nujabes, Fleetwood Mac

+

๐Ÿฟ - The Righteous Gemstones, Saltburn

+

๐Ÿ“š - Thinking, Fast And Slow by Daniel Kahneman

+

๐ŸŽฎ - Baldur's Gate 3, Monster Train, RDR2

+ +

Last updated: Jan 12, 2024

+
+ + +

In no particular order...

+ +
- - diff --git a/src/routes/(main)/blog/+page.svelte b/src/routes/(main)/blog/+page.svelte index 498472e..aeebb2e 100644 --- a/src/routes/(main)/blog/+page.svelte +++ b/src/routes/(main)/blog/+page.svelte @@ -38,7 +38,6 @@ }; let recipes = false; - let snippets = false; let technical = false; let notes = false; @@ -50,7 +49,6 @@ if (!Array.isArray(givenstate.show)) givenstate.show = [givenstate.show]; if (!givenstate.show.includes('Recipes')) recipes = false; if (!givenstate.show.includes('Technical')) technical = false; - if (!givenstate.show.includes('Snippets')) snippets = false; if (!givenstate.show.includes('Notes')) notes = false; if (givenstate.filter) filterStr = givenstate.filter; urlState = { ...defaultURLState, ...givenstate }; @@ -63,7 +61,6 @@ filter: filterStr, show: [ recipes && 'Recipes', - snippets && 'Snippets', technical && 'Technical', notes && 'Notes' ].filter(Boolean) @@ -99,10 +96,9 @@ if (filterStr && notIncludes(filterStr, x)) { return false; } else { - if ([recipes, technical, snippets, notes].every((v) => v === false)) return true; + if ([recipes, technical, notes].every((v) => v === false)) return true; if (recipes && x.category === 'recipe') return true; if (technical && x.category === 'technical') return true; - if (snippets && x.category === 'snippet') return true; if (notes && x.category === 'note') return true; } }); @@ -168,17 +164,6 @@ > Recipes -