2
2
import CategorySecond from ' /src/components/CategorySecond.vue' ;
3
3
import AppLink from ' ../../components/AppLink.vue' ;
4
4
5
- const csArticleFrontmatters = import .meta.glob(
5
+ const csArticleTitles = import .meta.glob(
6
6
[' ./articles/*.zh.md' , ' !./articles/template*' ],
7
7
// Tricky solution for importing only the titles statically.
8
8
// The `query` parameter creates a unique import identifier for Vite
@@ -13,9 +13,14 @@ const csArticleFrontmatters = import.meta.glob(
13
13
{ eager: true , import: ' title' , query: ' title.md' }
14
14
);
15
15
16
- const catalog = Object .entries (csArticleFrontmatters).map (([path , title ]) => {
16
+ const csArticleDates = import .meta.glob(
17
+ [' ./articles/*.zh.md' , ' !./articles/template*' ],
18
+ { eager: true , import: ' date' , query: ' date.md' }
19
+ );
20
+
21
+ const catalog = Object .entries (csArticleTitles).map (([path , title ]) => {
17
22
const slug = path .split (' /' ).pop ().replace (' .zh.md' , ' ' );
18
- return { slug, title };
23
+ return { slug, title, date : csArticleDates[path] };
19
24
});
20
25
</script >
21
26
@@ -55,11 +60,17 @@ const catalog = Object.entries(csArticleFrontmatters).map(([path, title]) => {
55
60
</ul >
56
61
57
62
<category-second title =" 众筹项目记录" />
58
- <ul class =" list-disc py-6 pl-16" >
59
- <li v-for =" item in catalog" :key =" item.slug" >
60
- <app-link :to =" `/crowdsourcing/${item.slug}`" >{{
61
- item.title
62
- }}</app-link >
63
+ <ul class =" list-disc px-16 py-6" >
64
+ <li
65
+ v-for =" item in catalog.toSorted(
66
+ (a, b) => Date.parse(a.date) - Date.parse(b.date)
67
+ )"
68
+ :key =" item.slug"
69
+ class =" flex justify-between" >
70
+ <app-link :to =" `/crowdsourcing/${item.slug}`" >
71
+ {{ item.title }}
72
+ </app-link >
73
+ <span >[{{ item.date.split('T')[0] }}]</span >
63
74
</li >
64
75
</ul >
65
76
</div >
0 commit comments