From 99acddf7edb73d7d8f46a17a68f5c0cc13b31a0a Mon Sep 17 00:00:00 2001 From: James Xylight Date: Mon, 17 Feb 2025 12:50:52 -0800 Subject: [PATCH] fix: use instance.data instead of profile.data.instance, fix SSR handoff crash --- .vscode/settings.json | 3 ++- .../components/lemmy/post/PostActions.svelte | 5 ++-- src/lib/components/lemmy/post/PostMeta.svelte | 17 +++++++------ src/lib/components/lemmy/post/helpers.ts | 3 ++- src/lib/components/markdown/Markdown.svelte | 25 ++++++++++++++++++- .../components/markdown/renderers/index.ts | 2 ++ src/lib/instance.svelte.ts | 2 +- src/routes/comment/[instance]/+page.ts | 4 +-- 8 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e76e1688..5ece412e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "i18n-ally.localesPaths": ["src/lib/i18n"], "i18n-ally.keystyle": "nested", - "prettier.prettierPath": "" + "prettier.prettierPath": "", + "search.searchOnTypeDebouncePeriod": 0 } diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte index fcc2c893..d0e83119 100644 --- a/src/lib/components/lemmy/post/PostActions.svelte +++ b/src/lib/components/lemmy/post/PostActions.svelte @@ -57,6 +57,7 @@ import RelativeDate, { formatRelativeDate, } from '$lib/components/util/RelativeDate.svelte' + import { instance } from '$lib/instance.svelte' let editing = $state(false) let saving = $state(false) @@ -327,12 +328,12 @@ onclick={() => { navigator.share?.({ url: localShare - ? `${instanceToURL(profile.data.instance)}/post/${post.post.id}` + ? `${instanceToURL(instance.data)}/post/${post.post.id}` : post.post.ap_id, }) ?? navigator.clipboard.writeText( localShare - ? `${instanceToURL(profile.data.instance)}/post/${post.post.id}` + ? `${instanceToURL(instance.data)}/post/${post.post.id}` : post.post.ap_id, ) toast({ content: $t('toast.copied') }) diff --git a/src/lib/components/lemmy/post/PostMeta.svelte b/src/lib/components/lemmy/post/PostMeta.svelte index dd13601f..1aeb59a6 100644 --- a/src/lib/components/lemmy/post/PostMeta.svelte +++ b/src/lib/components/lemmy/post/PostMeta.svelte @@ -69,6 +69,7 @@ import CommunityHeader from '../community/CommunityHeader.svelte' import { publishedToDate } from '$lib/components/util/date' import { profile } from '$lib/auth.svelte' + import { instance } from '$lib/instance.svelte' interface Props { community?: Community | undefined @@ -303,7 +304,7 @@ {#if title && id} - + {#if title} + + {/if} {:else}
diff --git a/src/lib/components/lemmy/post/helpers.ts b/src/lib/components/lemmy/post/helpers.ts index 60cbe093..320ec22b 100644 --- a/src/lib/components/lemmy/post/helpers.ts +++ b/src/lib/components/lemmy/post/helpers.ts @@ -1,4 +1,5 @@ import { profile } from '$lib/auth.svelte' +import { instance } from '$lib/instance.svelte' import { client } from '$lib/lemmy.svelte.js' import type { View } from '$lib/settings.svelte' import { isImage, isVideo } from '$lib/ui/image' @@ -61,7 +62,7 @@ export const isYoutubeLink = (url?: string): RegExpMatchArray | null => { } export const postLink = (post: Post) => - `/post/${encodeURIComponent(profile.data.instance)}/${post.id}` + `/post/${encodeURIComponent(instance.data)}/${post.id}` export type MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none' export type IframeType = 'youtube' | 'video' | 'none' diff --git a/src/lib/components/markdown/Markdown.svelte b/src/lib/components/markdown/Markdown.svelte index 24f277ab..436e48a3 100644 --- a/src/lib/components/markdown/Markdown.svelte +++ b/src/lib/components/markdown/Markdown.svelte @@ -19,6 +19,7 @@ MdListItem, MdSubscript, MdSuperscript, + MdText, } from './renderers/index' import { linkify, subSupscriptExtension } from './renderers/plugins' import containerExtension from './renderers/spoiler/spoiler' @@ -85,6 +86,28 @@ subscript: MdSubscript, superscript: MdSuperscript, } + + export const inlineRenderers = { + heading: MdText, + image: MdText, + link: MdText, + blockquote: MdText, + hr: MdText, + html: MdText, + code: MdText, + list: MdText, + // @ts-ignore + spoiler: MdText, + table: MdText, + tablebody: MdText, + tablecell: MdText, + tablehead: MdText, + tablerow: MdTableRow, + paragraph: MdParagraph, + listitem: MdText, + subscript: MdSubscript, + superscript: MdSuperscript, + }