Skip to content

Commit

Permalink
Merge pull request #58 from tjheffner/refactor-stuff
Browse files Browse the repository at this point in the history
Refactor stuff
  • Loading branch information
tjheffner authored Jan 13, 2024
2 parents e0af62e + 6cc3e0a commit d68051a
Show file tree
Hide file tree
Showing 20 changed files with 2,137 additions and 399 deletions.
2,056 changes: 1,946 additions & 110 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"remark-autolink-headings": "^6.1.0",
"remark-frontmatter": "^3.0.0",
"remark-github": "^11.2.2",
"remark-html": "^16.0.1",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.1.0",
"remark-sectionize": "^1.1.1",
Expand Down
79 changes: 0 additions & 79 deletions src/lib/components/Comment.svelte

This file was deleted.

86 changes: 10 additions & 76 deletions src/lib/components/Comments.svelte
Original file line number Diff line number Diff line change
@@ -1,80 +1,14 @@
<script>
/** @type {import('$lib/types').GHMetadata} */
export let ghMetadata;
let data = [];
import { onMount } from 'svelte';
onMount(async () => {
data = await (await fetch(ghMetadata.commentsUrl)).json();
});
import Comment from './Comment.svelte';
export let issueNumber;
</script>

{#if data.length}
<p class="my-4 font-bold text-accent">Comments:</p>
{/if}
<div
class="prose mb-8 divide-y divide-dashed divide-sky-600 dark:prose-invert dark:divide-blue-300"
>
{#each data as comment}
<Comment {comment} />
{/each}
</div>
<a
href={`${ghMetadata.issueUrl}#issuecomment-new`}
rel="external noopener noreferrer"
target="_blank"
class="my-4 rounded-lg bg-sky-600 p-2 font-bold text-orange-100 ring-red-600
transition-all duration-200 ease-in-out hover:ring-2
dark:bg-yellow-800 dark:text-yellow-100 dark:ring-yellow-400"
>
Leave a new comment!
</a>

<!-- <pre class="prose dark:prose-invert">
{JSON.stringify(data, null, 2)}
</pre> -->
<!--
{
"url": "https://api.github.com/repos/sw-yx/swyxkit/issues/comments/1008454294",
"html_url": "https://github.com/sw-yx/swyxkit/issues/10#issuecomment-1008454294",
"issue_url": "https://api.github.com/repos/sw-yx/swyxkit/issues/10",
"id": 1008454294,
"node_id": "IC_kwDOFYx2rM48G8qW",
"user": {
"login": "sw-yx",
"id": 6764957,
"node_id": "MDQ6VXNlcjY3NjQ5NTc=",
"avatar_url": "https://avatars.githubusercontent.com/u/6764957?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/sw-yx",
"html_url": "https://github.com/sw-yx",
"followers_url": "https://api.github.com/users/sw-yx/followers",
"following_url": "https://api.github.com/users/sw-yx/following{/other_user}",
"gists_url": "https://api.github.com/users/sw-yx/gists{/gist_id}",
"starred_url": "https://api.github.com/users/sw-yx/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/sw-yx/subscriptions",
"organizations_url": "https://api.github.com/users/sw-yx/orgs",
"repos_url": "https://api.github.com/users/sw-yx/repos",
"events_url": "https://api.github.com/users/sw-yx/events{/privacy}",
"received_events_url": "https://api.github.com/users/sw-yx/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2022-01-10T00:16:22Z",
"updated_at": "2022-01-10T00:16:22Z",
"author_association": "OWNER",
"body": "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Corrupti fugiat quod non ipsum perspiciatis voluptatum pariatur explicabo enim, suscipit sapiente, quo perferendis amet sint voluptates. Quibusdam ullam voluptatibus expedita repudiandae quos tenetur, modi eligendi eos. Sit cum unde dolor assumenda error, suscipit earum, corrupti molestias vero quae incidunt enim aspernatur magni inventore reprehenderit esse rerum quas, at itaque? Autem repellendus cupiditate natus vero inventore sit! Excepturi expedita optio in! Sapiente rerum fuga dignissimos odit iure laboriosam earum non dolores obcaecati repellendus ipsum minus enim eum et, totam facere? Doloribus autem sed magni nobis aspernatur nulla officiis impedit nostrum obcaecati assumenda!",
"reactions": {
"url": "https://api.github.com/repos/sw-yx/swyxkit/issues/comments/1008454294/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
} -->
<div>
<script src="https://utteranc.es/client.js"
repo="tjheffner/heffdotdev"
issue-number={`${issueNumber}`}
theme="boxy-light"
crossorigin="anonymous"
async>
</script>
</div>
6 changes: 0 additions & 6 deletions src/lib/components/PostItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
>
{new Date(item.date).toISOString().slice(0, 10)}
</p>

{#if item.ghMetadata && item.ghMetadata.reactions.total_count}
<p class="md:col-span-1 md:col-start-4 md:justify-self-end text-accent">
{item.ghMetadata.reactions.total_count} ♥
</p>
{/if}
</div>
</a>

Expand Down
34 changes: 0 additions & 34 deletions src/lib/components/Reactions.svelte

This file was deleted.

27 changes: 2 additions & 25 deletions src/lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/content/work/google.svx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion src/lib/siteConfig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SITE_URL = 'https://heffner.netlify.app';
// export const SITE_URL = 'https://heffner.netlify.app';
export const SITE_URL = 'https://heffner.dev';
export const GH_USER = 'tjheffner';
export const GH_USER_REPO = 'tjheffner/heffdotdev'; // used for pulling github issues and offering comments
export const SITE_TITLE = 'heffner.dev';
Expand Down
24 changes: 24 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 18 additions & 12 deletions src/routes/(main)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
DEFAULT_OG_IMAGE,
MY_TWITTER_HANDLE
} from '$lib/siteConfig';
export const prerender = false; // index page is most visited, lets prerender
</script>

<svelte:head>
Expand All @@ -35,25 +34,32 @@
</h1>
</Slice>

<Slice title="Hello!">
<p>this site is perpetually under construction but coming along :)</p>
<Slice title="Hello World!">
<p>This site is perpetually under construction but coming along :)</p>

<p>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.<p>
<p>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.<p>

<p>thanks for stopping by, check out the links that work</p>
<p>Thanks for stopping by, check out the links that work ✌️</p>
</Slice>

<Slice title="Fav Recipes">

<Slice title="Currently...">
<p><span class="text-3xl">🎶</span> - Stove God Cooks, Nujabes, Fleetwood Mac</p>
<p><span class="text-3xl">🍿</span> - The Righteous Gemstones, Saltburn</p>
<p><span class="text-3xl">📚</span> - Thinking, Fast And Slow by Daniel Kahneman</p>
<p><span class="text-3xl">🎮</span> - Baldur's Gate 3, Monster Train, RDR2</p>

<p class="text-xs">Last updated: Jan 12, 2024</p>
</Slice>

<Slice title="Top Recipes">
<p>In no particular order...</p>
<div class="grid w-full grid-cols-1 md:grid-cols-3 gap-4 align-middle">
<Card title="Creme Brulee" href={'/creme-brulee'}/>
<Card title="Caper Butter" href={'/dill-caper-compound-butter'} />
<Card title="Preserved Lemons" href={'/preserved-lemons'}/>
<Card title="Pizza Dough" href={'/pizza-dough'}/>
<Card title="Chicken & Bean Stew" href={'/southwest-chicken-bean-stew'}/>
</div>
</Slice>

<!-- <Slice title="Latest Tech Posts">
<div class="grid w-full grid-cols-1 md:grid-cols-3 gap-4 align-middle">
pull the latest 3 posts that have `technical` or `snippet` category here
</div>
</Slice> -->
</section>
Loading

0 comments on commit d68051a

Please sign in to comment.