Skip to content

Commit 93764e0

Browse files
committed
chore: cleanup code
1 parent bbdcd84 commit 93764e0

File tree

14 files changed

+52
-32
lines changed

14 files changed

+52
-32
lines changed

justfile

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ run:
1010
npm run dev
1111

1212
host:
13+
#!/usr/bin/env bash
14+
export VERCEL_GIT_COMMIT_REF="$(git rev-parse --abbrev-ref HEAD)"
15+
export VERCEL_GIT_COMMIT_SHA="$(git rev-parse HEAD)"
1316
npm run dev -- --host
1417

1518
build:
@@ -21,6 +24,10 @@ lint:
2124
preview:
2225
npm run preview
2326

27+
logo:
28+
toilet -f roman -F crop --html 'rafi.' \
29+
-d "$(brew --prefix figlet)"/share/figlet/fonts
30+
2431
favicon:
2532
convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 {{ logo }} {{ icon_dir }}/output-16x16.ico
2633
convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 {{ logo }} {{ icon_dir }}/output-32x32.ico

src/app.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
%sveltekit.head%
2020
</head>
2121

22-
<!--<body data-sveltekit-preload-data="hover">-->
23-
<body>
22+
<body data-sveltekit-preload-data="hover">
2423
<div style="display: contents">%sveltekit.body%</div>
2524
</body>
2625

src/lib/components/article/article.svelte

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
</svelte:head>
1717

1818
<article class="prose">
19-
<!-- Title -->
2019
<hgroup>
2120
<h1>{data.meta.title}</h1>
2221
<p>
@@ -34,7 +33,6 @@
3433
</p>
3534
</hgroup>
3635

37-
<!-- Tags -->
3836
{#if data.meta.categories}
3937
<div class="tags">
4038
{#each data.meta.categories as category}
@@ -43,10 +41,7 @@
4341
</div>
4442
{/if}
4543

46-
<!-- Post -->
47-
<div class="prose">
48-
<svelte:component this={data.content} />
49-
</div>
44+
<svelte:component this={data.content} />
5045
</article>
5146

5247
<TableOfContents />

src/lib/components/code/layout.svelte

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
<script context="module" lang="ts">
1+
<script context="module">
22
import codeblock from './block.svelte';
3-
// import alert from './Alert.svelte';
4-
// import img from './Image.svelte';
53
6-
// export { alert, codeblock, img };
74
export { codeblock };
85
</script>
96

src/lib/components/presentation/presentation.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
2929
deckRef.initialize();
3030
31+
// Cleanup reveal.js when unmounting
3132
return () => {
32-
// Cleanup reveal.js
3333
if (deckRef) {
3434
deckRef.destroy();
3535
deckRef = null;

src/lib/components/toc/tree.svelte

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
{@const node = heading.node.innerHTML}
4040
{@const nodeWithoutSpan = node.replace(/<span.*<\/span>/g, '')}
4141
<li class="mt-0 {level === 1 && 'parent'}">
42-
<div class={'list-item text-muted-foreground ' + ($isActive(heading.id) && 'active ')}>
42+
<div
43+
class={'list-item text-muted-foreground ' +
44+
($isActive(heading.id) && 'active ')}
45+
>
4346
<a href="#{heading.id}" use:melt={$item(heading.id)} use:hoverAction>
44-
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
4547
{@html nodeWithoutSpan}
4648
</a>
4749
</div>

src/lib/posts.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { Post, ImportedFile } from '$lib/types'
22

3-
// Parse markdown files.
3+
/**
4+
* Parse Markdown files.
5+
* @param paths - Imported files from vite's import.meta.glob(...)
6+
* @param subPath - Optional sub-path to prepend to slug.
7+
*/
48
export function parseFiles(paths: Record<string, any>, subPath: string = '') {
59
let posts: Post[] = []
610
for (const path in paths) {
@@ -35,7 +39,7 @@ function asPost(slug: string, post: any): ImportedFile {
3539
return {
3640
slug,
3741
content: post.default,
38-
meta: post.metadata as Omit<Post, 'slug'>,
42+
meta: post.metadata as Omit<Post, 'slug'> || {},
3943
}
4044
}
4145

src/routes/(site)/+layout.svelte

+6-9
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,22 @@
1212
1313
export let data;
1414
15-
$: isSlides = data.url.endsWith('/slides');
15+
$: presenting = data.url.endsWith('/slides');
1616
</script>
1717

1818
<Header
19-
nav={!isSlides}
20-
url={isSlides ? data.url.replace(/\/slides$/, '') : ''}
19+
nav={!presenting}
20+
url={presenting ? data.url.replace(/\/slides$/, '') : ''}
2121
/>
2222

2323
{#key data.url}
24-
<main
25-
class={isSlides ? 'main-present' : ''}
26-
in:fly={{ x: 50, duration: 150, easing: sineIn }}
27-
>
24+
<main class:presenting in:fly={{ x: 50, duration: 150, easing: sineIn }}>
2825
<div>
2926
<slot />
3027
</div>
3128
</main>
3229
{/key}
33-
{#if !isSlides}
30+
{#if !presenting}
3431
<Footer />
3532
{/if}
3633

@@ -48,7 +45,7 @@
4845
overflow: hidden;
4946
}
5047
51-
.main-present {
48+
main.presenting {
5249
flex: 1 1 auto;
5350
padding: 0 !important;
5451
max-width: none !important;

src/routes/(site)/+page.svelte

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676

7777
<h2>Projects</h2>
7878
<ul>
79-
<!-- <li><a href="/neovim">neovim config</a></li> -->
8079
<li><a href="https://github.com/rafi/gits">gits</a></li>
8180
<li><a href="https://nester.co.il">nester</a></li>
8281
</ul>

src/routes/(site)/[slug]/slides/+page.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
export let data;
55
</script>
66

7+
<svelte:head>
8+
<link rel="canonical" href={data.url.replace(/\/slides$/, '')} />
9+
</svelte:head>
10+
711
<Presentation>
812
{data.raw}
913
</Presentation>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
VERCEL_GIT_COMMIT_SHA,
3+
VERCEL_GIT_COMMIT_REF,
4+
} from '$env/static/private';
5+
6+
export function load() {
7+
return {
8+
gitSHA: VERCEL_GIT_COMMIT_SHA,
9+
gitRef: VERCEL_GIT_COMMIT_REF,
10+
}
11+
}

src/routes/(site)/about/+page.svelte

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
<script>
1+
<script lang="ts">
22
import Profile from '$lib/components/profile-card.svelte';
33
import { RecentTracks } from '$lib/components/lastfm';
4+
5+
export let data;
46
</script>
57

68
<svelte:head>
@@ -21,6 +23,10 @@
2123
<p>
2224
This site happily lives at <a href="https://vercel.com">Vercel</a>
2325
and powered by <a href="https://kit.svelte.dev/">SvelteKit</a>.
26+
{#if data.gitSHA}
27+
(<a href="https://github.com/rafi/vim-config/commit/{data.gitSHA}">
28+
{data.gitSHA.substring(0, 7)}</a>)
29+
{/if}
2430
</p>
2531

2632
<p>

src/routes/(site)/about/+page.ts

-2
This file was deleted.

src/styles/layout.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ html[color-scheme='dark'] {
7070

7171
--nav-background: #25272a;
7272
--nav-border: #1a1b1e;
73-
--border-color: #434343;
73+
/* --border-color: #434343; */
74+
--border-color: hsl(0 0% 100% / 0.1);
7475

7576
--muted: 10 5% 96%;
7677
--muted-foreground: 255 0% 79% / .4;
@@ -188,7 +189,6 @@ main a {
188189

189190
main a:hover {
190191
background-color: var(--color-hover);
191-
/* text-decoration: none; */
192192
}
193193

194194
input,
@@ -224,6 +224,7 @@ h5:hover a.hash-link,
224224
h6:hover a.hash-link {
225225
opacity: 1;
226226
}
227+
227228
a.hash-link:before {
228229
content: "#";
229230
}

0 commit comments

Comments
 (0)