fix: use instance.data instead of profile.data.instance, fix SSR handoff crash
This commit is contained in:
8 files changed
+40
-9
No files matched your search
Vendored
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"i18n-ally.localesPaths": ["src/lib/i18n"],
|
"i18n-ally.localesPaths": ["src/lib/i18n"],
|
||||||
"i18n-ally.keystyle": "nested",
|
"i18n-ally.keystyle": "nested",
|
||||||
"prettier.prettierPath": ""
|
"prettier.prettierPath": "",
|
||||||
|
"search.searchOnTypeDebouncePeriod": 0
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
import RelativeDate, {
|
import RelativeDate, {
|
||||||
formatRelativeDate,
|
formatRelativeDate,
|
||||||
} from '$lib/components/util/RelativeDate.svelte'
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import { instance } from '$lib/instance.svelte'
|
||||||
|
|
||||||
let editing = $state(false)
|
let editing = $state(false)
|
||||||
let saving = $state(false)
|
let saving = $state(false)
|
||||||
@@ -327,12 +328,12 @@
|
|||||||
onclick={() => {
|
onclick={() => {
|
||||||
navigator.share?.({
|
navigator.share?.({
|
||||||
url: localShare
|
url: localShare
|
||||||
? `${instanceToURL(profile.data.instance)}/post/${post.post.id}`
|
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
||||||
: post.post.ap_id,
|
: post.post.ap_id,
|
||||||
}) ??
|
}) ??
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
localShare
|
localShare
|
||||||
? `${instanceToURL(profile.data.instance)}/post/${post.post.id}`
|
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
||||||
: post.post.ap_id,
|
: post.post.ap_id,
|
||||||
)
|
)
|
||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { instance } from '$lib/instance.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community?: Community | undefined
|
community?: Community | undefined
|
||||||
@@ -303,7 +304,7 @@
|
|||||||
</header>
|
</header>
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
<a
|
<a
|
||||||
href="/post/{encodeURIComponent(profile.data.instance)}/{id}"
|
href="/post/{encodeURIComponent(instance.data)}/{id}"
|
||||||
class="inline hover:underline
|
class="inline hover:underline
|
||||||
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
|
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
|
||||||
{settings.font == 'satoshi/nunito'
|
{settings.font == 'satoshi/nunito'
|
||||||
@@ -316,12 +317,14 @@
|
|||||||
style="grid-area: title;"
|
style="grid-area: title;"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
|
{#if title}
|
||||||
<Markdown
|
<Markdown
|
||||||
source={title}
|
source={title}
|
||||||
inline
|
inline
|
||||||
noStyle
|
noStyle
|
||||||
class={view == 'compact' ? '' : 'leading-[1.3]'}
|
class={view == 'compact' ? '' : 'leading-[1.3]'}
|
||||||
></Markdown>
|
></Markdown>
|
||||||
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<div style="grid-area: title; margin: 0;"></div>
|
<div style="grid-area: title; margin: 0;"></div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { instance } from '$lib/instance.svelte'
|
||||||
import { client } from '$lib/lemmy.svelte.js'
|
import { client } from '$lib/lemmy.svelte.js'
|
||||||
import type { View } from '$lib/settings.svelte'
|
import type { View } from '$lib/settings.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image'
|
import { isImage, isVideo } from '$lib/ui/image'
|
||||||
@@ -61,7 +62,7 @@ export const isYoutubeLink = (url?: string): RegExpMatchArray | null => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const postLink = (post: Post) =>
|
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 MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none'
|
||||||
export type IframeType = 'youtube' | 'video' | 'none'
|
export type IframeType = 'youtube' | 'video' | 'none'
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
MdListItem,
|
MdListItem,
|
||||||
MdSubscript,
|
MdSubscript,
|
||||||
MdSuperscript,
|
MdSuperscript,
|
||||||
|
MdText,
|
||||||
} from './renderers/index'
|
} from './renderers/index'
|
||||||
import { linkify, subSupscriptExtension } from './renderers/plugins'
|
import { linkify, subSupscriptExtension } from './renderers/plugins'
|
||||||
import containerExtension from './renderers/spoiler/spoiler'
|
import containerExtension from './renderers/spoiler/spoiler'
|
||||||
@@ -85,6 +86,28 @@
|
|||||||
subscript: MdSubscript,
|
subscript: MdSubscript,
|
||||||
superscript: MdSuperscript,
|
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>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -119,7 +142,7 @@
|
|||||||
>
|
>
|
||||||
<SvelteMarkdown
|
<SvelteMarkdown
|
||||||
source={tokens}
|
source={tokens}
|
||||||
{renderers}
|
renderers={inline ? inlineRenderers : renderers}
|
||||||
{options}
|
{options}
|
||||||
isInline={inline || undefined}
|
isInline={inline || undefined}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import MdParagraph from './MdParagraph.svelte'
|
|||||||
import MdListItem from './MdListItem.svelte'
|
import MdListItem from './MdListItem.svelte'
|
||||||
import MdSubscript from './MdSubscript.svelte'
|
import MdSubscript from './MdSubscript.svelte'
|
||||||
import MdSuperscript from './MdSuperscript.svelte'
|
import MdSuperscript from './MdSuperscript.svelte'
|
||||||
|
import MdText from './MdText.svelte'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
MdCode,
|
MdCode,
|
||||||
@@ -36,4 +37,5 @@ export {
|
|||||||
MdListItem,
|
MdListItem,
|
||||||
MdSubscript,
|
MdSubscript,
|
||||||
MdSuperscript,
|
MdSuperscript,
|
||||||
|
MdText,
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ class InstanceData {
|
|||||||
#instance = $derived(profile.data.instance)
|
#instance = $derived(profile.data.instance)
|
||||||
|
|
||||||
get data() {
|
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 { redirect } from '@sveltejs/kit'
|
||||||
import { get } from 'svelte/store'
|
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.
|
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
`/comment/${encodeURIComponent(profile.data.instance)}/${params.instance}`,
|
`/comment/${encodeURIComponent(instance.data)}/${params.instance}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user