-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from tjheffner/refactor-stuff
Refactor stuff
- Loading branch information
Showing
20 changed files
with
2,137 additions
and
399 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.