merge with upsteam 2ef763fc34

This commit is contained in:
sevichecc 2023-01-26 00:15:28 +08:00
parent 3bb83c69db
commit 2495dc7278
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000
6 changed files with 22 additions and 18 deletions

10
src/app.d.ts vendored
View file

@ -1,6 +1,6 @@
/// <reference types="@sveltejs/kit" /> /// <reference types="@sveltejs/kit" />
import { FFFBase, FFFExtra } from 'fff-flavored-frontmatter' import type { FFFBase, FFFMention } from 'fff-flavored-frontmatter'
interface ImportMetaEnv extends Readonly<Record<string, string>> { interface ImportMetaEnv extends Readonly<Record<string, string>> {
readonly URARA_SITE_PROTOCOL?: 'http://' | 'https://' readonly URARA_SITE_PROTOCOL?: 'http://' | 'https://'
@ -15,8 +15,8 @@ interface ImportMeta {
declare global { declare global {
namespace Urara { namespace Urara {
namespace Post { namespace Post {
type Frontmatter = Omit<FFFBase, 'created' | 'updated' | 'image' | 'audio' | 'video' | 'flags'> & type Frontmatter = Omit<FFFBase, 'flags'> &
Pick<FFFExtra, 'in_reply_to'> & { Pick<FFFMention, 'in_reply_to'> & {
/** /**
* post type. * post type.
* @remarks auto-generated * @remarks auto-generated
@ -51,6 +51,10 @@ declare global {
* @remarks auto-generated or set manually * @remarks auto-generated or set manually
*/ */
updated: string updated: string
/**
* the published date of the post.
*/
published?: string
/** /**
* the featured image for article, or image for "photo" / "multi-photo" posts. * the featured image for article, or image for "photo" / "multi-photo" posts.
* @remarks currently only supports string * @remarks currently only supports string

View file

@ -1,15 +1,15 @@
<script lang="ts"> <script lang="ts">
export let id: string export let id: string
export let list: boolean = undefined export let list: boolean | undefined = undefined
export let playlist: string = undefined export let playlist: string | undefined = undefined
export let start: string = undefined export let start: string | undefined = undefined
export let autoplay: boolean = false export let autoplay: boolean = false
export let disablekb: boolean = false export let disablekb: boolean = false
export let controls: boolean = true export let controls: boolean = true
export let fs = true export let fs = true
export let loop = false export let loop = false
const src = `https://www.youtube.com/embed/${id}?${new URLSearchParams({ const src = `https://www.youtube.com/embed/${id}?${new URLSearchParams({
...(list ? { listType: 'playlist', list } : {}), ...(list ? { listType: 'playlist', list: 'true' } : {}),
...(playlist ? { playlist } : {}), ...(playlist ? { playlist } : {}),
...(start ? { start } : {}), ...(start ? { start } : {}),
autoplay: autoplay ? '1' : '0', autoplay: autoplay ? '1' : '0',
@ -29,4 +29,4 @@
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
loading="lazy" loading="lazy"
allowfullscreen /> allowfullscreen />
</div> </div>

View file

@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
export let post: Urara.Post export let post: Urara.Post
const actions = import.meta.glob<{ default: unknown }>('/src/lib/components/actions/*.svelte', { eager: true }) const actions = import.meta.glob<any>('/src/lib/components/actions/*.svelte', { eager: true, import: 'default' })
</script> </script>
<div class="sticky top-24 hidden xl:flex flex-col gap-4 w-fit h-[calc(100vh-12rem)] ml-auto mr-8 my-8 justify-center"> <div class="sticky top-24 hidden xl:flex flex-col gap-4 w-fit h-[calc(100vh-12rem)] ml-auto mr-8 my-8 justify-center">
{#if Object.keys(actions).length} {#if Object.keys(actions).length}
{#each Object.values(actions) as action} {#each Object.values(actions) as action}
<svelte:component this={action.default} {post} /> <svelte:component this={action} {post} />
{/each} {/each}
{/if} {/if}
</div> </div>

View file

@ -3,7 +3,7 @@
import { toSnake } from '$lib/utils/case' import { toSnake } from '$lib/utils/case'
export let post: Urara.Post export let post: Urara.Post
export let config: CommentConfig export let config: CommentConfig
const comments = import.meta.glob<{ default: unknown }>('/src/lib/components/comments/*.svelte', { eager: true }) const comments = import.meta.glob<any>('/src/lib/components/comments/*.svelte', { eager: true, import: 'default' })
let currentComment: string | undefined = undefined let currentComment: string | undefined = undefined
let currentConfig: unknown | undefined = undefined let currentConfig: unknown | undefined = undefined
currentComment = localStorage.getItem('comment') ?? toSnake(config.use[0]) currentComment = localStorage.getItem('comment') ?? toSnake(config.use[0])
@ -16,6 +16,7 @@
{#if config.use.length > 1} {#if config.use.length > 1}
<div class="tabs w-full mb-8" class:tabs-boxed={config?.['style'] === 'boxed'}> <div class="tabs w-full mb-8" class:tabs-boxed={config?.['style'] === 'boxed'}>
{#each config.use as name} {#each config.use as name}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<span <span
on:click={() => { on:click={() => {
currentComment = toSnake(name) currentComment = toSnake(name)
@ -33,10 +34,10 @@
{#if currentComment} {#if currentComment}
{#key currentComment} {#key currentComment}
<svelte:component <svelte:component
this={comments[`/src/lib/components/comments/${currentComment}.svelte`].default} this={comments[`/src/lib/components/comments/${currentComment}.svelte`]}
{post} {post}
config={currentConfig} /> config={currentConfig} />
{/key} {/key}
{/if} {/if}
</div> </div>
{/if} {/if}

View file

@ -7,7 +7,6 @@
<nav class="flex flex-col md:flex-row flex-warp justify-evenly"> <nav class="flex flex-col md:flex-row flex-warp justify-evenly">
{#if prev} {#if prev}
<div <div
href={prev.path}
class:image-full={prev['image']} class:image-full={prev['image']}
class:md:rounded-r-box={next && !next['image']} class:md:rounded-r-box={next && !next['image']}
class="flex-1 card group rounded-none before:!rounded-none overflow-hidden"> class="flex-1 card group rounded-none before:!rounded-none overflow-hidden">
@ -34,7 +33,6 @@
{/if} {/if}
{#if next} {#if next}
<div <div
href={next.path}
class:image-full={next['image']} class:image-full={next['image']}
class:md:rounded-l-box={prev && !prev['image']} class:md:rounded-l-box={prev && !prev['image']}
class="flex-1 card group rounded-none before:!rounded-none overflow-hidden"> class="flex-1 card group rounded-none before:!rounded-none overflow-hidden">
@ -56,4 +54,4 @@
</div> </div>
</div> </div>
{/if} {/if}
</nav> </nav>

View file

@ -55,6 +55,7 @@
<ul dir="ltr" id="toc-list-root"> <ul dir="ltr" id="toc-list-root">
{#each toc as { depth, title, slug }} {#each toc as { depth, title, slug }}
<li id={`toc-item-${slug}`} class="flex flex-col"> <li id={`toc-item-${slug}`} class="flex flex-col">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<span <span
dir="ltr" dir="ltr"
on:click={() => on:click={() =>
@ -76,4 +77,4 @@
{/each} {/each}
</ul> </ul>
</nav> </nav>
</aside> </aside>