Skip to content

Commit cc11ef1

Browse files
committed
feat: fixed eslint & new features
1 parent 3cedcc2 commit cc11ef1

49 files changed

Lines changed: 176 additions & 128 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

demo/pages/posts/draft.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- draft
77
duration: 2min
88
type: blog
9+
lang: en
910
---
1011

1112
::: zh-CN

demo/pages/posts/hello-valaxy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tags:
88
- 笔记
99
duration: 2min
1010
type: blog
11+
lang: zh
1112
---
1213

1314
## Hello, Valaxy!

demo/pages/posts/install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tags:
88
- document
99
duration: 2min
1010
type: docs
11+
lang: en
1112
---
1213

1314
[![npm](https://img.shields.io/npm/v/valaxy-theme-antfu?color=000)](https://www.npmjs.com/package/valaxy-theme-antfu)

demo/valaxy.config.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import LinkAttributes from 'markdown-it-link-attributes'
66
import MarkdownItGitHubAlerts from 'markdown-it-github-alerts'
77
import Shiki from '@shikijs/markdown-it'
88
import { rendererRich, transformerTwoslash } from '@shikijs/twoslash'
9-
// @ts-expect-error missing types
10-
import TOC from 'markdown-it-table-of-contents'
119

1210
/**
1311
* User Config
@@ -59,6 +57,25 @@ export default defineConfig<ThemeConfig>({
5957
},
6058
],
6159

60+
subNav: [
61+
{
62+
text: 'Blog',
63+
link: '/posts',
64+
},
65+
{
66+
text: 'Talks',
67+
link: '/talks',
68+
},
69+
{
70+
text: 'Notes',
71+
link: '/notes',
72+
},
73+
{
74+
text: 'Documentation',
75+
link: '/docs',
76+
},
77+
],
78+
6279
footer: {
6380
since: 2024,
6481
},

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ export default antfu(
55
{
66
unocss: true,
77
formatters: true,
8+
ignores: ['**/dist', '**/public'],
9+
rules: {
10+
'ts/no-unused-expressions': 'off',
11+
'regexp/no-unused-capturing-group': 'off',
12+
'vue/no-v-text-v-html-on-component': 'off',
13+
'vue/no-template-shadow': 'off',
14+
},
815
},
916
)

theme/components/CalCom.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if (typeof window !== 'undefined') {
4949
</script>
5050

5151
<template>
52-
<button :data-cal-link="link" btn-gray text-sm>
52+
<button :data-cal-link="link" text-sm btn-gray>
5353
<div i-ri-calendar-event-fill />
5454
{{ title }}
5555
</button>

theme/components/Footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const themeConfig = useThemeConfig()
77
</script>
88

99
<template>
10-
<div class="slide-enter m-auto mb-6 mt-10 flex prose animate-delay-1200!">
10+
<div class="slide-enter mb-6 flex prose m-auto mt-10 animate-delay-1200!">
1111
<span class="text-sm op50"><a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" style="color:inherit">CC BY-NC-SA 4.0</a> {{ themeConfig.footer.since }}-PRESENT © {{ siteConfig.author.name }}</span>
1212
<div class="flex-auto" />
1313
</div>

theme/components/ListPosts.vue

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script setup lang="ts">
2-
import { useRouter } from 'vue-router'
2+
// import { useRouter } from 'vue-router'
33
import { computed } from 'vue'
44
import { usePostList } from 'valaxy'
5+
import type { Post } from 'valaxy'
56
import { englishOnly, formatDate } from '../logics'
6-
import type { Post } from '../types'
77
88
const props = defineProps<{
99
type?: string
1010
posts?: Post[]
1111
extra?: Post[]
1212
}>()
1313
14-
const router = useRouter()
14+
// const router = useRouter()
1515
// const routes: Post[] = router.getRoutes()
1616
// .filter(i => i.path.startsWith('/posts') && i.meta.frontmatter.date && !i.meta.frontmatter.draft)
1717
// .filter(i => !i.path.endsWith('.html') && (i.meta.frontmatter.type || 'blog').split('+').includes(props.type))
@@ -30,13 +30,17 @@ const router = useRouter()
3030
// const routes = usePostList({ type: props.type || '' })
3131
const routes = usePostList({ type: props.type })
3232
33-
const posts = computed(() => props.posts || routes.value)
33+
// const posts = computed(() => props.posts || routes.value)
3434
35-
// const posts = computed(() =>
36-
// [...(props.posts || routes), ...props.extra || []]
37-
// .sort((a, b) => +new Date(b.date) - +new Date(a.date))
38-
// .filter(i => !englishOnly.value || i.lang !== 'zh'),
39-
// )
35+
const posts = computed(() =>
36+
[...(props.posts || routes.value), ...props.extra || []]
37+
.sort((a, b) => {
38+
const dateA = typeof a.date === 'string' || typeof a.date === 'number' ? new Date(a.date) : new Date()
39+
const dateB = typeof b.date === 'string' || typeof b.date === 'number' ? new Date(b.date) : new Date()
40+
return +dateB - +dateA
41+
})
42+
.filter(i => !englishOnly.value || i.lang !== 'zh'),
43+
)
4044
4145
const getYear = (a: Date | string | number) => new Date(a).getFullYear()
4246
const isFuture = (a?: Date | string | number) => a && new Date(a) > new Date()
@@ -48,28 +52,28 @@ function isSameGroup(a: Post, b?: Post) {
4852
function getGroupName(p: Post) {
4953
if (isFuture(p.date))
5054
return 'Upcoming'
51-
return getYear(p.date)
55+
return getYear(p.date!)
5256
}
5357
</script>
5458

5559
<template>
5660
<ul>
5761
<template v-if="!posts.length">
58-
<div py2 op50>
62+
<div op50 py2>
5963
{ nothing here yet }
6064
</div>
6165
</template>
6266

6367
<template v-for="route, idx in posts" :key="route.path">
6468
<div
65-
v-if="!isSameGroup(route, posts[idx - 1])" select-none relative h20 pointer-events-none slide-enter :style="{
69+
v-if="!isSameGroup(route, posts[idx - 1])" slide-enter select-none pointer-events-none relative h20 :style="{
6670
'--enter-stage': idx - 2,
6771
'--enter-step': '60ms',
6872
}"
6973
>
7074
<span
71-
text-8em color-transparent absolute left--3rem top--2rem font-bold text-stroke-2 text-stroke-hex-aaa
72-
op10
75+
76+
absolute font-bold color-transparent text-stroke-hex-aaa text-8em left--3rem top--2rem text-stroke-2 op10
7377
>{{ getGroupName(route) }}</span>
7478
</div>
7579
<div
@@ -79,19 +83,19 @@ function getGroupName(p: Post) {
7983
}"
8084
>
8185
<component
82-
:is="route.path.includes('://') ? 'a' : 'RouterLink'" v-bind="route.path.includes('://') ? {
86+
:is="route.path?.includes('://') ? 'a' : 'RouterLink'" v-bind="route.path?.includes('://') ? {
8387
href: route.path,
8488
target: '_blank',
8589
rel: 'noopener noreferrer',
8690
} : {
8791
to: route.path,
8892
}
89-
" class="item block font-normal mb-6 mt-2 no-underline"
93+
" class="mb-6 item block font-normal mt-2 no-underline"
9094
>
9195
<li class="no-underline" flex="~ col md:row gap-2 md:items-center">
92-
<div class="title text-lg leading-1.2em" flex="~ gap-2 wrap">
96+
<div class="text-lg title leading-1.2em" flex="~ gap-2 wrap">
9397
<span
94-
v-if="route.lang === 'zh'" align-middle flex-none
98+
v-if="route.lang === 'zh'" flex-none align-middle
9599
class="text-xs bg-zinc:15 text-zinc5 rounded px-1 py-0.5 ml--12 mr2 my-auto hidden md:block"
96100
>中文</span>
97101
<span align-middle>{{ route.title }}</span>
@@ -112,7 +116,7 @@ function getGroupName(p: Post) {
112116
<span text-sm op50 ws-nowrap>
113117
{{ formatDate(route.date, true) }}
114118
</span>
115-
<span v-if="route.duration" text-sm op40 ws-nowrap>· {{ route.duration }}</span>
119+
<span v-if="route.duration" text-sm ws-nowrap op40>· {{ route.duration }}</span>
116120
<span v-if="route.platform" text-sm op40 ws-nowrap>· {{ route.platform }}</span>
117121
<span v-if="route.place" text-sm op40 ws-nowrap md:hidden>· {{ route.place }}</span>
118122
<span
@@ -121,7 +125,7 @@ function getGroupName(p: Post) {
121125
>中文</span>
122126
</div>
123127
</li>
124-
<div v-if="route.place" op50 text-sm hidden mt--2 md:block>
128+
<div v-if="route.place" op50 text-sm hidden md:block mt--2>
125129
{{ route.place }}
126130
</div>
127131
</component>

theme/components/ListProjects.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
defineProps<{ projects: Record<string, any[]> }>()
33
44
function slug(name: string) {
5-
return name.toLowerCase().replace(/[\s\\\/]+/g, '-')
5+
return name.toLowerCase().replace(/[\s\\/]+/g, '-')
66
}
77
</script>
88

@@ -12,28 +12,28 @@ function slug(name: string) {
1212
v-for="key, cidx in Object.keys(projects)" :key="key" slide-enter
1313
:style="{ '--enter-stage': cidx + 1 }"
1414
>
15-
<div
15+
<div
1616
:id="slug(key)"
17-
select-none relative h20 pointer-events-none slide-enter
17+
slide-enter select-none relative h20 pointer-events-none
1818
:style="{
1919
'--enter-stage': cidx - 2,
2020
'--enter-step': '60ms',
2121
}"
2222
>
23-
<span text-5em color-transparent absolute left--1rem top-0rem font-bold leading-1em text-stroke-1.5 text-stroke-hex-aaa op35 dark:op20>{{ key }}</span>
23+
<span color-transparent absolute font-bold text-stroke-hex-aaa text-5em left--1rem top-0rem leading-1em text-stroke-1.5 op35 dark:op20>{{ key }}</span>
2424
</div>
2525
<!-- <h4 :id="slug(key)" class="mt-15 mb-2 font-bold text-center op75">
2626
{{ key }}
2727
</h4> -->
2828
<div
29-
class="project-grid py-2 max-w-500 w-max mx-auto"
29+
class="mx-auto project-grid py-2 max-w-500 w-max"
3030
grid="~ cols-1 md:cols-2 gap-4 lg:cols-3"
3131
:class="projects[key].length === 1 ? 'flex' : projects[key].length > 2 ? 'lg:grid-cols-3' : ''"
3232
>
3333
<a
3434
v-for="item, idx in projects[key]"
3535
:key="idx"
36-
class="item relative flex items-center"
36+
class="relative flex item items-center"
3737
:href="item.link"
3838
target="_blank"
3939
:class="!item.link ? 'opacity-0 pointer-events-none h-0 -mt-8 -mb-4' : ''"
@@ -48,16 +48,16 @@ function slug(name: string) {
4848
<Vitest v-else-if="item.icon === 'vitest'" class="text-4xl opacity-50" />
4949
<Elk v-else-if="item.icon === 'elk'" class="text-4xl opacity-50" />
5050
<AnthonyFu v-else-if="item.icon === 'af'" class="text-4xl opacity-50" />
51-
<div v-else class="text-3xl opacity-50" :class="item.icon || 'i-carbon-unknown'" />
51+
<div v-else class="opacity-50 text-3xl" :class="item.icon || 'i-carbon-unknown'" />
5252
</div>
5353
<div class="flex-auto">
5454
<div class="text-normal">{{ item.name }}</div>
55-
<div class="desc text-sm opacity-50 font-normal" v-html="item.desc" />
55+
<div class="text-sm opacity-50 font-normal desc" v-html="item.desc" />
5656
</div>
5757
</a>
5858
</div>
5959
</div>
60-
<div class="prose pb5 mx-auto mt10 text-center">
60+
<div class="mx-auto prose text-center pb5 mt10">
6161
<div block mt-5>
6262
<a href="https://antfu.me/stars-rank" target="_blank" op50>All projects sort by Stars</a>
6363
</div>

theme/components/ListTalks.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function daysLeft(date: string) {
2323
<hr>
2424
</div>
2525
<h2 :id="getSlug(talk.title)" tabindex="-1" important-mb-0>
26-
<span v-if="talk.series" mb1 text-lg font-400 italic op45>
26+
<span v-if="talk.series" text-lg mb1 font-400 italic op45>
2727
{{ talk.series }}
2828
<br>
2929
</span>
@@ -47,7 +47,7 @@ function daysLeft(date: string) {
4747
</a>
4848
<span
4949
v-if="p.lang === 'zh'"
50-
ml2 flex-none align-top
50+
flex-none align-top ml2
5151
class="my-auto rounded bg-zinc:15 px-1 py-0.5 text-xs text-zinc5"
5252
>中文</span>
5353
<div text-sm op50>
@@ -75,7 +75,7 @@ function daysLeft(date: string) {
7575
v-if="isFuture(p.date)" :href="p.conferenceUrl" target="_blank"
7676
rel="noopener noreferrer"
7777

78-
mr--2 rounded bg-gray:15 px2 font-bold font-serif op50 duration-500 important-border-0 hover:op100 important-transition-opacity
78+
rounded op50 duration-500 important-border-0 hover:op100 important-transition-opacity font-bold mr--2 bg-gray:15 px2 font-serif
7979
>
8080
<div i-ri-time-line />
8181
in {{ daysLeft(p.date) }} days

0 commit comments

Comments
 (0)