mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Upgrade to Svelte 5, some regressions :(
This commit is contained in:
@@ -1,27 +1,37 @@
|
||||
<script lang="ts">
|
||||
export let calloutType: string;
|
||||
import { IconExclamationCircle } from "@tabler/icons-svelte";
|
||||
interface Props {
|
||||
calloutType: string;
|
||||
icon?: import('svelte').Snippet;
|
||||
title?: import('svelte').Snippet;
|
||||
body?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let {
|
||||
calloutType,
|
||||
icon,
|
||||
title,
|
||||
body
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
<div class="callout" data-callout={calloutType}>
|
||||
<div class="callout-title">
|
||||
{#if $$slots.icon}
|
||||
<div class="callout-icon"><slot name="icon" /></div>
|
||||
{#if icon}
|
||||
<div class="callout-icon">{@render icon?.()}</div>
|
||||
{:else}
|
||||
<div class="callout-icon"><IconExclamationCircle /></div>
|
||||
{/if}
|
||||
<div class="callout-title-inner">
|
||||
<slot name="title"
|
||||
>{calloutType.replace(/\w\S*/g, function (txt) {
|
||||
{#if title}{@render title()}{:else}{calloutType.replace(/\w\S*/g, function (txt) {
|
||||
return (
|
||||
txt.charAt(0).toUpperCase() +
|
||||
txt.substring(1).toLowerCase()
|
||||
);
|
||||
})}</slot
|
||||
>
|
||||
})}{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if $$slots.body}
|
||||
<div class="callout-body"><slot name="body" /></div>
|
||||
{#if body}
|
||||
<div class="callout-body">{@render body?.()}</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang="ts" context="module">
|
||||
<script lang="ts" module>
|
||||
type Attrs = {
|
||||
[name: string]: string;
|
||||
};
|
||||
@@ -6,6 +6,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
// look at https://github.com/sveltejs/learn.svelte.dev/blob/main/src/routes/tutorial/%5Bslug%5D/Editor.svelte
|
||||
// import { javascript } from "@codemirror/lang-javascript";
|
||||
import { onDestroy, onMount, createEventDispatcher } from "svelte";
|
||||
@@ -21,27 +23,40 @@
|
||||
import { type LanguageSupport } from "@codemirror/language";
|
||||
import { get_base_extensions } from "./editorExtensions";
|
||||
|
||||
export let value = "";
|
||||
export let contentAttributes: AttrSource | null = null;
|
||||
export let lang: LanguageSupport | null = null;
|
||||
|
||||
export let useTab = true;
|
||||
export let tabSize = 2;
|
||||
|
||||
export let lineWrapping = false;
|
||||
export let editable = true;
|
||||
export let readonly = false;
|
||||
export let placeholder: string | HTMLElement | null | undefined = undefined;
|
||||
interface Props {
|
||||
value?: string;
|
||||
contentAttributes?: AttrSource | null;
|
||||
lang?: LanguageSupport | null;
|
||||
useTab?: boolean;
|
||||
tabSize?: number;
|
||||
lineWrapping?: boolean;
|
||||
editable?: boolean;
|
||||
readonly?: boolean;
|
||||
placeholder?: string | HTMLElement | null | undefined;
|
||||
header?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let {
|
||||
value = $bindable(""),
|
||||
contentAttributes = null,
|
||||
lang = null,
|
||||
useTab = true,
|
||||
tabSize = 2,
|
||||
lineWrapping = false,
|
||||
editable = true,
|
||||
readonly = false,
|
||||
placeholder = undefined,
|
||||
header
|
||||
}: Props = $props();
|
||||
|
||||
const is_browser = typeof window !== "undefined";
|
||||
|
||||
let element: HTMLDivElement;
|
||||
let view: EditorView;
|
||||
let element: HTMLDivElement = $state();
|
||||
let view: EditorView = $state();
|
||||
|
||||
$: view && update(value);
|
||||
$: view && state_extensions && reconfigure();
|
||||
|
||||
$: on_change = handle_change;
|
||||
|
||||
let update_from_prop = false;
|
||||
let update_from_state = false;
|
||||
@@ -52,19 +67,6 @@
|
||||
|
||||
let extensions: Extension[] = [];
|
||||
|
||||
$: state_extensions = [
|
||||
...get_base_extensions(
|
||||
useTab,
|
||||
tabSize,
|
||||
lineWrapping,
|
||||
placeholder,
|
||||
editable,
|
||||
readonly,
|
||||
lang,
|
||||
),
|
||||
$theme == "dark" ? githubDark : githubLight,
|
||||
...extensions,
|
||||
];
|
||||
|
||||
if (langPlugin !== null) extensions.push(langPlugin);
|
||||
if (contentAttributes !== null)
|
||||
@@ -165,20 +167,40 @@
|
||||
|
||||
// lintGutter(),
|
||||
// linter(esLint(new eslint.Linter(), config)),
|
||||
run(() => {
|
||||
view && update(value);
|
||||
});
|
||||
let state_extensions = $derived([
|
||||
...get_base_extensions(
|
||||
useTab,
|
||||
tabSize,
|
||||
lineWrapping,
|
||||
placeholder,
|
||||
editable,
|
||||
readonly,
|
||||
lang,
|
||||
),
|
||||
$theme == "dark" ? githubDark : githubLight,
|
||||
...extensions,
|
||||
]);
|
||||
run(() => {
|
||||
view && state_extensions && reconfigure();
|
||||
});
|
||||
let on_change = $derived(handle_change);
|
||||
</script>
|
||||
|
||||
<div class="editor-wrapper card" class:no-header={!$$slots.header}>
|
||||
{#if $$slots.header}
|
||||
<div class="editor-wrapper card" class:no-header={!header}>
|
||||
{#if header}
|
||||
<div class="header">
|
||||
<slot name="header" />
|
||||
{@render header?.()}
|
||||
</div>
|
||||
{/if}
|
||||
{#if is_browser}
|
||||
<div class="codemirror-wrapper editor" bind:this={element} />
|
||||
<div class="codemirror-wrapper editor" bind:this={element}></div>
|
||||
{:else}
|
||||
<div class="scm-waiting editor">
|
||||
<div class="scm-waiting__loading scm-loading">
|
||||
<div class="scm-loading__spinner" />
|
||||
<div class="scm-loading__spinner"></div>
|
||||
<p class="scm-loading__text">Loading editor...</p>
|
||||
</div>
|
||||
<div class="cm-editor"><pre class="scm-pre">{value}</pre></div>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<span class="site-name">Jade Ellis</span>
|
||||
</a>
|
||||
|
||||
<button on:click={sendFeedback} class="feedback-button">Report a bug</button>
|
||||
<button onclick={sendFeedback} class="feedback-button">Report a bug</button>
|
||||
</div>
|
||||
|
||||
{#each Object.entries(links) as [title, inner_links]}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<script lang="ts">
|
||||
import type { Endpoints } from "@octokit/types";
|
||||
|
||||
export let releaseData: Endpoints["GET /repos/{owner}/{repo}/releases/latest"]["response"]["data"];
|
||||
import { browser } from "$app/environment";
|
||||
interface Props {
|
||||
releaseData: Endpoints["GET /repos/{owner}/{repo}/releases/latest"]["response"]["data"];
|
||||
}
|
||||
|
||||
let { releaseData }: Props = $props();
|
||||
// console.log(releaseData);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import url from "./logo.svg?url";
|
||||
import { SITE_URL } from "$lib/metadata";
|
||||
let logo: HTMLDivElement;
|
||||
let logo: HTMLDivElement = $state();
|
||||
let wiggleCount = 0;
|
||||
function wiggle() {
|
||||
wiggleCount++;
|
||||
@@ -18,8 +20,8 @@
|
||||
<div class="hero card edge h-card">
|
||||
<div
|
||||
class="logo"
|
||||
on:click|preventDefault={wiggle}
|
||||
on:animationiteration={wiggleIteration}
|
||||
onclick={preventDefault(wiggle)}
|
||||
onanimationiteration={wiggleIteration}
|
||||
bind:this={logo}
|
||||
>
|
||||
<a href={SITE_URL} class="u-url u-uid" rel="me"
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<script lang="ts">
|
||||
import TocItem from "./TocItem.svelte";
|
||||
const className = "toc";
|
||||
type FlatHeading = { level: number; title: string };
|
||||
export let headings: nestedListNode[];
|
||||
interface Props {
|
||||
headings: nestedListNode[];
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let { headings }: Props = $props();
|
||||
|
||||
// creates a `class` property, even
|
||||
// though it is a reserved word
|
||||
export { className as class };
|
||||
export const listType = "ul";
|
||||
|
||||
let open = false;
|
||||
let open = $state(false);
|
||||
/** @type {import('./$types').Snapshot<string>} */
|
||||
export const snapshot = {
|
||||
capture: () => open,
|
||||
@@ -20,7 +23,7 @@
|
||||
</script>
|
||||
|
||||
{#if headings?.length > 0}
|
||||
<aside class={className}>
|
||||
<aside class="toc">
|
||||
<details bind:open>
|
||||
<summary accesskey="c" title="(Alt + C)">Table of Contents</summary>
|
||||
<div class="inner">
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<script lang="ts">
|
||||
import TocItem from './TocItem.svelte';
|
||||
|
||||
export let node: nestedListNode;
|
||||
interface Props {
|
||||
node: nestedListNode;
|
||||
}
|
||||
|
||||
let { node }: Props = $props();
|
||||
export const listType = "ul"
|
||||
</script>
|
||||
|
||||
@@ -9,7 +14,7 @@
|
||||
{#if node.children.length > 0}
|
||||
<svelte:element this={listType} class="toc-level {"toc-level-" + node.children[0].level}">
|
||||
{#each node.children as nodes}
|
||||
<svelte:self node={nodes} {listType} />
|
||||
<TocItem node={nodes} {listType} />
|
||||
{/each}
|
||||
</svelte:element>
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// import fontBoldUrl from './Inter-Bold.ttf?url';
|
||||
// import fontRegularUrl from './Inter-Regular.ttf?url';
|
||||
// This is a hack
|
||||
// Get the URL that the server is running on
|
||||
// console.log(import.meta.env)
|
||||
// let base = (import.meta.env.VITE_DOMAIN || "http://localhost:5173") + import.meta.env.BASE_URL;
|
||||
// if (base?.endsWith('/')) {
|
||||
// base = base.slice(0, -1);
|
||||
// }
|
||||
// // console.log(base)
|
||||
// const fontBoldData = await (await fetch(base + fontBoldUrl)).arrayBuffer();
|
||||
// const fontRegularData = await (await fetch(base + fontRegularUrl)).arrayBuffer();
|
||||
// import { readFileSync } from 'fs';
|
||||
// const fontBoldUrl = new URL('./Inter-Bold.ttf', import.meta.url).href
|
||||
// const fontBoldData = readFileSync(fontBoldUrl);
|
||||
// const fontRegularUrl = new URL('./Inter-Regular.ttf', import.meta.url).href
|
||||
// const fontRegularData = readFileSync(fontRegularUrl);
|
||||
// console.log(fontBoldUrl)
|
||||
// export { fontBoldData, fontRegularData };
|
||||
@@ -1,23 +1,33 @@
|
||||
<script lang="ts">
|
||||
export let src;
|
||||
export let alt;
|
||||
export let title;
|
||||
export let thumb;
|
||||
interface Props {
|
||||
src: any;
|
||||
alt: any;
|
||||
title: any;
|
||||
thumb: any;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
src,
|
||||
alt,
|
||||
title,
|
||||
thumb,
|
||||
class: className
|
||||
}: Props = $props();
|
||||
// export let align
|
||||
// export let small: boolean;
|
||||
// console.log("imgcmp", thumb);
|
||||
const className = "";
|
||||
export { className as class };
|
||||
let loaded = false
|
||||
let loaded = $state(false)
|
||||
// console.log(thumb)
|
||||
// import _PastedImage20240716123726Png from "./Pasted%20image%2020240716123726.png?meta";
|
||||
</script>
|
||||
|
||||
<figure class={className}>
|
||||
<!-- <figure class={className}> -->
|
||||
<!-- Svelte 5 hydration bug means we can't nest image inside figure -->
|
||||
<img
|
||||
{src}
|
||||
{alt}
|
||||
{title}
|
||||
class={className}
|
||||
width={thumb?.originalWidth}
|
||||
height={thumb?.originalHeight}
|
||||
style:background-image={loaded ? "none" : `url('${thumb?.thumbSrc}')`}
|
||||
@@ -25,10 +35,10 @@
|
||||
decoding="async"
|
||||
style:--aspect-ratio={thumb?.originalWidth / thumb?.originalHeight}
|
||||
/>
|
||||
{#if title}
|
||||
<!-- {#if title}
|
||||
<figcaption>{title}</figcaption>
|
||||
{/if}
|
||||
</figure>
|
||||
{/if} -->
|
||||
<!-- </figure> -->
|
||||
<!-- {:else}
|
||||
<img
|
||||
{src}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<script context="module">
|
||||
<script>
|
||||
/** @type {{children?: import('svelte').Snippet}} */
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
<script module>
|
||||
import img from "$lib/htmlComponents/img.svelte";
|
||||
import Callout from "$lib/Callout.svelte";
|
||||
export { img, Callout };
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
|
||||
@@ -15,20 +15,24 @@
|
||||
|
||||
const minify = init().minify;
|
||||
|
||||
let value = "";
|
||||
let output = "";
|
||||
let options: Config = {};
|
||||
let value = $state("");
|
||||
let output = $state("");
|
||||
let options: Config = $state({});
|
||||
async function process(str: string) {
|
||||
options = await parseMeta(str);
|
||||
const res = await bookmarkify(str, options, minify);
|
||||
if (typeof res == "string") {
|
||||
output = res;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
const contentAttributes = { "aria-label": "Bookmarklet editor" };
|
||||
|
||||
$: progress = process(value);
|
||||
let computation = $derived(process(value));
|
||||
|
||||
$effect(async () => {
|
||||
output = await computation;
|
||||
});
|
||||
</script>
|
||||
|
||||
<SvelteSeo
|
||||
@@ -45,11 +49,13 @@
|
||||
lang={javascript()}
|
||||
{contentAttributes}
|
||||
>
|
||||
<div slot="header" class="code-header">Input</div>
|
||||
{#snippet header()}
|
||||
<div class="code-header">Input</div>
|
||||
{/snippet}
|
||||
</Editor>
|
||||
|
||||
<h2>Output</h2>
|
||||
{#await progress}
|
||||
{#await computation}
|
||||
<p>...waiting</p>
|
||||
{:catch error}
|
||||
<p style="color: red">{error.message}</p>
|
||||
|
||||
@@ -13,16 +13,15 @@
|
||||
|
||||
const minify = init().minify;
|
||||
|
||||
let value = "";
|
||||
let output = "";
|
||||
async function process(str: string) {
|
||||
let value = $state("");
|
||||
let output = $state("");
|
||||
async function process(str: string): string {
|
||||
if (value === "") {
|
||||
output = "";
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
const result = await minify(str);
|
||||
if (typeof result.code == "string") {
|
||||
output = result.code;
|
||||
return result.code;
|
||||
} else {
|
||||
console.error(result);
|
||||
}
|
||||
@@ -30,7 +29,11 @@
|
||||
|
||||
const contentAttributes = { "aria-label": "Javascript editor" };
|
||||
|
||||
$: progress = process(value);
|
||||
let computation = $derived(process(value));
|
||||
|
||||
$effect(async () => {
|
||||
output = await computation;
|
||||
});
|
||||
</script>
|
||||
|
||||
<SvelteSeo
|
||||
@@ -47,11 +50,13 @@
|
||||
lang={javascript()}
|
||||
{contentAttributes}
|
||||
>
|
||||
<div slot="header" class="code-header">Input</div>
|
||||
{#snippet header()}
|
||||
<div class="code-header">Input</div>
|
||||
{/snippet}
|
||||
</Editor>
|
||||
|
||||
<h2>Output</h2>
|
||||
{#await progress}
|
||||
{#await computation}
|
||||
<p>...waiting</p>
|
||||
{:catch error}
|
||||
<p style="color: red">{error.message}</p>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
const { status, error } = $page;
|
||||
const message = error?.message || "Hmm";
|
||||
const title = `${status}: ${message}`;
|
||||
let sentryElement: HTMLDivElement;
|
||||
let openForm = () => {};
|
||||
let sentryElement: HTMLDivElement = $state();
|
||||
let openForm = $state(() => {});
|
||||
const online = typeof navigator !== 'undefined' ? navigator.onLine : true;
|
||||
onMount(async () => {
|
||||
const feedback = Sentry.getFeedback({
|
||||
@@ -55,8 +55,8 @@
|
||||
<p>Reload the page once you've found the internet.</p>
|
||||
{/if}
|
||||
<p>
|
||||
<button on:click={openForm}>Send Feedback</button>
|
||||
<button class="secondary" on:click={() => window.location.reload()}
|
||||
<button onclick={openForm}>Send Feedback</button>
|
||||
<button class="secondary" onclick={() => window.location.reload()}
|
||||
>Reload</button
|
||||
>
|
||||
</p>
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
import Nav from "$lib/Nav.svelte";
|
||||
import Footer from "$lib/Footer.svelte";
|
||||
import { SITE_TITLE } from "$lib/metadata"
|
||||
interface Props {
|
||||
children?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let { children }: Props = $props();
|
||||
</script>
|
||||
<svelte:head>
|
||||
<Favicons />
|
||||
@@ -12,5 +17,5 @@
|
||||
<meta property="og:site_name" content={SITE_TITLE}>
|
||||
</svelte:head>
|
||||
<Nav />
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
<Footer />
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Hero from "$lib/Hero.svelte";
|
||||
import SvelteSeo from "svelte-seo";
|
||||
import Homepage from "Notes/Website Homepage.md";
|
||||
import Homepage from "$notes/Website Homepage.md";
|
||||
import { SITE_URL, SITE_TITLE } from "$lib/metadata";
|
||||
import { onMount } from "svelte";
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
import SvelteSeo from "svelte-seo";
|
||||
|
||||
import type { WithContext, Thing } from "schema-dts";
|
||||
export let data;
|
||||
interface Props {
|
||||
data: any;
|
||||
}
|
||||
|
||||
let { data }: Props = $props();
|
||||
const { pages } = data;
|
||||
|
||||
const jsonLd = {
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
// https://github.com/mattjennings/sveltekit-blog-template/blob/main/src/routes/post/%5Bslug%5D/%2Bpage.svelte
|
||||
|
||||
import { browser } from "$app/environment";
|
||||
import SvelteSeo from "svelte-seo";
|
||||
export let data;
|
||||
import { SITE_URL, SITE_TITLE } from "$lib/metadata";
|
||||
import Toc from "$lib/Toc.svelte";
|
||||
import type { WithContext, Thing } from "schema-dts";
|
||||
import pfpUrl from "$lib/logo.svg?url";
|
||||
import { gtag } from "$lib/analytics.js";
|
||||
// let GhReleasesDownload: Promise<any>;
|
||||
// if (data.ghReleaseData) {
|
||||
// GhReleasesDownload = import("$lib/GhReleasesDownload.svelte").then((m) => m.default)
|
||||
// }
|
||||
$: canonical = SITE_URL + "/blog/" + data.post.canonical;
|
||||
interface Props {
|
||||
data: any;
|
||||
}
|
||||
|
||||
let { data }: Props = $props();
|
||||
// console.log(data)
|
||||
function calcOgURL(
|
||||
slug: string,
|
||||
date: string,
|
||||
@@ -33,10 +34,6 @@
|
||||
return url;
|
||||
}
|
||||
|
||||
$: webShareAPISupported = browser && typeof navigator.share !== "undefined";
|
||||
// let webShareAPISupported = true;
|
||||
|
||||
$: handleWebShare;
|
||||
const handleWebShare = async () => {
|
||||
try {
|
||||
const url = new URL(canonical);
|
||||
@@ -69,7 +66,21 @@
|
||||
fediverse: "@JadedBlueEyes@tech.lgbt",
|
||||
image: pfpUrl,
|
||||
};
|
||||
$: jsonLd = {
|
||||
// let GhReleasesDownload: Promise<any>;
|
||||
// if (data.ghReleaseData) {
|
||||
// GhReleasesDownload = import("$lib/GhReleasesDownload.svelte").then((m) => m.default)
|
||||
// }
|
||||
let canonical = $derived(SITE_URL + "/blog/" + data.post.canonical);
|
||||
let webShareAPISupported;
|
||||
run(() => {
|
||||
webShareAPISupported = browser && typeof navigator.share !== "undefined";
|
||||
});
|
||||
// let webShareAPISupported = true;
|
||||
|
||||
run(() => {
|
||||
handleWebShare;
|
||||
});
|
||||
let jsonLd = $derived({
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebPage",
|
||||
breadcrumb: {
|
||||
@@ -118,7 +129,7 @@
|
||||
name: "Jade's Blog",
|
||||
},
|
||||
},
|
||||
} as WithContext<Thing>;
|
||||
} as WithContext<Thing>);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -199,7 +210,7 @@
|
||||
>
|
||||
· <span class="reading-time ib">{data.post.readingTime.text}</span>
|
||||
{#if webShareAPISupported}
|
||||
· <button class="link" on:click={handleWebShare}>Share</button>
|
||||
· <button class="link" onclick={handleWebShare}>Share</button>
|
||||
{/if}
|
||||
</aside>
|
||||
<Toc headings={data.post.headings} />
|
||||
@@ -210,7 +221,7 @@
|
||||
{/await} -->
|
||||
|
||||
<div class="e-content">
|
||||
<svelte:component this={data.component} />
|
||||
<data.component />
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
@@ -11,10 +11,9 @@ export async function load({ data, params }) {
|
||||
// console.log(data)
|
||||
const component =
|
||||
// await import(data.page.filepath)
|
||||
await import("Notes/Blogs/" + data.page.filepath.name + ".md")
|
||||
await import(`$notes/Blogs/${data.page.filepath.name}.md`)
|
||||
// console.log(data.page.filepath)
|
||||
|
||||
|
||||
return {
|
||||
post: data.page,
|
||||
component: component.default
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { pages } from '../posts'
|
||||
import { error, type RequestHandler } from '@sveltejs/kit'
|
||||
|
||||
export const prerender = false;
|
||||
import satori from 'satori';
|
||||
import { Resvg } from '@resvg/resvg-js';
|
||||
import { SITE_DOMAIN } from '$lib/metadata';
|
||||
@@ -8,13 +8,18 @@ import TTLCache from "@isaacs/ttlcache";
|
||||
import { format } from "@tusbar/cache-control";
|
||||
const cache = new TTLCache({ max: 10000, ttl: 1000 * 60 * 60 })
|
||||
import fnv from "fnv-plus"
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
// const fontFile = await fetch('https://og-playground.vercel.app/inter-latin-ext-700-normal.woff');
|
||||
const fontBoldUrl = new URL('./Inter-Bold.ttf', import.meta.url)
|
||||
const fontBoldData = readFileSync(fontBoldUrl);
|
||||
const fontRegularUrl = new URL('./Inter-Regular.ttf', import.meta.url)
|
||||
const fontRegularData = readFileSync(fontRegularUrl);
|
||||
|
||||
// import fontBoldString from '$lib/assets/Inter-Bold.ttf?raw';
|
||||
// import fontRegularString from '$lib/assets/Inter-Regular.ttf?raw';
|
||||
// const fontBoldData = Buffer.from(fontBoldString);
|
||||
// const fontRegularData = Buffer.from(fontRegularString);
|
||||
|
||||
// import { fontBoldData, fontRegularData } from '$lib/assets/fonts';
|
||||
// Hacky hack because sveltekit
|
||||
const fontBoldData = await (await fetch("https://config-servers-1.ellis.link/Inter-Bold.ttf")).arrayBuffer();
|
||||
const fontRegularData = await (await fetch("https://config-servers-1.ellis.link/Inter-Regular.ttf")).arrayBuffer();
|
||||
|
||||
|
||||
const defaultWidth = 800;
|
||||
const defaultRatio = 0.5
|
||||
|
||||
@@ -65,18 +65,20 @@ if (browser) {
|
||||
// previous: allPosts[index + 1]
|
||||
// }))
|
||||
const dateRegex = /^((?<year>\d{4})-(?<month>[0][1-9]|1[0-2])-(?<day>[0][1-9]|[1-2]\d|3[01]))\s*/
|
||||
export const pages = Object.entries(import.meta.glob('/node_modules/Notes/Blogs/*.md', { eager: true }))
|
||||
.map(([filepath, post]) => {
|
||||
|
||||
export const pages = (await Promise.all(Object.entries(import.meta.glob('$notes/Blogs/*.md', { eager: true}))
|
||||
.map(async ([filepath, post]) => {
|
||||
const path = parse(filepath);
|
||||
const title = path.name.replace(dateRegex, "")
|
||||
|
||||
|
||||
// @ts-ignore
|
||||
// let {year, month, day}: { year: string, month: string, day: string } = path.name.match(dateRegex)?.groups;
|
||||
// let {year, month, day}: { year: string, month: string, day: strisng } = path.name.match(dateRegex)?.groups;
|
||||
|
||||
// console.log(year, month, day)
|
||||
const date = path.name.match(dateRegex)[1];
|
||||
const datePath = date.replaceAll("-", "/")
|
||||
const slug = slugify(title, { lower: true })
|
||||
|
||||
return {
|
||||
title,
|
||||
date,
|
||||
@@ -85,10 +87,9 @@ export const pages = Object.entries(import.meta.glob('/node_modules/Notes/Blogs/
|
||||
...post.metadata,
|
||||
|
||||
slug,
|
||||
// filepath: relative(import.meta.dirname, filepath)
|
||||
filepath: path
|
||||
}
|
||||
})
|
||||
})))
|
||||
// sort by date
|
||||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
|
||||
// Get all posts and add metadata
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
// https://github.com/mattjennings/sveltekit-blog-template/blob/main/src/routes/post/%5Bslug%5D/%2Bpage.svelte
|
||||
|
||||
import SvelteSeo from "svelte-seo";
|
||||
export let data;
|
||||
import { SITE_URL } from "$lib/metadata";
|
||||
import GhReleasesDownload from "$lib/GhReleasesDownload.svelte";
|
||||
interface Props {
|
||||
data: any;
|
||||
}
|
||||
|
||||
let { data }: Props = $props();
|
||||
// let GhReleasesDownload: Promise<any>;
|
||||
// if (data.ghReleaseData) {
|
||||
// GhReleasesDownload = import("$lib/GhReleasesDownload.svelte").then((m) => m.default)
|
||||
@@ -31,5 +35,5 @@
|
||||
<GhReleasesDownload releaseData={data.ghReleaseData} />
|
||||
{/if}
|
||||
|
||||
<svelte:component this={data.component} />
|
||||
<data.component />
|
||||
</main>
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function load({ data }) {
|
||||
// load the markdown file based on slug
|
||||
const component =
|
||||
// await import(data.page.filepath)
|
||||
await import("Notes/Projects/" + data.page.filepath.name + ".md")
|
||||
await import(`$notes/Projects/${data.page.filepath.name}.md`)
|
||||
// console.log(data.page.filepath)
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ if (browser) {
|
||||
throw new Error(`posts can only be imported server-side`)
|
||||
}
|
||||
|
||||
export const pages = Object.entries(import.meta.glob('/node_modules/Notes/Projects/*.md', { eager: true }))
|
||||
export const pages = Object.entries(import.meta.glob('$notes/Projects/*.md', { eager: true }))
|
||||
.map(([filepath, post]) => {
|
||||
const path = parse(filepath);
|
||||
const slug = slugify(path.name, { lower: true })
|
||||
|
||||
@@ -7,7 +7,7 @@ import slugify from 'slugify';
|
||||
|
||||
import { parse, format } from "node:path";
|
||||
import { pages as blogPosts } from "../blog/posts"
|
||||
const projects = Object.entries(import.meta.glob('/node_modules/Notes/Projects/*.md', { eager: true }))
|
||||
const projects = Object.entries(import.meta.glob('$notes/Projects/*.md', { eager: true }))
|
||||
.map(([filepath, post]) => {
|
||||
return parse(filepath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user