Skip to content

Commit 0f601b0

Browse files
committed
docs: sort showcase by stargazers count
1 parent b03971e commit 0f601b0

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎docs/.vitepress/components/RepoInfo.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defineProps<{
2929
</div>
3030
</a>
3131

32-
<a target="_blank" :href="`https://www.npmjs.com/package/${name}`">
32+
<a target="_blank" :href="`https://npmx.dev/package/${name}`">
3333
<div class="flex text-gray-400" hover="text-#cc3534">
3434
<i class="i-ri:npmjs-fill" />
3535
</div>

‎docs/.vitepress/config.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
import type { Repository } from './data/repository.data'
2+
import { createRequire } from 'node:module'
13
import path from 'node:path'
24
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
35
import MarkdownItGitHubAlerts from 'markdown-it-github-alerts'
46
import { defineConfig } from 'vitepress'
57
import { groupIconMdPlugin } from 'vitepress-plugin-group-icons'
68
import { description, ogImage, title } from './constant'
7-
import { repositoryMeta } from './data/meta'
9+
10+
const require = createRequire(import.meta.url)
11+
const repos: Repository[] = []
12+
13+
try {
14+
const meta = require('./data/repository.json')
15+
repos.push(...meta)
16+
}
17+
catch {
18+
}
819

920
// https://vitepress.dev/reference/site-config
1021
export default defineConfig({
@@ -43,7 +54,7 @@ export default defineConfig({
4354
text: 'Overview',
4455
link: '/showcase/',
4556
},
46-
...repositoryMeta.map(repo => (
57+
...repos.map(repo => (
4758
{
4859
text: repo.name,
4960
link: `/showcase/${repo.name}`,
@@ -80,6 +91,7 @@ export default defineConfig({
8091
md.use(groupIconMdPlugin)
8192
},
8293
codeTransformers: [
94+
// @ts-expect-error - version mismatch
8395
transformerTwoslash({
8496
twoslashOptions: {
8597
compilerOptions: {

‎docs/.vitepress/data/gen-files.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ for (const [key, repo] of Object.entries(data)) {
3939

4040
writeFileSync(
4141
path.resolve(import.meta.dirname, 'repository.json'),
42-
JSON.stringify(Object.values(data), null, 2),
42+
JSON.stringify(Object.values(data).sort(
43+
(a, b) => b.stargazers.totalCount - a.stargazers.totalCount,
44+
), null, 2),
4345
)
4446

4547
consola.success('All files generate done!')

0 commit comments

Comments
 (0)