From bc44372c961c40465c741167a662ee3908eec4ea Mon Sep 17 00:00:00 2001 From: Harsh Mahajan Date: Tue, 11 Nov 2025 12:39:42 +0000 Subject: [PATCH 1/3] init --- .../components/blog/copy-as-markdown.svelte | 22 ++++++++++++++----- src/lib/remote/markdown.remote.ts | 19 ++++++++++++++++ svelte.config.js | 4 +++- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/lib/remote/markdown.remote.ts diff --git a/src/lib/components/blog/copy-as-markdown.svelte b/src/lib/components/blog/copy-as-markdown.svelte index 54e111f36c..ea4713db5b 100644 --- a/src/lib/components/blog/copy-as-markdown.svelte +++ b/src/lib/components/blog/copy-as-markdown.svelte @@ -1,19 +1,29 @@ -{#if $rawContent} +{#if !markdown.loading && markdown.current} + {#snippet tooltip()} + Copied + {/snippet} + + + + + {#if $open} + {/if} - + {/if} + + diff --git a/src/lib/components/blog/table-of-contents.svelte b/src/lib/components/blog/table-of-contents.svelte index c06bc12ee0..ae091cf713 100644 --- a/src/lib/components/blog/table-of-contents.svelte +++ b/src/lib/components/blog/table-of-contents.svelte @@ -81,5 +81,4 @@ style:transform={`translateY(${position}px)`} > - diff --git a/src/lib/components/ui/icon/sprite/sprite.svelte b/src/lib/components/ui/icon/sprite/sprite.svelte index efc46b18bb..033b45cdd4 100644 --- a/src/lib/components/ui/icon/sprite/sprite.svelte +++ b/src/lib/components/ui/icon/sprite/sprite.svelte @@ -3,20 +3,18 @@ xmlns:xlink="http://www.w3.org/1999/xlink" style="display: none;" > - - + + + + + - + @@ -27,222 +25,222 @@ fill="currentColor" > - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + - + - + - + - + - + - + - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + + + + - + - + - + - + - + - + - + ; @@ -40,7 +41,7 @@
diff --git a/src/lib/remote/markdown.remote.ts b/src/lib/remote/markdown.remote.ts index 9d78365c44..1be8cc4dc4 100644 --- a/src/lib/remote/markdown.remote.ts +++ b/src/lib/remote/markdown.remote.ts @@ -2,18 +2,13 @@ import { query } from '$app/server'; import { readFile } from 'fs/promises'; import { join } from 'path'; -export const getPageMarkdown = query( - 'unchecked', - async (routeId: string | null) => { - if (!routeId) return null; - - try { - const basePath = join(process.cwd(), 'src', 'routes', routeId, '+page.markdoc'); - return await readFile(basePath, 'utf-8'); - } catch (e) { - return null; - } - } -); - +export const getPageMarkdown = query('unchecked', async (routeId: string | null) => { + if (!routeId) return null; + try { + const basePath = join(process.cwd(), 'src', 'routes', routeId, '+page.markdoc'); + return await readFile(basePath, 'utf-8'); + } catch (e) { + return null; + } +}); From de199980acc48048b9ce932bcbc44590e8249dd5 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan Date: Tue, 11 Nov 2025 18:17:24 +0000 Subject: [PATCH 3/3] Move getMarkdownContent into markdown.remote.ts and remove duplicate file --- src/lib/remote/markdown.remote.ts | 7 ++++--- src/lib/utils/get-markdown-content.ts | 12 ------------ src/routes/blog/+layout.server.ts | 4 ++-- src/routes/docs/+layout.server.ts | 4 ++-- 4 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 src/lib/utils/get-markdown-content.ts diff --git a/src/lib/remote/markdown.remote.ts b/src/lib/remote/markdown.remote.ts index 1be8cc4dc4..e7a4071e12 100644 --- a/src/lib/remote/markdown.remote.ts +++ b/src/lib/remote/markdown.remote.ts @@ -2,13 +2,14 @@ import { query } from '$app/server'; import { readFile } from 'fs/promises'; import { join } from 'path'; -export const getPageMarkdown = query('unchecked', async (routeId: string | null) => { +const getMarkdownContent = async (routeId: string | null) => { if (!routeId) return null; - try { const basePath = join(process.cwd(), 'src', 'routes', routeId, '+page.markdoc'); return await readFile(basePath, 'utf-8'); } catch (e) { return null; } -}); +}; + +export const getPageMarkdown = query('unchecked', getMarkdownContent); diff --git a/src/lib/utils/get-markdown-content.ts b/src/lib/utils/get-markdown-content.ts deleted file mode 100644 index e2860fb5d9..0000000000 --- a/src/lib/utils/get-markdown-content.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { readFile } from 'fs/promises'; -import { join } from 'path'; - -export const getMarkdownContent = async (slug: T) => { - if (!slug) return null; - try { - const basePath = join(process.cwd(), 'src', 'routes', slug, '+page.markdoc'); - return await readFile(basePath, 'utf-8'); - } catch (e) { - return null; - } -}; diff --git a/src/routes/blog/+layout.server.ts b/src/routes/blog/+layout.server.ts index 22833f0960..fa5296da9f 100644 --- a/src/routes/blog/+layout.server.ts +++ b/src/routes/blog/+layout.server.ts @@ -1,8 +1,8 @@ -import { getMarkdownContent } from '$lib/utils/get-markdown-content'; +import { getPageMarkdown } from '$lib/remote/markdown.remote'; import type { LayoutRouteId } from './$types'; export const load = async ({ route }) => { return { - rawContent: await getMarkdownContent(route.id) + rawContent: await getPageMarkdown(route.id as LayoutRouteId) }; }; diff --git a/src/routes/docs/+layout.server.ts b/src/routes/docs/+layout.server.ts index 22833f0960..fa5296da9f 100644 --- a/src/routes/docs/+layout.server.ts +++ b/src/routes/docs/+layout.server.ts @@ -1,8 +1,8 @@ -import { getMarkdownContent } from '$lib/utils/get-markdown-content'; +import { getPageMarkdown } from '$lib/remote/markdown.remote'; import type { LayoutRouteId } from './$types'; export const load = async ({ route }) => { return { - rawContent: await getMarkdownContent(route.id) + rawContent: await getPageMarkdown(route.id as LayoutRouteId) }; };