fix: use instance.data instead of profile.data.instance, fix SSR handoff crash
This commit is contained in:
8 files changed
+46
-15
No files matched your search
Vendored
+2
-1
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"i18n-ally.localesPaths": ["src/lib/i18n"],
|
||||
"i18n-ally.keystyle": "nested",
|
||||
"prettier.prettierPath": ""
|
||||
"prettier.prettierPath": "",
|
||||
"search.searchOnTypeDebouncePeriod": 0
|
||||
}
|
||||
@@ -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') })
|
||||
|
||||
@@ -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 @@
|
||||
</header>
|
||||
{#if title && id}
|
||||
<a
|
||||
href="/post/{encodeURIComponent(profile.data.instance)}/{id}"
|
||||
href="/post/{encodeURIComponent(instance.data)}/{id}"
|
||||
class="inline hover:underline
|
||||
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
|
||||
{settings.font == 'satoshi/nunito'
|
||||
@@ -316,12 +317,14 @@
|
||||
style="grid-area: title;"
|
||||
data-sveltekit-preload-data="tap"
|
||||
>
|
||||
<Markdown
|
||||
source={title}
|
||||
inline
|
||||
noStyle
|
||||
class={view == 'compact' ? '' : 'leading-[1.3]'}
|
||||
></Markdown>
|
||||
{#if title}
|
||||
<Markdown
|
||||
source={title}
|
||||
inline
|
||||
noStyle
|
||||
class={view == 'compact' ? '' : 'leading-[1.3]'}
|
||||
></Markdown>
|
||||
{/if}
|
||||
</a>
|
||||
{:else}
|
||||
<div style="grid-area: title; margin: 0;"></div>
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -119,7 +142,7 @@
|
||||
>
|
||||
<SvelteMarkdown
|
||||
source={tokens}
|
||||
{renderers}
|
||||
renderers={inline ? inlineRenderers : renderers}
|
||||
{options}
|
||||
isInline={inline || undefined}
|
||||
/>
|
||||
|
||||
@@ -16,6 +16,7 @@ import MdParagraph from './MdParagraph.svelte'
|
||||
import MdListItem from './MdListItem.svelte'
|
||||
import MdSubscript from './MdSubscript.svelte'
|
||||
import MdSuperscript from './MdSuperscript.svelte'
|
||||
import MdText from './MdText.svelte'
|
||||
|
||||
export {
|
||||
MdCode,
|
||||
@@ -36,4 +37,5 @@ export {
|
||||
MdListItem,
|
||||
MdSubscript,
|
||||
MdSuperscript,
|
||||
MdText,
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class InstanceData {
|
||||
#instance = $derived(profile.data.instance)
|
||||
|
||||
get data() {
|
||||
return this.#instance
|
||||
return this.#instance ?? DEFAULT_INSTANCE_URL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { instance } from '$lib/instance.svelte'
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
@@ -6,6 +6,6 @@ export function load({ params }) {
|
||||
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
||||
redirect(
|
||||
302,
|
||||
`/comment/${encodeURIComponent(profile.data.instance)}/${params.instance}`,
|
||||
`/comment/${encodeURIComponent(instance.data)}/${params.instance}`,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user