BLOG-73 Change website title dynamically #77
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">
|
<script lang="ts">
|
||||||
|
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||||
import Motto from '$lib/home/framework/ui/Motto.svelte';
|
import Motto from '$lib/home/framework/ui/Motto.svelte';
|
||||||
import Terminal from '$lib/home/framework/ui/Terminal.svelte';
|
import Terminal from '$lib/home/framework/ui/Terminal.svelte';
|
||||||
import TitleScreen from '$lib/home/framework/ui/TitleScreen.svelte';
|
import TitleScreen from '$lib/home/framework/ui/TitleScreen.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>{generateTitle()}</title>
|
||||||
|
</svelte:head>
|
||||||
<div>
|
<div>
|
||||||
<TitleScreen />
|
<TitleScreen />
|
||||||
<Terminal />
|
<Terminal />
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import { getContext, onMount } from 'svelte';
|
import { getContext, onMount } from 'svelte';
|
||||||
import markdownit from 'markdown-it';
|
import markdownit from 'markdown-it';
|
||||||
import SafeHtml from '$lib/common/framework/ui/SafeHtml.svelte';
|
import SafeHtml from '$lib/common/framework/ui/SafeHtml.svelte';
|
||||||
|
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||||
|
|
||||||
const { id }: { id: number } = $props();
|
const { id }: { id: number } = $props();
|
||||||
|
|
||||||
@ -16,6 +17,9 @@
|
|||||||
onMount(() => postBloc.dispatch({ event: PostEventType.PostLoadedEvent, id: id }));
|
onMount(() => postBloc.dispatch({ event: PostEventType.PostLoadedEvent, id: id }));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>{generateTitle(state.data?.info.title)}</title>
|
||||||
|
</svelte:head>
|
||||||
<article class="container prose pb-10">
|
<article class="container prose pb-10">
|
||||||
{#if state.data}
|
{#if state.data}
|
||||||
<PostContentHeader postInfo={state.data.info} />
|
<PostContentHeader postInfo={state.data.info} />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import generateTitle from '$lib/common/framework/ui/generateTitle';
|
||||||
import { PostListBloc, PostListEventType } from '$lib/post/adapter/presenter/postListBloc';
|
import { PostListBloc, PostListEventType } from '$lib/post/adapter/presenter/postListBloc';
|
||||||
import PostPreview from '$lib/post/framework/ui/PostPreview.svelte';
|
import PostPreview from '$lib/post/framework/ui/PostPreview.svelte';
|
||||||
import { getContext, onMount } from 'svelte';
|
import { getContext, onMount } from 'svelte';
|
||||||
@ -9,6 +10,9 @@
|
|||||||
onMount(() => postListBloc.dispatch({ event: PostListEventType.PostListLoadedEvent }));
|
onMount(() => postListBloc.dispatch({ event: PostListEventType.PostListLoadedEvent }));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>{generateTitle('文章')}</title>
|
||||||
|
</svelte:head>
|
||||||
<div class="container pb-10">
|
<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>
|
<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">
|
<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