|
1 | 1 | <template> |
2 | 2 | <div class="blog-container article-detail-page"> |
3 | | - <div class="article-detail-grid"> |
4 | | - <div class="article-detail-wrap"> |
5 | | - <div v-if="loading" class="article-detail-loading">加载中...</div> |
6 | | - |
7 | | - <template v-else> |
8 | | - <article v-if="article?.id" class="article-reader"> |
9 | | - <router-link class="article-back" to="/all"> |
10 | | - <span class="article-back-chev" aria-hidden="true">‹</span> |
11 | | - 返回博客 |
12 | | - </router-link> |
13 | | - |
14 | | - <p class="article-kicker-meta"> |
15 | | - <span>{{ formatDate(article.publishedAt) }}</span> |
| 3 | + <div class="article-detail-wrap"> |
| 4 | + <div v-if="loading" class="article-detail-loading">加载中...</div> |
| 5 | + |
| 6 | + <template v-else> |
| 7 | + <article v-if="article?.id" class="article-reader"> |
| 8 | + <router-link class="article-back" to="/all"> |
| 9 | + <span class="article-back-chev" aria-hidden="true">‹</span> |
| 10 | + 返回博客 |
| 11 | + </router-link> |
| 12 | + |
| 13 | + <p class="article-kicker-meta"> |
| 14 | + <span>{{ formatDate(article.publishedAt) }}</span> |
| 15 | + <span class="article-kicker-dot">·</span> |
| 16 | + <span>{{ readMinutes }} 分钟</span> |
| 17 | + <template v-if="categoryLabel"> |
16 | 18 | <span class="article-kicker-dot">·</span> |
17 | | - <span>{{ readMinutes }} 分钟</span> |
18 | | - <template v-if="categoryLabel"> |
19 | | - <span class="article-kicker-dot">·</span> |
20 | | - <span>{{ categoryLabel }}</span> |
21 | | - </template> |
22 | | - </p> |
| 19 | + <span>{{ categoryLabel }}</span> |
| 20 | + </template> |
| 21 | + </p> |
23 | 22 |
|
24 | | - <h1 class="article-reader-title">{{ article.title }}</h1> |
25 | | - <p v-if="article.summary" class="article-reader-lead">{{ article.summary }}</p> |
| 23 | + <h1 class="article-reader-title">{{ article.title }}</h1> |
| 24 | + <p v-if="article.summary" class="article-reader-lead">{{ article.summary }}</p> |
26 | 25 |
|
27 | | - <figure v-if="article.coverMediaKey" class="article-reader-cover"> |
28 | | - <img :src="coverUrl(article.coverMediaKey)" alt="" /> |
29 | | - </figure> |
| 26 | + <figure v-if="article.coverMediaKey" class="article-reader-cover"> |
| 27 | + <img :src="coverUrl(article.coverMediaKey)" alt="" /> |
| 28 | + </figure> |
30 | 29 |
|
31 | | - <div class="markdown-body article-markdown article-markdown--body" v-html="html" /> |
32 | | - </article> |
| 30 | + <div class="markdown-body article-markdown article-markdown--body" v-html="html" /> |
| 31 | + </article> |
33 | 32 |
|
34 | | - <div v-else class="article-detail-empty">文章不存在</div> |
| 33 | + <div v-else class="article-detail-empty">文章不存在</div> |
35 | 34 |
|
36 | | - <CommentSection v-if="article?.id" :article-id="article.id" /> |
37 | | - </template> |
38 | | - </div> |
39 | | - |
40 | | - <!-- 右侧:文章大纲(标题目录) --> |
41 | | - <aside v-if="tocItems.length" class="article-toc-rail" aria-label="文章大纲"> |
42 | | - <div class="article-toc-card"> |
43 | | - <div class="article-toc-title">大纲</div> |
44 | | - <nav class="article-toc-body" aria-label="大纲导航"> |
45 | | - <button |
46 | | - v-for="it in tocItems" |
47 | | - :key="it.id" |
48 | | - class="article-toc-item" |
49 | | - type="button" |
50 | | - :style="{ paddingLeft: `${10 + Math.max(0, it.level - 1) * 12}px` }" |
51 | | - @click="jumpToHeading(it.id)" |
52 | | - > |
53 | | - {{ it.text }} |
54 | | - </button> |
55 | | - </nav> |
56 | | - </div> |
57 | | - </aside> |
| 35 | + <CommentSection v-if="article?.id" :article-id="article.id" /> |
| 36 | + </template> |
58 | 37 | </div> |
| 38 | + |
| 39 | + <!-- 右侧:文章大纲(标题目录) --> |
| 40 | + <aside v-if="tocItems.length" class="article-toc-rail" aria-label="文章大纲"> |
| 41 | + <div class="article-toc-card"> |
| 42 | + <div class="article-toc-title">大纲</div> |
| 43 | + <nav class="article-toc-body" aria-label="大纲导航"> |
| 44 | + <button |
| 45 | + v-for="it in tocItems" |
| 46 | + :key="it.id" |
| 47 | + class="article-toc-item" |
| 48 | + type="button" |
| 49 | + :style="{ paddingLeft: `${10 + Math.max(0, it.level - 1) * 12}px` }" |
| 50 | + @click="jumpToHeading(it.id)" |
| 51 | + > |
| 52 | + {{ it.text }} |
| 53 | + </button> |
| 54 | + </nav> |
| 55 | + </div> |
| 56 | + </aside> |
59 | 57 | </div> |
60 | 58 | </template> |
61 | 59 |
|
|
0 commit comments