@velonor/theme 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @velonor/theme
2
+
3
+ A Simple & Beautiful Blog Theme, based on @velonor/engine
4
+
5
+ ## Migration
6
+
7
+ If you were using `@velonor/theme`, it is now deprecated. Please migrate to `@velonor/theme`.
8
+
9
+
10
+ [More information](https://vitepress.open17.vip)
11
+
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "type": "module",
3
+ "types": "./src/types/index.d.ts",
4
+ "typesVersions": {
5
+ "*": {
6
+ "config": [
7
+ "src/types/theme.d.ts"
8
+ ]
9
+ }
10
+ },
11
+ "version": "1.0.0",
12
+ "exports": {
13
+ ".": "./src/index.ts",
14
+ "./genFeed": "./src/genFeed.mjs",
15
+ "./config": "./src/types/theme.d.ts"
16
+ },
17
+ "main": "./src/index.ts",
18
+ "license": "Apache-2.0",
19
+ "author": "velonor <opensci@163.com>",
20
+ "name": "@velonor/theme",
21
+ "homepage": "https://vitepress.open17.vip",
22
+ "files": [
23
+ "src",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/open17/velonor.git"
30
+ },
31
+ "peerDependencies": {
32
+ "@giscus/vue": "^3.0.0",
33
+ "vitepress": "^1.0.1",
34
+ "unocss": "^66.0.0",
35
+ "@unocss/vite": "^66.0.0"
36
+ },
37
+ "keywords": [
38
+ "vitepress",
39
+ "vitepress theme",
40
+ "vitepress-theme",
41
+ "vitepress-blog",
42
+ "vitepress blog"
43
+ ],
44
+ "dependencies": {
45
+ "feed": "^4.2.2",
46
+ "@velonor/engine": "^0.1.0"
47
+ },
48
+ "devDependencies": {
49
+ "@eslint/js": "^9.14.0",
50
+ "@types/node": "^22.9.0",
51
+ "@typescript-eslint/eslint-plugin": "^8.13.0",
52
+ "@typescript-eslint/parser": "^8.13.0",
53
+ "eslint": "^9.14.0",
54
+ "eslint-config-prettier": "^9.1.0",
55
+ "eslint-plugin-prettier": "^5.2.1",
56
+ "eslint-plugin-vue": "^9.30.0",
57
+ "globals": "^15.12.0",
58
+ "prettier": "^3.3.3",
59
+ "typescript": "^5.6.3",
60
+ "typescript-eslint": "^8.13.0"
61
+ },
62
+ "scripts": {
63
+ "lint": "eslint src --fix",
64
+ "format": "prettier --write src"
65
+ }
66
+ }
67
+
@@ -0,0 +1,4 @@
1
+ import { createArchiveLoader } from '@velonor/engine/loader';
2
+
3
+ export default createArchiveLoader('posts/**/*.md');
4
+
@@ -0,0 +1,4 @@
1
+ import { createCategoriesLoader } from '@velonor/engine/loader';
2
+
3
+ export default createCategoriesLoader('posts/**/*.md');
4
+
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <ThemeLayout>
3
+ <div
4
+ class="flex w-full flex-col bg-opacity-90 backdrop-blur-md dark:shadow-none shadow-lg border-2 border-[var(--blog-border-c)] bg-[var(--vp-c-blog-bg)] rounded-2xl py-10 px-6 md:px-10 gap-8">
5
+ <div class="flex flex-col md:flex-row md:items-end md:justify-between gap-4">
6
+ <div class="flex flex-col gap-2">
7
+ <div class="text-3xl md:text-4xl font-bold tracking-tight">{{ archiveTitle }}</div>
8
+ <div class="text-sm opacity-70">
9
+ {{ totalPosts }} {{ postsText }} · {{ yearGroups.length }} {{ yearsText }}
10
+ </div>
11
+ </div>
12
+ <div class="flex items-center gap-2 text-xs">
13
+ <a v-if="blogHomeLink" :href="withBase(blogHomeLink)"
14
+ class="px-3 py-1 rounded-full border border-[var(--blog-border-c)]/70 bg-[var(--vp-c-bg)]/40 hover:bg-[var(--vp-c-bg)]/60 transition">
15
+ {{ backToBlogText }}
16
+ </a>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="flex flex-col gap-10">
21
+ <div
22
+ v-for="yearGroup in yearGroups"
23
+ :key="yearGroup.year"
24
+ class="rounded-2xl border border-[var(--blog-border-c)]/70 bg-[var(--vp-c-bg)]/30 px-5 md:px-7 py-6">
25
+ <div class="flex items-center justify-between mb-5">
26
+ <div class="text-2xl font-bold tracking-tight flex items-center gap-3">
27
+ <span class="w-1.5 h-6 rounded-full bg-[var(--vp-c-brand-2)]"></span>
28
+ {{ yearGroup.year }}
29
+ </div>
30
+ <div class="text-xs opacity-70">
31
+ {{ yearGroup.total }} {{ postsText }} · {{ yearGroup.months.length }} {{ monthsText }}
32
+ </div>
33
+ </div>
34
+
35
+ <div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
36
+ <details
37
+ v-for="monthGroup in yearGroup.months"
38
+ :key="`${yearGroup.year}-${monthGroup.month}`"
39
+ class="group rounded-xl border border-dashed border-[var(--blog-border-c)]/60 bg-[var(--vp-c-bg)]/40 p-4 transition hover:-translate-y-0.5 hover:shadow-lg hover:border-solid">
40
+ <summary class="list-none cursor-pointer">
41
+ <div class="flex items-center justify-between">
42
+ <div class="flex items-center gap-2 text-base font-semibold">
43
+ <span>{{ monthGroup.monthName }}</span>
44
+ <span class="text-xs px-2 py-0.5 rounded-full border border-[var(--blog-border-c)]/70 opacity-70">
45
+ {{ monthGroup.posts.length }}
46
+ </span>
47
+ </div>
48
+ <span class="text-xs opacity-60 group-open:rotate-180 transition">⌄</span>
49
+ </div>
50
+ <div class="mt-3 flex flex-col gap-1 text-sm opacity-80">
51
+ <div v-for="post in monthGroup.posts.slice(0, 3)" :key="post.url" class="truncate">
52
+ {{ post.frontmatter.title }}
53
+ </div>
54
+ <div v-if="monthGroup.posts.length > 3" class="text-xs opacity-60">
55
+ +{{ monthGroup.posts.length - 3 }} more
56
+ </div>
57
+ </div>
58
+ </summary>
59
+
60
+ <div class="mt-4 pt-3 border-t border-dashed border-[var(--blog-border-c)]/70">
61
+ <div
62
+ class="px-3 py-2 flex justify-between w-full rounded-lg flex-col md:flex-row gap-1 border border-transparent hover:border-[var(--blog-border-c)] hover:bg-[var(--blog-time-line-text-bg)]/60 hover:text-[var(--blog-time-line-text)] transition"
63
+ v-for="post in monthGroup.posts"
64
+ :key="post.url">
65
+ <a class="text-sm font-medium" :href="withBase(post.url)">
66
+ {{ post.frontmatter.title }}
67
+ </a>
68
+ <div class="text-xs opacity-75 transition duration-150 ease-in-out">
69
+ {{ formatMonthDay(post.frontmatter.date) }}
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </details>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </ThemeLayout>
79
+ </template>
80
+
81
+ <script setup lang="ts">
82
+ import { data as archiveIndex } from '../archive.data';
83
+ import { withBase, useData } from 'vitepress';
84
+ import ThemeLayout from './ThemeLayout.vue';
85
+ import { type BlogPost, getLocalizedString } from '@velonor/engine';
86
+ import { computed } from 'vue';
87
+ import { data as pageLinks } from '../page-links.data';
88
+
89
+ interface MonthGroup {
90
+ month: number;
91
+ monthName: string;
92
+ posts: BlogPost[];
93
+ }
94
+
95
+ interface YearGroup {
96
+ year: number;
97
+ months: MonthGroup[];
98
+ total: number;
99
+ }
100
+
101
+ const yearGroups = computed(() => (archiveIndex.yearGroups || []) as YearGroup[]);
102
+ const totalPosts = computed(() => archiveIndex.totalPosts ?? 0);
103
+
104
+ const { lang, theme } = useData();
105
+ const blogHomeLink = computed(() => theme.value.blog?.homePageLink || pageLinks?.blog || '/page/blog');
106
+ const backToBlogText = computed(() => getLocalizedString('backToBlog', lang.value));
107
+ const archiveTitle = computed(() => (lang.value || '').startsWith('zh') ? '归档' : 'Archive');
108
+ const postsText = computed(() => (lang.value || '').startsWith('zh') ? '文章' : 'Posts');
109
+ const yearsText = computed(() => (lang.value || '').startsWith('zh') ? '年份' : 'Years');
110
+ const monthsText = computed(() => (lang.value || '').startsWith('zh') ? '月份' : 'Months');
111
+
112
+ const formatMonthDay = (value: unknown) => {
113
+ if (!value) return '';
114
+ const date = new Date(value as any);
115
+ if (Number.isNaN(date.getTime())) return String(value).slice(5, 10);
116
+ const month = String(date.getMonth() + 1).padStart(2, '0');
117
+ const day = String(date.getDate()).padStart(2, '0');
118
+ return `${month}-${day}`;
119
+ };
120
+ </script>
121
+
@@ -0,0 +1,232 @@
1
+ <script setup>
2
+ import { useData, withBase } from 'vitepress';
3
+ import { computed, watch } from 'vue';
4
+ import ThemeLayout from './ThemeLayout.vue';
5
+ import {
6
+ DEFAULT_PAGE_SIZE,
7
+ DEFAULT_PAGE_GROUP_SIZE,
8
+ getLocalizedString,
9
+ usePagination,
10
+ formatDate,
11
+ } from '@velonor/engine/client';
12
+ import { useTagFilter } from '../composables/useTagFilter';
13
+ import { useCategories } from '../composables/useCategories';
14
+
15
+ const { theme, lang } = useData();
16
+ const blogConfig = computed(() => theme.value.blog || {});
17
+
18
+ const pageSize = computed(
19
+ () => blogConfig.value.pageSize || theme.value.home?.postsPerPage || DEFAULT_PAGE_SIZE
20
+ );
21
+ const pageGroupSize = computed(
22
+ () => blogConfig.value.pageGroupSize || DEFAULT_PAGE_GROUP_SIZE
23
+ );
24
+
25
+ const locale = computed(() => {
26
+ if (typeof navigator !== 'undefined' && navigator.language) return navigator.language;
27
+ return lang.value || 'en-US';
28
+ });
29
+
30
+ const { selectedTags } = useTagFilter();
31
+ const { filterPostsByActiveCategory, activeCategory } = useCategories({
32
+ otherLabel: getLocalizedString('other', lang.value),
33
+ });
34
+
35
+ const filteredPosts = computed(() => {
36
+ const byCategory = filterPostsByActiveCategory(activeCategory.value);
37
+ if (!selectedTags.value.length) return byCategory;
38
+ return byCategory.filter((item) => {
39
+ const tags = item.frontmatter.tags || [];
40
+ return selectedTags.value.some((tag) => tags.includes(tag));
41
+ });
42
+ });
43
+
44
+ const blogTitle = computed(() => (lang.value || '').startsWith('zh') ? '博客' : 'Blog');
45
+ const postsText = computed(() => (lang.value || '').startsWith('zh') ? '文章' : 'Posts');
46
+
47
+
48
+ const {
49
+ currentPage,
50
+ totalPages,
51
+ pageRange,
52
+ paginatedItems,
53
+ setPage,
54
+ nextPage,
55
+ prevPage,
56
+ jumpInput,
57
+ jumpToInput,
58
+ } = usePagination(filteredPosts, {
59
+ pageSize,
60
+ pageGroupSize: pageGroupSize.value,
61
+ pageParam: 'page',
62
+ });
63
+
64
+ watch([selectedTags, activeCategory, pageSize], () => {
65
+ setPage(1);
66
+ });
67
+
68
+ const hashString = (value) => {
69
+ let hash = 0;
70
+ for (let i = 0; i < value.length; i += 1) {
71
+ hash = (hash << 5) - hash + value.charCodeAt(i);
72
+ hash |= 0;
73
+ }
74
+ return Math.abs(hash);
75
+ };
76
+
77
+ const getCoverFallbackStyle = (post) => {
78
+ const title = post?.frontmatter?.title || post?.title || post?.url || 'post';
79
+ const hash = hashString(String(title));
80
+ const hue = hash % 360;
81
+ const hue2 = (hue + 40 + (hash % 60)) % 360;
82
+ const hue3 = (hue + 120 + (hash % 90)) % 360;
83
+ const sat = 30 + (hash % 20);
84
+ const light = 20 + (hash % 15);
85
+ const angle = 120 + (hash % 40);
86
+ const gradient = `linear-gradient(${angle}deg, hsla(${hue}, ${sat}%, ${light + 14}%, 0.42), hsla(${hue2}, ${sat}%, ${light}%, 0.22))`;
87
+ const dots = `radial-gradient(hsla(${hue2}, ${sat}%, ${light + 20}%, 0.35) 1px, transparent 1px)`;
88
+ return {
89
+ backgroundImage: `${gradient}, ${dots}`,
90
+ backgroundSize: 'cover, 16px 16px',
91
+ backgroundPosition: 'center, 0 0',
92
+ };
93
+ };
94
+
95
+ const changePage = (page) => {
96
+ setPage(page);
97
+ if (typeof window !== 'undefined') {
98
+ window.scrollTo({ top: 0, behavior: 'smooth' });
99
+ }
100
+ };
101
+
102
+ const jumpToPage = () => {
103
+ jumpToInput();
104
+ if (typeof window !== 'undefined') {
105
+ window.scrollTo({ top: 0, behavior: 'smooth' });
106
+ }
107
+ };
108
+ </script>
109
+
110
+ <template>
111
+ <ThemeLayout :showContent="true">
112
+ <div class="w-full flex flex-col gap-3 md:gap-4 mb-1">
113
+ <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
114
+ <div class="flex flex-col gap-2">
115
+ <div class="text-3xl md:text-4xl font-bold tracking-tight">{{ blogTitle }}</div>
116
+ <div class="text-sm opacity-70">
117
+ {{ filteredPosts.length }} {{ postsText }}
118
+ </div>
119
+ </div>
120
+ <div class="flex items-center gap-2 text-xs flex-wrap">
121
+ <span v-if="activeCategory"
122
+ class="px-3 py-1 rounded-full border border-[var(--blog-tag-text-2)] bg-[var(--blog-tag-bg-2)]/90 text-[var(--blog-tag-text-2)]">
123
+ 分类: {{ activeCategory }}
124
+ </span>
125
+ <span v-if="selectedTags.length"
126
+ class="px-3 py-1 rounded-full border border-[var(--blog-tag-text-1)] bg-[var(--blog-tag-bg-1)] text-[var(--blog-tag-text-1)]">
127
+ 标签: {{ selectedTags.join(" / ") }}
128
+ </span>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ <!-- 博客文章 -->
133
+ <div class="w-full flex justify-center items-center relative" v-for="(post, idx) of paginatedItems" :key="post.url">
134
+ <a :href="withBase(post.url)" class="w-full rounded-2xl">
135
+ <div
136
+ class="bg-opacity-90 backdrop-blur-md w-full rounded-2xl flex flex-col md:flex-row dark:shadow-none shadow-lg border-2 border-[var(--blog-border-c)] bg-[var(--vp-c-blog-bg)] relative transition duration-200 hover:-translate-y-0.5 hover:shadow-xl overflow-hidden"
137
+ :class="idx % 2 === 1 ? 'md:flex-row-reverse' : ''">
138
+ <!-- 置顶标识 -->
139
+ <div v-if="post.frontmatter.pin" class=" absolute top-0 left-0 w-0 h-0">
140
+ <div
141
+ class="z-20 absolute top-0 left-0 w-0 h-0 border-t-[2rem] border-r-transparent border-r-[2rem] border-[var(--vp-c-blog-bg)] rounded-tl-2xl">
142
+ </div>
143
+ <div
144
+ class="z-10 absolute top-0 left-0 w-0 h-0 border-t-[3rem] border-r-transparent border-r-[3rem] border-[var(--vp-c-brand-2)] rounded-tl-2xl">
145
+ </div>
146
+ </div>
147
+ <!-- 文章图片 -->
148
+ <div class="w-full md:w-2/5 bg-[var(--vp-c-bg)]/30">
149
+ <div class="w-full h-48 md:h-full min-h-48 relative overflow-hidden" v-if="post.frontmatter.cover">
150
+ <img :src="post.frontmatter.cover" alt=""
151
+ class="w-full h-full object-cover transition duration-300 scale-100 hover:scale-105" />
152
+ </div>
153
+ <div v-else class="w-full h-48 md:h-full min-h-48" :style="getCoverFallbackStyle(post)"></div>
154
+ </div>
155
+ <div class="w-full md:w-3/5 flex flex-col gap-3 px-6 md:px-8 py-6">
156
+ <!-- 标题 -->
157
+ <div class="text-lg md:text-xl font-semibold tracking-tight">
158
+ <span>{{ post.frontmatter.title }}</span>
159
+ </div>
160
+ <!-- 摘要 -->
161
+ <div v-html="post.excerpt || post.frontmatter.desc" class="text-sm leading-relaxed opacity-80"></div>
162
+ <!-- 文章信息 -->
163
+ <div class="flex justify-between w-full items-center flex-wrap text-sm gap-3 mt-auto pt-2">
164
+ <div class="flex justify-end items-end gap-2 flex-wrap">
165
+ <div v-for="(tag, idx) in post.frontmatter.tags" :key="`${post.url}-tag-${idx}`"
166
+ class="bg-[var(--blog-tag-bg-2)]/90 text-[var(--blog-tag-text-2)] border-[var(--blog-tag-text-2)] px-2.5 py-0.5 rounded-full text-xs">
167
+ <span>{{ tag }}</span>
168
+ </div>
169
+ </div>
170
+ <div class="text-xs opacity-75">{{ formatDate(post.frontmatter.date, locale) }}</div>
171
+ </div>
172
+ </div>
173
+ </div>
174
+ </a>
175
+ </div>
176
+ <!-- 分页 -->
177
+ <div class="flex justify-center items-center gap-2 border-0 flex-row w-full px-5" v-if="totalPages > 1">
178
+ <!-- 上一页 -->
179
+ <button @click="prevPage()" :disabled="currentPage <= 1"
180
+ class="border-2 px-3 h-8 text-center flex justify-center items-center cursor-pointer bg-[var(--vp-c-blog-bg)] rounded-md text-sm disabled:opacity-50 disabled:cursor-not-allowed">
181
+ {{ getLocalizedString('prev', lang) }}
182
+ </button>
183
+
184
+ <!-- 页码 -->
185
+ <div class="flex justify-center items-center gap-2">
186
+ <!-- 第一页(如果不在范围内) -->
187
+ <template v-if="pageRange[0] > 1">
188
+ <div @click="changePage(1)"
189
+ class="border-2 w-8 h-8 text-center flex justify-center items-center cursor-pointer rounded-md bg-[var(--vp-c-blog-bg)]">
190
+ 1
191
+ </div>
192
+ <span v-if="pageRange[0] > 2" class="text-sm">...</span>
193
+ </template>
194
+
195
+ <!-- 页码范围 -->
196
+ <div @click="changePage(page)" v-for="page in pageRange" :key="page"
197
+ class="border-2 w-8 h-8 text-center flex justify-center items-center cursor-pointer rounded-md" :class="{
198
+ 'bg-[var(--vp-c-brand-1)] text-white border-[var(--vp-c-brand-1)]': page === currentPage,
199
+ 'bg-[var(--vp-c-blog-bg)]': page !== currentPage,
200
+ }">
201
+ {{ page }}
202
+ </div>
203
+
204
+ <!-- 最后一页(如果不在范围内) -->
205
+ <template v-if="pageRange[pageRange.length - 1] < totalPages">
206
+ <span v-if="pageRange[pageRange.length - 1] < totalPages - 1" class="text-sm">...</span>
207
+ <div @click="changePage(totalPages)"
208
+ class="border-2 w-8 h-8 text-center flex justify-center items-center cursor-pointer rounded-md bg-[var(--vp-c-blog-bg)]">
209
+ {{ totalPages }}
210
+ </div>
211
+ </template>
212
+ </div>
213
+
214
+ <!-- 跳转到页 -->
215
+ <div class="flex items-center gap-2 ml-2">
216
+ <input type="number" min="1" :max="totalPages" v-model.trim="jumpInput" @keyup.enter="jumpToPage"
217
+ class="w-16 h-8 border-2 rounded-md bg-[var(--vp-c-blog-bg)] px-2 text-sm" :placeholder="`${currentPage}/${totalPages}`" />
218
+ <button @click="jumpToPage"
219
+ class="border-2 px-3 h-8 text-center flex justify-center items-center cursor-pointer bg-[var(--vp-c-blog-bg)] rounded-md text-sm">
220
+ 跳转
221
+ </button>
222
+ </div>
223
+
224
+ <!-- 下一页 -->
225
+ <button @click="nextPage()" :disabled="currentPage >= totalPages"
226
+ class="border-2 px-3 h-8 text-center flex justify-center items-center cursor-pointer bg-[var(--vp-c-blog-bg)] rounded-md text-sm disabled:opacity-50 disabled:cursor-not-allowed">
227
+ {{ getLocalizedString('next', lang) }}
228
+ </button>
229
+ </div>
230
+ </ThemeLayout>
231
+ </template>
232
+