diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9d08a1a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.vscode/settings.json b/.vscode/settings.json index f6b486c..ce4bbaa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,33 @@ { - "cSpell.words": [ - "iconify", - "katex", - "pangu", - "vuepress" - ] + "cSpell.words": [ + "antfu", + "attributify", + "iconify", + "katex", + "pangu", + "vuepress" + ], + "editor.formatOnSave": false, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.organizeImports": "never" + }, + // Enable the ESlint flat config support + "eslint.experimental.useFlatConfig": true, + // The following is optional. + // It's better to put under project setting `.vscode/settings.json` + // to avoid conflicts with working with different eslint configs + // that does not support all formats. + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml" + ] } diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 65403a7..09ec625 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,11 +1,11 @@ +import { readFileSync, statSync } from 'node:fs' +import { join } from 'node:path' import { defineConfig } from 'vitepress' -import nav from './nav' -import mdPangu from "markdown-it-pangu" +import mdPangu from 'markdown-it-pangu' import katex from 'markdown-it-katex' import footnote from 'markdown-it-footnote' +import nav from './nav' import { sidebar } from './sidebar' -import { readFileSync, statSync } from 'node:fs' -import { join } from 'node:path' const dir = 'docs' const siteTitle = 'SOC-8' @@ -17,17 +17,17 @@ export default defineConfig({ ssr: { noExternal: [ '@nolebase/vitepress-plugin-enhanced-readabilities', - '@nolebase/vitepress-plugin-highlight-targeted-heading' + '@nolebase/vitepress-plugin-highlight-targeted-heading', ], }, }, - title: "SOC-8", + title: 'SOC-8', base: '/SOC-8/', markdown: { config(md) { - md.use(mdPangu); - md.use(footnote); - md.use(katex); + md.use(mdPangu) + md.use(footnote) + md.use(katex) }, }, dir, @@ -42,7 +42,7 @@ export default defineConfig({ sidebar, socialLinks: [ - { icon: 'github', link: 'https://github.com/project-trans/SOC-8' } + { icon: 'github', link: 'https://github.com/project-trans/SOC-8' }, ], editLink: { @@ -72,16 +72,16 @@ export default defineConfig({ 'meta', { property: 'og:title', - content: siteTitle - } + content: siteTitle, + }, ]) head.push([ 'meta', { name: 'description', - content: '跨性别和多元性别人群健康照护指南第八版(SOC-8)' - } + content: '跨性别和多元性别人群健康照护指南第八版(SOC-8)', + }, ]) return head @@ -135,35 +135,34 @@ export default defineConfig({ // trim space pageContent = pageContent.trim() // if pageSourceFileContent is longer than 200 characters, add ellipsis - if (pageSourceFileContent.length > 100) { + if (pageSourceFileContent.length > 100) pageContent += '...' - } head.push([ 'meta', - { name: 'description', content: pageContent } + { name: 'description', content: pageContent }, ]) head.push([ 'meta', - { property: 'og:title', content: context.title } + { property: 'og:title', content: context.title }, ]) head.push([ 'meta', - { property: 'og:description', content: pageContent } + { property: 'og:description', content: pageContent }, ]) head.push([ 'meta', - { property: 'og:title', content: context.title } + { property: 'og:title', content: context.title }, ]) head.push([ 'meta', - { property: 'twitter:description', content: pageContent } + { property: 'twitter:description', content: pageContent }, ]) return head - } + }, }) diff --git a/docs/.vitepress/env.d.ts b/docs/.vitepress/env.d.ts index c390b34..d1034d4 100644 --- a/docs/.vitepress/env.d.ts +++ b/docs/.vitepress/env.d.ts @@ -1,5 +1,6 @@ declare module 'markdown-it-pangu' { - import { PluginSimple } from 'markdown-it' + import type { PluginSimple } from 'markdown-it' + const pangu: PluginSimple export default pangu -} \ No newline at end of file +} diff --git a/docs/.vitepress/nav.ts b/docs/.vitepress/nav.ts index a1533c8..393ef4a 100644 --- a/docs/.vitepress/nav.ts +++ b/docs/.vitepress/nav.ts @@ -1,9 +1,9 @@ -import { type DefaultTheme } from 'vitepress' +import type { DefaultTheme } from 'vitepress' const nav = [ { - text: "简体中文翻译", - link: "/soc8cn/", + text: '简体中文翻译', + link: '/soc8cn/', }, -] satisfies DefaultTheme.Config['nav']; -export default nav; +] satisfies DefaultTheme.Config['nav'] +export default nav diff --git a/docs/.vitepress/plugins/markdownTransform.ts b/docs/.vitepress/plugins/markdownTransform.ts index 3a73a6f..7d4b26b 100644 --- a/docs/.vitepress/plugins/markdownTransform.ts +++ b/docs/.vitepress/plugins/markdownTransform.ts @@ -1,5 +1,5 @@ +import { relative, resolve } from 'node:path' import type { Plugin } from 'vite' -import { resolve, relative } from 'path' const ROOT = resolve(__dirname, '../../') @@ -12,7 +12,7 @@ export function MarkdownTransform(): Plugin { return null id = relative(ROOT, id) - if (id == 'index.md') + if (id === 'index.md') return null code = pageHeaderTemplate(code) @@ -22,11 +22,12 @@ export function MarkdownTransform(): Plugin { } } - -const pageHeaderTemplate = (code: string) => code.replace(/(^---$(\s|\S)+^---$)/m, `$1 +function pageHeaderTemplate(code: string) { + return code.replace(/(^---$(\s|\S)+^---$)/m, `$1 # {{ $frontmatter.title }} `) +} diff --git a/docs/.vitepress/sidebar.ts b/docs/.vitepress/sidebar.ts index 110f6f7..9ef0a75 100644 --- a/docs/.vitepress/sidebar.ts +++ b/docs/.vitepress/sidebar.ts @@ -1,7 +1,7 @@ -import { type DefaultTheme } from 'vitepress' +import type { DefaultTheme } from 'vitepress' import { generateSidebar } from 'vitepress-sidebar' -export const sidebar = generateSidebar([ +export const sidebar = generateSidebar([ // 大学指南 { documentRootPath: '/docs', diff --git a/docs/.vitepress/theme/components/Containers.vue b/docs/.vitepress/theme/components/Containers.vue index 12bd117..080a596 100644 --- a/docs/.vitepress/theme/components/Containers.vue +++ b/docs/.vitepress/theme/components/Containers.vue @@ -1,14 +1,9 @@ diff --git a/docs/.vitepress/theme/components/PageInfo.vue b/docs/.vitepress/theme/components/PageInfo.vue index b7eaa99..0cd4a16 100644 --- a/docs/.vitepress/theme/components/PageInfo.vue +++ b/docs/.vitepress/theme/components/PageInfo.vue @@ -1,11 +1,11 @@