@sugarat/theme 0.1.7 → 0.1.9
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/node.d.ts +16 -0
- package/package.json +1 -1
- package/src/components/BlogItem.vue +31 -0
- package/src/components/BlogList.vue +7 -4
- package/src/components/BlogRecommendArticle.vue +10 -3
- package/src/components/TimelinePage.vue +7 -0
- package/src/composables/config/index.ts +17 -0
- package/src/index.ts +7 -1
- package/src/styles/index.scss +1 -0
package/node.d.ts
CHANGED
|
@@ -39,6 +39,22 @@ declare namespace Theme {
|
|
|
39
39
|
layout?: string;
|
|
40
40
|
categories: string[];
|
|
41
41
|
tags: string[];
|
|
42
|
+
/**
|
|
43
|
+
* 文章首页置顶
|
|
44
|
+
*/
|
|
45
|
+
top?: number;
|
|
46
|
+
/**
|
|
47
|
+
* 手动控制相关文章列表的顺序
|
|
48
|
+
*/
|
|
49
|
+
recommend?: number | false;
|
|
50
|
+
/**
|
|
51
|
+
* 时间线
|
|
52
|
+
*/
|
|
53
|
+
timeline: string;
|
|
54
|
+
/**
|
|
55
|
+
* 专栏&合集
|
|
56
|
+
*/
|
|
57
|
+
album: string;
|
|
42
58
|
}
|
|
43
59
|
interface PageData {
|
|
44
60
|
route: string;
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<a class="blog-item" :href="route">
|
|
3
|
+
<i class="pin" v-if="!!pin"></i>
|
|
3
4
|
<!-- 左侧信息 -->
|
|
4
5
|
<div class="info-part">
|
|
5
6
|
<!-- 标题 -->
|
|
@@ -33,6 +34,7 @@ const props = defineProps<{
|
|
|
33
34
|
tag?: string[]
|
|
34
35
|
author?: string
|
|
35
36
|
cover?: string
|
|
37
|
+
pin?: number
|
|
36
38
|
}>()
|
|
37
39
|
|
|
38
40
|
const showTime = computed(() => {
|
|
@@ -41,6 +43,35 @@ const showTime = computed(() => {
|
|
|
41
43
|
</script>
|
|
42
44
|
|
|
43
45
|
<style lang="scss" scoped>
|
|
46
|
+
.blog-item .pin {
|
|
47
|
+
position: absolute;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
width: 30px;
|
|
50
|
+
height: 30px;
|
|
51
|
+
top: -4px;
|
|
52
|
+
left: -4px;
|
|
53
|
+
opacity: 0.5;
|
|
54
|
+
}
|
|
55
|
+
.blog-item:hover .pin {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
}
|
|
58
|
+
.blog-item .pin::before {
|
|
59
|
+
content: '';
|
|
60
|
+
position: absolute;
|
|
61
|
+
width: 120%;
|
|
62
|
+
height: 30px;
|
|
63
|
+
background-image: linear-gradient(
|
|
64
|
+
45deg,
|
|
65
|
+
var(--blog-theme-color),
|
|
66
|
+
var(--blog-theme-color)
|
|
67
|
+
);
|
|
68
|
+
transform: rotate(-45deg) translateY(-20px);
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.23);
|
|
73
|
+
}
|
|
74
|
+
|
|
44
75
|
.blog-item {
|
|
45
76
|
position: relative;
|
|
46
77
|
margin: 0 auto 20px;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
:tag="v.meta.tag"
|
|
10
10
|
:cover="v.meta.cover"
|
|
11
11
|
:author="v.meta.author || globalAuthor"
|
|
12
|
+
:pin="v.meta.top"
|
|
12
13
|
/>
|
|
13
14
|
</li>
|
|
14
15
|
</ul>
|
|
@@ -43,11 +44,13 @@ const activeTag = useActiveTag()
|
|
|
43
44
|
const activeTagLabel = computed(() => activeTag.value.label)
|
|
44
45
|
|
|
45
46
|
const wikiList = computed(() => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const topList = docs.value.filter((v) => v.meta.top)
|
|
48
|
+
topList.sort((a, b) => a.meta.top - b.meta.top)
|
|
49
|
+
const data = docs.value.filter(
|
|
50
|
+
(v) => v.meta.date && v.meta.title && !v.meta.top && !v.meta.hidden
|
|
51
|
+
)
|
|
49
52
|
data.sort((a, b) => +new Date(b.meta.date) - +new Date(a.meta.date))
|
|
50
|
-
return data
|
|
53
|
+
return topList.concat(data)
|
|
51
54
|
})
|
|
52
55
|
|
|
53
56
|
const filterData = computed(() => {
|
|
@@ -66,9 +66,16 @@ const recommendList = computed(() => {
|
|
|
66
66
|
.filter((v) => !!v.meta.title)
|
|
67
67
|
// 过滤掉自己
|
|
68
68
|
.filter((v) => v.route !== route.path.replace(/.html$/, ''))
|
|
69
|
+
// 过滤掉不需要展示的
|
|
70
|
+
.filter((v) => v.meta.recommend !== false)
|
|
69
71
|
|
|
70
|
-
origin.
|
|
71
|
-
|
|
72
|
+
const topList = origin.filter((v) => v.meta?.recommend)
|
|
73
|
+
topList.sort((a, b) => Number(a.meta.recommend) - Number(b.meta.recommend))
|
|
74
|
+
|
|
75
|
+
const normalList = origin.filter((v) => !v.meta?.recommend)
|
|
76
|
+
normalList.sort((a, b) => +new Date(b.meta.date) - +new Date(a.meta.date))
|
|
77
|
+
|
|
78
|
+
return topList.concat(normalList)
|
|
72
79
|
})
|
|
73
80
|
const currentPage = ref(1)
|
|
74
81
|
const changePage = () => {
|
|
@@ -128,7 +135,7 @@ const showChangeBtn = computed(() => {
|
|
|
128
135
|
font-size: 14px;
|
|
129
136
|
color: var(--description-font-color);
|
|
130
137
|
font-weight: 600;
|
|
131
|
-
margin: 6px
|
|
138
|
+
margin: 6px 8px 10px 0;
|
|
132
139
|
width: 18px;
|
|
133
140
|
height: 18px;
|
|
134
141
|
line-height: 18px;
|
|
@@ -45,6 +45,23 @@ export namespace Theme {
|
|
|
45
45
|
// old
|
|
46
46
|
categories: string[]
|
|
47
47
|
tags: string[]
|
|
48
|
+
/**
|
|
49
|
+
* 文章首页置顶
|
|
50
|
+
*/
|
|
51
|
+
top?: number
|
|
52
|
+
/**
|
|
53
|
+
* 手动控制相关文章列表的顺序
|
|
54
|
+
*/
|
|
55
|
+
recommend?: number | false
|
|
56
|
+
// TODO: 待开发
|
|
57
|
+
/**
|
|
58
|
+
* 时间线
|
|
59
|
+
*/
|
|
60
|
+
timeline: string
|
|
61
|
+
/**
|
|
62
|
+
* 专栏&合集
|
|
63
|
+
*/
|
|
64
|
+
album: string
|
|
48
65
|
}
|
|
49
66
|
export interface PageData {
|
|
50
67
|
route: string
|
package/src/index.ts
CHANGED
|
@@ -10,9 +10,15 @@ import DefaultTheme from 'vitepress/theme'
|
|
|
10
10
|
import BlogApp from './components/BlogApp.vue'
|
|
11
11
|
import { withConfigProvider } from './composables/config/blog'
|
|
12
12
|
|
|
13
|
+
// page
|
|
14
|
+
import TimelinePage from './components/TimelinePage.vue'
|
|
15
|
+
|
|
13
16
|
export const BlogTheme: Theme = {
|
|
14
17
|
...DefaultTheme,
|
|
15
|
-
Layout: withConfigProvider(BlogApp)
|
|
18
|
+
Layout: withConfigProvider(BlogApp),
|
|
19
|
+
enhanceApp(ctx) {
|
|
20
|
+
ctx.app.component('TimelinePage', TimelinePage)
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export * from './composables/config/index'
|