fix: ssr issues
This commit is contained in:
1 parent
e3c7aca8ee
commit
16154bbc23
9 files changed
+146
-146
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "photon-lemmy",
|
||||
"version": "1.18.2",
|
||||
"version": "1.19.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
: view == 'list'
|
||||
? 'py-5'
|
||||
: 'py-5'}"
|
||||
id={post.post.id}
|
||||
>
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
@@ -83,9 +84,7 @@
|
||||
<svelte:element
|
||||
this={$userSettings.expandImages ? 'div' : 'a'}
|
||||
href={postLink(post.post)}
|
||||
class="container mx-auto z-10 transition-colors {loaded
|
||||
? ''
|
||||
: 'bg-slate-200 dark:bg-zinc-800'} rounded-xl max-h-[60vh] relative overflow-hidden"
|
||||
class="container mx-auto z-10 transition-colors rounded-xl max-h-[60vh] relative overflow-hidden"
|
||||
data-sveltekit-preload-data="off"
|
||||
aria-label={post.post.name}
|
||||
>
|
||||
@@ -126,8 +125,7 @@
|
||||
src={bestImageURL(post.post, false, 1024)}
|
||||
loading="lazy"
|
||||
class="max-h-[inherit] max-w-full h-auto z-30
|
||||
opacity-0 transition-opacity duration-300 object-contain mx-auto"
|
||||
class:opacity-100={loaded}
|
||||
transition-opacity duration-300 object-contain mx-auto"
|
||||
width={512}
|
||||
height={300}
|
||||
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
||||
@@ -168,7 +166,7 @@
|
||||
dark:from-zinc-400 dark:via-zinc-400 bg-clip-text
|
||||
{view == 'list' ? `max-h-24` : 'max-h-48'}"
|
||||
>
|
||||
<Markdown inline source={post.post.body.slice(0, 500)} />
|
||||
<Markdown inline source={post.post.body} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
export let community: boolean = false
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex flex-col {$userSettings.view == 'card'
|
||||
<ul
|
||||
class="flex flex-col list-none {$userSettings.view == 'card'
|
||||
? 'gap-3 md:gap-4'
|
||||
: ''} divide-slate-200 dark:divide-zinc-800"
|
||||
class:divide-y={$userSettings.view != 'card'}
|
||||
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#if posts.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
@@ -31,9 +30,9 @@
|
||||
</Placeholder>
|
||||
</div>
|
||||
{: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)}
|
||||
<div
|
||||
<li
|
||||
in:fly|global={{
|
||||
y: -8,
|
||||
duration: 500,
|
||||
@@ -42,8 +41,8 @@
|
||||
}}
|
||||
>
|
||||
<Post hideCommunity={community} view={$userSettings.view} bind:post />
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</ul>
|
||||
@@ -39,63 +39,60 @@
|
||||
</script>
|
||||
|
||||
<slot {vote} {score}>
|
||||
<Popover openOnHover placement="bottom">
|
||||
<div
|
||||
class=" flex items-center text-sm gap-1 rounded-md border border-slate-200
|
||||
<!-- <Popover openOnHover placement="bottom"> -->
|
||||
<div
|
||||
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"
|
||||
slot="target"
|
||||
>
|
||||
<Button
|
||||
aria-label="Upvote"
|
||||
class={vote == 1
|
||||
? voteColor(vote)
|
||||
: 'hover:dark:text-blue-600 hover:text-blue-500'}
|
||||
on:click={async () => castVote(vote == 1 ? 0 : 1)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
alignment="center"
|
||||
>
|
||||
<Button
|
||||
aria-label="Upvote"
|
||||
class={vote == 1
|
||||
? voteColor(vote)
|
||||
: 'hover:dark:text-blue-600 hover:text-blue-500'}
|
||||
on:click={async () => castVote(vote == 1 ? 0 : 1)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
alignment="center"
|
||||
>
|
||||
<Icon src={ChevronUp} mini size="18" />
|
||||
</Button>
|
||||
<span
|
||||
class="font-medium transition-colors duration-200 grid {voteColor(
|
||||
vote
|
||||
)}"
|
||||
class:hidden={$profile?.user?.local_user_view.local_user.show_scores ==
|
||||
false}
|
||||
>
|
||||
{#key score}
|
||||
<span
|
||||
in:fly={{ y: score > oldScore ? 4 : -4, duration: 200 }}
|
||||
out:fly={{ y: score > oldScore ? -4 : 4, duration: 200 }}
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
>
|
||||
<FormattedNumber number={score} />
|
||||
</span>
|
||||
{/key}
|
||||
</span>
|
||||
<Button
|
||||
aria-label="Downvote"
|
||||
class="{vote == -1 ? voteColor(vote) : ''} {$site?.site_view.local_site
|
||||
.enable_downvotes
|
||||
? 'hover:dark:text-red-600 hover:text-red-500'
|
||||
: 'pointer-events-none opacity-50'}"
|
||||
on:click={async () => castVote(vote == -1 ? 0 : -1)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
>
|
||||
<Icon src={ChevronDown} mini size="18" />
|
||||
</Button>
|
||||
<Icon src={ChevronUp} mini size="18" />
|
||||
</Button>
|
||||
<span
|
||||
class="font-medium transition-colors duration-200 grid {voteColor(vote)}"
|
||||
class:hidden={$profile?.user?.local_user_view.local_user.show_scores ==
|
||||
false}
|
||||
>
|
||||
{#key score}
|
||||
<span
|
||||
in:fly={{ y: score > oldScore ? 4 : -4, duration: 200 }}
|
||||
out:fly={{ y: score > oldScore ? -4 : 4, duration: 200 }}
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
>
|
||||
<FormattedNumber number={score} />
|
||||
</span>
|
||||
{/key}
|
||||
</span>
|
||||
<Button
|
||||
aria-label="Downvote"
|
||||
class="{vote == -1 ? voteColor(vote) : ''} {$site?.site_view.local_site
|
||||
.enable_downvotes
|
||||
? 'hover:dark:text-red-600 hover:text-red-500'
|
||||
: 'pointer-events-none opacity-50'}"
|
||||
on:click={async () => castVote(vote == -1 ? 0 : -1)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
>
|
||||
<Icon src={ChevronDown} mini size="18" />
|
||||
</Button>
|
||||
</div>
|
||||
<!-- <div class="flex items-center gap-2">
|
||||
<div class="flex items-center font-medium text-blue-500 gap-0.5">
|
||||
<Icon src={ArrowUp} mini size="18" title="Upvotes" />
|
||||
{upvotes}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex items-center font-medium text-blue-500 gap-0.5">
|
||||
<Icon src={ArrowUp} mini size="18" title="Upvotes" />
|
||||
{upvotes}
|
||||
</div>
|
||||
<div class="flex items-center font-medium text-red-500 gap-0.5">
|
||||
<Icon src={ArrowDown} mini size="18" title="Downvotes" />
|
||||
{downvotes}
|
||||
</div>
|
||||
<div class="flex items-center font-medium text-red-500 gap-0.5">
|
||||
<Icon src={ArrowDown} mini size="18" title="Downvotes" />
|
||||
{downvotes}
|
||||
</div>
|
||||
</Popover>
|
||||
</div> -->
|
||||
<!-- </Popover> -->
|
||||
</slot>
|
||||
@@ -1,10 +1,12 @@
|
||||
<script lang="ts">
|
||||
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 inline: boolean = false
|
||||
|
||||
let rendered = ''
|
||||
|
||||
function replaceURLs(node: HTMLElement, source: string) {
|
||||
if (!div) return
|
||||
const links = node.querySelectorAll('a')
|
||||
@@ -17,18 +19,22 @@
|
||||
|
||||
let div: HTMLElement
|
||||
|
||||
const render = (source: string): string => {
|
||||
function render(source: string): string {
|
||||
if (!source || source == '') return ''
|
||||
|
||||
try {
|
||||
return inline ? mdInline.render(source) : md.render(source)
|
||||
const output = inline ? mdInline.render(source) : md.render(source)
|
||||
return output
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
$: rendered = render(source)
|
||||
$: replaceURLs(div, rendered)
|
||||
onMount(() => {
|
||||
rendered = `${rendered} `
|
||||
})
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
+11
-1
@@ -1,5 +1,6 @@
|
||||
// maybe fix circular dependency, hopefully.
|
||||
|
||||
import { browser } from '$app/environment'
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
@@ -7,5 +8,14 @@ export const LINKED_INSTANCE_URL =
|
||||
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
|
||||
? env.PUBLIC_INSTANCE_URL
|
||||
: 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)
|
||||
+1
-1
@@ -113,7 +113,7 @@ export const defaultSettings: Settings = {
|
||||
debugInfo: false,
|
||||
expandImages: true,
|
||||
view: 'cozy',
|
||||
font: 'system',
|
||||
font: 'inter',
|
||||
leftAlign: false,
|
||||
hidePhoton: toBool(env.PUBLIC_REMOVE_CREDIT) ?? false,
|
||||
newWidth: true,
|
||||
|
||||
@@ -23,19 +23,17 @@
|
||||
minimum: 0.4,
|
||||
trickleSpeed: 200,
|
||||
showSpinner: false,
|
||||
easing: 'ease-out',
|
||||
speed: 300,
|
||||
})
|
||||
|
||||
$: {
|
||||
if ($navigating) {
|
||||
if (typeof document != 'undefined') {
|
||||
if (browser) {
|
||||
if ($navigating) {
|
||||
nProgress.start()
|
||||
document?.documentElement?.classList?.toggle('wait', true)
|
||||
}
|
||||
}
|
||||
if (!$navigating) {
|
||||
if (typeof document != 'undefined') {
|
||||
nProgress.done(true)
|
||||
document?.documentElement?.classList?.toggle('wait', false)
|
||||
if (!$navigating) {
|
||||
nProgress.done()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+54
-62
@@ -37,71 +37,63 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<div
|
||||
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>
|
||||
<h1
|
||||
class="text-3xl font-bold flex items-center w-full justify-between flex-wrap"
|
||||
>
|
||||
Frontpage
|
||||
<span class="xl:hidden">
|
||||
<Button on:click={() => (sidebar = !sidebar)}>About</Button>
|
||||
</span>
|
||||
</h1>
|
||||
</header>
|
||||
<div
|
||||
class="flex flex-row gap-4 max-w-full justify-between w-full flex-wrap"
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
<header>
|
||||
<h1
|
||||
class="text-3xl font-bold flex items-center w-full justify-between flex-wrap"
|
||||
>
|
||||
<Select
|
||||
bind:value={data.listingType}
|
||||
on:change={() =>
|
||||
searchParam($page.url, 'type', data.listingType, 'page', 'cursor')}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={GlobeAmericas} size="16" mini />
|
||||
Location
|
||||
</span>
|
||||
<option value="All">All</option>
|
||||
<option value="Local">Local</option>
|
||||
<option value="Subscribed" disabled={!$profile?.jwt}>Subscribed</option>
|
||||
{#if feature('moderatorView', $site?.version)}
|
||||
<option
|
||||
value="ModeratorView"
|
||||
disabled={!$profile?.jwt || !amModOfAny($profile?.user)}
|
||||
>
|
||||
Moderator
|
||||
</option>
|
||||
{/if}
|
||||
</Select>
|
||||
<div class="flex gap-4 flex-wrap">
|
||||
<Sort selected={data.sort} />
|
||||
<div class="max-[420px]:hidden">
|
||||
<ViewSelect />
|
||||
</div>
|
||||
Frontpage
|
||||
<span class="xl:hidden">
|
||||
<Button on:click={() => (sidebar = !sidebar)}>About</Button>
|
||||
</span>
|
||||
</h1>
|
||||
</header>
|
||||
<div class="flex flex-row gap-4 max-w-full justify-between w-full flex-wrap">
|
||||
<Select
|
||||
bind:value={data.listingType}
|
||||
on:change={() =>
|
||||
searchParam($page.url, 'type', data.listingType, 'page', 'cursor')}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={GlobeAmericas} size="16" mini />
|
||||
Location
|
||||
</span>
|
||||
<option value="All">All</option>
|
||||
<option value="Local">Local</option>
|
||||
<option value="Subscribed" disabled={!$profile?.jwt}>Subscribed</option>
|
||||
{#if feature('moderatorView', $site?.version)}
|
||||
<option
|
||||
value="ModeratorView"
|
||||
disabled={!$profile?.jwt || !amModOfAny($profile?.user)}
|
||||
>
|
||||
Moderator
|
||||
</option>
|
||||
{/if}
|
||||
</Select>
|
||||
<div class="flex gap-4 flex-wrap">
|
||||
<Sort selected={data.sort} />
|
||||
<div class="max-[420px]:hidden">
|
||||
<ViewSelect />
|
||||
</div>
|
||||
</div>
|
||||
<section class="flex flex-col gap-3 sm:gap-4 h-full">
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
</section>
|
||||
<div class="mt-auto">
|
||||
<Pageination
|
||||
page={data.page}
|
||||
cursor={{ next: data.cursor.next, back: data.cursor.back }}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
on:cursor={(c) => {
|
||||
searchParam($page.url, 'cursor', c.detail)
|
||||
}}
|
||||
>
|
||||
<span class="flex flex-row items-center gap-1">
|
||||
<Icon src={ChartBar} size="16" mini />
|
||||
<span class="font-medium text-black dark:text-white">
|
||||
{$site?.site_view.counts.users_active_day}
|
||||
</span>
|
||||
<span class="font-normal">Active users</span>
|
||||
</div>
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
<div class="mt-auto">
|
||||
<Pageination
|
||||
page={data.page}
|
||||
cursor={{ next: data.cursor.next, back: data.cursor.back }}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
on:cursor={(c) => {
|
||||
searchParam($page.url, 'cursor', c.detail)
|
||||
}}
|
||||
>
|
||||
<span class="flex flex-row items-center gap-1">
|
||||
<Icon src={ChartBar} size="16" mini />
|
||||
<span class="font-medium text-black dark:text-white">
|
||||
{$site?.site_view.counts.users_active_day}
|
||||
</span>
|
||||
</Pageination>
|
||||
</div>
|
||||
<span class="font-normal">Active users</span>
|
||||
</span>
|
||||
</Pageination>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user