BLOG-73 feat: change title dynamic
This commit is contained in:
parent
9ad3809f47
commit
5fcf50ec7b
6
frontend/src/lib/common/framework/ui/generateTitle.ts
Normal file
6
frontend/src/lib/common/framework/ui/generateTitle.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Strings } from '$lib/strings';
|
||||
|
||||
export default function generateTitle(pageTitle?: string): string {
|
||||
if (!pageTitle) return Strings.APP_NAME;
|
||||
return `${Strings.APP_NAME} - ${pageTitle}`;
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
<script lang="ts">
|
||||
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||
import Motto from '$lib/home/framework/ui/Motto.svelte';
|
||||
import Terminal from '$lib/home/framework/ui/Terminal.svelte';
|
||||
import TitleScreen from '$lib/home/framework/ui/TitleScreen.svelte';
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{generateTitle()}</title>
|
||||
</svelte:head>
|
||||
<div>
|
||||
<TitleScreen />
|
||||
<Terminal />
|
||||
|
@ -4,6 +4,7 @@
|
||||
import { getContext, onMount } from 'svelte';
|
||||
import markdownit from 'markdown-it';
|
||||
import SafeHtml from '$lib/common/framework/ui/SafeHtml.svelte';
|
||||
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||
|
||||
const { id }: { id: number } = $props();
|
||||
|
||||
@ -16,6 +17,9 @@
|
||||
onMount(() => postBloc.dispatch({ event: PostEventType.PostLoadedEvent, id: id }));
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{generateTitle(state.data?.info.title)}</title>
|
||||
</svelte:head>
|
||||
<article class="container prose pb-10">
|
||||
{#if state.data}
|
||||
<PostContentHeader postInfo={state.data.info} />
|
||||
|
@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||
import { PostListBloc, PostListEventType } from '$lib/post/adapter/presenter/postListBloc';
|
||||
import PostPreview from '$lib/post/framework/ui/PostPreview.svelte';
|
||||
import { getContext, onMount } from 'svelte';
|
||||
@ -9,6 +10,9 @@
|
||||
onMount(() => postListBloc.dispatch({ event: PostListEventType.PostListLoadedEvent }));
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{generateTitle('文章')}</title>
|
||||
</svelte:head>
|
||||
<div class="container pb-10">
|
||||
<h1 class="py-9 text-center text-3xl font-bold text-gray-800 md:py-20 md:text-5xl">文章</h1>
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-y-8 lg:grid-cols-3">
|
||||
|
3
frontend/src/lib/strings.ts
Normal file
3
frontend/src/lib/strings.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export abstract class Strings {
|
||||
static readonly APP_NAME = '魚之魷魂 SquidSpirit';
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user