|
3 | 3 | import type { PageData } from "./$types"; |
4 | 4 |
|
5 | 5 | const { data }: { data: PageData } = $props(); |
6 | | - const { article, relatedArticles } = data; |
| 6 | + |
7 | 7 | </script> |
8 | 8 |
|
9 | 9 | <svelte:head> |
10 | | - {#if article} |
11 | | - <title>{article.title} | ut.code();</title> |
12 | | - <meta property="og:title" content={article.title} /> |
13 | | - {#if article.excerpt} |
14 | | - <meta name="description" content={article.excerpt} /> |
15 | | - <meta property="og:description" content={article.excerpt} /> |
| 10 | + {#if data.article} |
| 11 | + <title>{data.article.title} | ut.code();</title> |
| 12 | + <meta property="og:title" content={data.article.title} /> |
| 13 | + {#if data.article.excerpt} |
| 14 | + <meta name="description" content={data.article.excerpt} /> |
| 15 | + <meta property="og:description" content={data.article.excerpt} /> |
16 | 16 | {/if} |
17 | | - {#if article.coverUrl} |
18 | | - <meta property="og:image" content={article.coverUrl} /> |
| 17 | + {#if data.article.coverUrl} |
| 18 | + <meta property="og:image" content={data.article.coverUrl} /> |
19 | 19 | {/if} |
20 | 20 | <meta property="og:type" content="article" /> |
21 | 21 | {/if} |
22 | 22 | </svelte:head> |
23 | 23 |
|
24 | | -{#if article} |
| 24 | +{#if data.article} |
25 | 25 | <article class="mx-auto max-w-3xl px-6 py-16"> |
26 | 26 | <a |
27 | 27 | href="/articles" |
|
30 | 30 | ← 記事一覧 |
31 | 31 | </a> |
32 | 32 |
|
33 | | - {#if article.coverUrl} |
| 33 | + {#if data.article.coverUrl} |
34 | 34 | <img |
35 | | - src={article.coverUrl} |
36 | | - alt={article.title} |
| 35 | + src={data.article.coverUrl} |
| 36 | + alt={data.article.title} |
37 | 37 | class="mb-6 aspect-[5/3] w-full rounded-xl object-cover sm:mb-8" |
38 | 38 | loading="lazy" |
39 | 39 | /> |
40 | 40 | {/if} |
41 | 41 |
|
42 | | - <h1 class="mb-3 text-2xl font-bold sm:mb-4 sm:text-3xl md:text-4xl">{article.title}</h1> |
| 42 | + <h1 class="mb-3 text-2xl font-bold sm:mb-4 sm:text-3xl md:text-4xl">{data.article.title}</h1> |
43 | 43 |
|
44 | 44 | <div class="mb-6 flex flex-wrap items-center gap-3 text-sm text-zinc-500 sm:mb-8 sm:gap-4"> |
45 | | - {#if article.author} |
| 45 | + {#if data.article.author} |
46 | 46 | <a |
47 | | - href="/members/{article.author.slug}" |
| 47 | + href="/members/{data.article.author.slug}" |
48 | 48 | class="flex items-center gap-2 hover:text-zinc-900" |
49 | 49 | > |
50 | | - {#if article.author.imageUrl} |
| 50 | + {#if data.article.author.imageUrl} |
51 | 51 | <img |
52 | | - src={article.author.imageUrl} |
53 | | - alt={article.author.name} |
| 52 | + src={data.article.author.imageUrl} |
| 53 | + alt={data.article.author.name} |
54 | 54 | class="aspect-square h-6 w-6 rounded-full object-cover" |
55 | 55 | loading="lazy" |
56 | 56 | /> |
57 | 57 | {/if} |
58 | | - {article.author.name} |
| 58 | + {data.article.author.name} |
59 | 59 | </a> |
60 | 60 | {/if} |
61 | | - {#if article.publishedAt} |
62 | | - <time datetime={article.publishedAt.toISOString()}> |
63 | | - {article.publishedAt.toLocaleDateString("ja-JP")} |
| 61 | + {#if data.article.publishedAt} |
| 62 | + <time datetime={data.article.publishedAt.toISOString()}> |
| 63 | + {data.article.publishedAt.toLocaleDateString("ja-JP")} |
64 | 64 | </time> |
65 | 65 | {/if} |
66 | 66 | </div> |
67 | 67 |
|
68 | | - <Markdown content={article.content} /> |
| 68 | + <Markdown content={data.article.content} /> |
69 | 69 | </article> |
70 | 70 |
|
71 | | - {#if relatedArticles.length > 0} |
| 71 | + {#if data.relatedArticles.length > 0} |
72 | 72 | <section class="mx-auto max-w-3xl px-6 pb-16"> |
73 | 73 | <div class="border-t border-zinc-200 pt-8 sm:pt-12"> |
74 | 74 | <h2 class="mb-4 text-xl font-bold sm:mb-6 sm:text-2xl">関連記事</h2> |
75 | 75 | <div class="grid gap-4 sm:gap-6 md:grid-cols-2 lg:grid-cols-3"> |
76 | | - {#each relatedArticles as relatedArticle (relatedArticle.id)} |
| 76 | + {#each data.relatedArticles as relatedArticle (relatedArticle.id)} |
77 | 77 | <a |
78 | 78 | href="/articles/{relatedArticle.slug}" |
79 | 79 | class="group rounded-xl border border-zinc-200/50 bg-white/80 backdrop-blur-md p-4 transition-all hover:bg-primary/5 hover:border-primary/30 hover:shadow-md" |
|
0 commit comments