fix: ssr issues

This commit is contained in:
Xyphyn committed 2023-10-10 17:15:08 -07:00
1 parent e3c7aca8ee
commit 16154bbc23
9 files changed
+45 -45

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "photon-lemmy", "name": "photon-lemmy",
"version": "1.18.2", "version": "1.19.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
+4 -6
View File
@@ -31,6 +31,7 @@
: view == 'list' : view == 'list'
? 'py-5' ? 'py-5'
: 'py-5'}" : 'py-5'}"
id={post.post.id}
> >
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -83,9 +84,7 @@
<svelte:element <svelte:element
this={$userSettings.expandImages ? 'div' : 'a'} this={$userSettings.expandImages ? 'div' : 'a'}
href={postLink(post.post)} href={postLink(post.post)}
class="container mx-auto z-10 transition-colors {loaded class="container mx-auto z-10 transition-colors rounded-xl max-h-[60vh] relative overflow-hidden"
? ''
: 'bg-slate-200 dark:bg-zinc-800'} rounded-xl max-h-[60vh] relative overflow-hidden"
data-sveltekit-preload-data="off" data-sveltekit-preload-data="off"
aria-label={post.post.name} aria-label={post.post.name}
> >
@@ -126,8 +125,7 @@
src={bestImageURL(post.post, false, 1024)} src={bestImageURL(post.post, false, 1024)}
loading="lazy" loading="lazy"
class="max-h-[inherit] max-w-full h-auto z-30 class="max-h-[inherit] max-w-full h-auto z-30
opacity-0 transition-opacity duration-300 object-contain mx-auto" transition-opacity duration-300 object-contain mx-auto"
class:opacity-100={loaded}
width={512} width={512}
height={300} height={300}
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur} class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
@@ -168,7 +166,7 @@
dark:from-zinc-400 dark:via-zinc-400 bg-clip-text dark:from-zinc-400 dark:via-zinc-400 bg-clip-text
{view == 'list' ? `max-h-24` : 'max-h-48'}" {view == 'list' ? `max-h-24` : 'max-h-48'}"
> >
<Markdown inline source={post.post.body.slice(0, 500)} /> <Markdown inline source={post.post.body} />
</div> </div>
{/if} {/if}
</div> </div>
@@ -11,11 +11,10 @@
export let community: boolean = false export let community: boolean = false
</script> </script>
<div <ul
class="flex flex-col {$userSettings.view == 'card' class="flex flex-col list-none {$userSettings.view == 'card'
? 'gap-3 md:gap-4' ? 'gap-3 md:gap-4'
: ''} divide-slate-200 dark:divide-zinc-800" : 'divide-y'} divide-slate-200 dark:divide-zinc-800"
class:divide-y={$userSettings.view != 'card'}
> >
{#if posts.length == 0} {#if posts.length == 0}
<div class="h-full grid place-items-center"> <div class="h-full grid place-items-center">
@@ -31,9 +30,9 @@
</Placeholder> </Placeholder>
</div> </div>
{:else} {:else}
{#each posts as post, index (post.post.id)} {#each posts as post, index}
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
<div <li
in:fly|global={{ in:fly|global={{
y: -8, y: -8,
duration: 500, duration: 500,
@@ -42,8 +41,8 @@
}} }}
> >
<Post hideCommunity={community} view={$userSettings.view} bind:post /> <Post hideCommunity={community} view={$userSettings.view} bind:post />
</div> </li>
{/if} {/if}
{/each} {/each}
{/if} {/if}
</div> </ul>
@@ -39,11 +39,10 @@
</script> </script>
<slot {vote} {score}> <slot {vote} {score}>
<Popover openOnHover placement="bottom"> <!-- <Popover openOnHover placement="bottom"> -->
<div <div
class=" flex items-center text-sm gap-1 rounded-md border border-slate-200 class=" flex items-center text-sm gap-1 rounded-md border border-slate-200
dark:border-zinc-800 bg-white dark:bg-zinc-900 px-1 h-8 cursor-pointer" dark:border-zinc-800 bg-white dark:bg-zinc-900 px-1 h-8 cursor-pointer"
slot="target"
> >
<Button <Button
aria-label="Upvote" aria-label="Upvote"
@@ -58,9 +57,7 @@
<Icon src={ChevronUp} mini size="18" /> <Icon src={ChevronUp} mini size="18" />
</Button> </Button>
<span <span
class="font-medium transition-colors duration-200 grid {voteColor( class="font-medium transition-colors duration-200 grid {voteColor(vote)}"
vote
)}"
class:hidden={$profile?.user?.local_user_view.local_user.show_scores == class:hidden={$profile?.user?.local_user_view.local_user.show_scores ==
false} false}
> >
@@ -87,7 +84,7 @@
<Icon src={ChevronDown} mini size="18" /> <Icon src={ChevronDown} mini size="18" />
</Button> </Button>
</div> </div>
<div class="flex items-center gap-2"> <!-- <div class="flex items-center gap-2">
<div class="flex items-center font-medium text-blue-500 gap-0.5"> <div class="flex items-center font-medium text-blue-500 gap-0.5">
<Icon src={ArrowUp} mini size="18" title="Upvotes" /> <Icon src={ArrowUp} mini size="18" title="Upvotes" />
{upvotes} {upvotes}
@@ -96,6 +93,6 @@
<Icon src={ArrowDown} mini size="18" title="Downvotes" /> <Icon src={ArrowDown} mini size="18" title="Downvotes" />
{downvotes} {downvotes}
</div> </div>
</div> </div> -->
</Popover> <!-- </Popover> -->
</slot> </slot>
+10 -4
View File
@@ -1,10 +1,12 @@
<script lang="ts"> <script lang="ts">
import { md, mdInline, photonify } from '$lib/components/markdown/markdown' import { md, mdInline, photonify } from '$lib/components/markdown/markdown'
import { userSettings } from '$lib/settings.js' import { onMount } from 'svelte'
export let source: string = '' export let source: string = ''
export let inline: boolean = false export let inline: boolean = false
let rendered = ''
function replaceURLs(node: HTMLElement, source: string) { function replaceURLs(node: HTMLElement, source: string) {
if (!div) return if (!div) return
const links = node.querySelectorAll('a') const links = node.querySelectorAll('a')
@@ -17,18 +19,22 @@
let div: HTMLElement let div: HTMLElement
const render = (source: string): string => { function render(source: string): string {
if (!source || source == '') return '' if (!source || source == '') return ''
try { try {
return inline ? mdInline.render(source) : md.render(source) const output = inline ? mdInline.render(source) : md.render(source)
return output
} catch (err) { } catch (err) {
console.error(err)
return '' return ''
} }
} }
$: rendered = render(source) $: rendered = render(source)
$: replaceURLs(div, rendered) $: replaceURLs(div, rendered)
onMount(() => {
rendered = `${rendered} `
})
</script> </script>
<div <div
+11 -1
View File
@@ -1,5 +1,6 @@
// maybe fix circular dependency, hopefully. // maybe fix circular dependency, hopefully.
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
@@ -7,5 +8,14 @@ export const LINKED_INSTANCE_URL =
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true' (env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
? env.PUBLIC_INSTANCE_URL ? env.PUBLIC_INSTANCE_URL
: undefined : undefined
export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
const getDefaultInstance = (): string => {
if (browser) {
return env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
} else {
return env.PUBLIC_INTERNAL_INSTANCE || env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
}
}
export const DEFAULT_INSTANCE_URL = getDefaultInstance()
export let instance = writable(DEFAULT_INSTANCE_URL) export let instance = writable(DEFAULT_INSTANCE_URL)
+1 -1
View File
@@ -113,7 +113,7 @@ export const defaultSettings: Settings = {
debugInfo: false, debugInfo: false,
expandImages: true, expandImages: true,
view: 'cozy', view: 'cozy',
font: 'system', font: 'inter',
leftAlign: false, leftAlign: false,
hidePhoton: toBool(env.PUBLIC_REMOVE_CREDIT) ?? false, hidePhoton: toBool(env.PUBLIC_REMOVE_CREDIT) ?? false,
newWidth: true, newWidth: true,
+4 -6
View File
@@ -23,19 +23,17 @@
minimum: 0.4, minimum: 0.4,
trickleSpeed: 200, trickleSpeed: 200,
showSpinner: false, showSpinner: false,
easing: 'ease-out',
speed: 300,
}) })
$: { $: {
if (browser) {
if ($navigating) { if ($navigating) {
if (typeof document != 'undefined') {
nProgress.start() nProgress.start()
document?.documentElement?.classList?.toggle('wait', true)
}
} }
if (!$navigating) { if (!$navigating) {
if (typeof document != 'undefined') { nProgress.done()
nProgress.done(true)
document?.documentElement?.classList?.toggle('wait', false)
} }
} }
} }
+2 -10
View File
@@ -37,10 +37,7 @@
</div> </div>
</Modal> </Modal>
<div <div class="flex flex-col gap-4 max-w-full w-full min-w-0">
class="flex flex-row gap-4 w-full h-full xl:divide-x divide-slate-200 dark:divide-zinc-900"
>
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<header> <header>
<h1 <h1
class="text-3xl font-bold flex items-center w-full justify-between flex-wrap" class="text-3xl font-bold flex items-center w-full justify-between flex-wrap"
@@ -51,9 +48,7 @@
</span> </span>
</h1> </h1>
</header> </header>
<div <div class="flex flex-row gap-4 max-w-full justify-between w-full flex-wrap">
class="flex flex-row gap-4 max-w-full justify-between w-full flex-wrap"
>
<Select <Select
bind:value={data.listingType} bind:value={data.listingType}
on:change={() => on:change={() =>
@@ -82,9 +77,7 @@
</div> </div>
</div> </div>
</div> </div>
<section class="flex flex-col gap-3 sm:gap-4 h-full">
<PostFeed posts={data.posts.posts} /> <PostFeed posts={data.posts.posts} />
</section>
<div class="mt-auto"> <div class="mt-auto">
<Pageination <Pageination
page={data.page} page={data.page}
@@ -103,5 +96,4 @@
</span> </span>
</Pageination> </Pageination>
</div> </div>
</div>
</div> </div>