chore: upgrade deps & lint

This commit is contained in:
YunYouJun 2023-10-03 00:15:39 +08:00
parent 65528c7d98
commit bc60967d62
80 changed files with 1025 additions and 1107 deletions

View File

@ -1,7 +1,7 @@
dist
public
cache
packages/valaxy/index.d.ts
packages/valaxy/client.d.ts
cache

View File

@ -1,3 +0,0 @@
{
"extends": "@antfu"
}

32
.vscode/settings.json vendored
View File

@ -13,18 +13,40 @@
"valaxy",
"valaxyjs"
],
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
},
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
],
"i18n-ally.sourceLanguage": "en",
"i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": ["packages/valaxy/src/client/locales"],
"i18n-ally.sortKeys": true,
"prettier.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.associations": {
"*.css": "postcss"
},
"editor.formatOnSave": false,
"[scss]": {
"editor.formatOnSave": true
},

View File

@ -5,8 +5,8 @@
"cypress"
]
},
"exclude": [],
"include": [
"**/*.ts"
]
],
"exclude": []
}

View File

@ -24,7 +24,7 @@
},
"devDependencies": {
"nodemon": "^3.0.1",
"vite-plugin-inspect": "^0.7.38",
"vite-plugin-inspect": "^0.7.40",
"vite-plugin-pwa": "^0.16.5"
}
}

View File

@ -1,18 +1,18 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"baseUrl": ".",
"resolveJsonModule": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": ["dist", "node_modules"]
}

View File

@ -21,7 +21,7 @@
"devDependencies": {
"nodemon": "^3.0.1",
"vite": "^4.4.9",
"vitepress": "1.0.0-rc.13",
"vitepress": "1.0.0-rc.20",
"vue": "^3.3.4"
}
}

View File

@ -184,7 +184,8 @@ And Vite's `import.meta.globEager` import must use a static string.
```ts {3}
const messages = Object.fromEntries(
Object.entries(
import.meta.globEager('../../locales/*.y(a)?ml'))
import.meta.globEager('../../locales/*.y(a)?ml')
)
.map(([key, value]) => {
const yaml = key.endsWith('.yaml')
return [key.slice(14, yaml ? -5 : -4), value.default]
@ -437,8 +438,7 @@ export function containerPlugin(md: MarkdownIt) {
languages.forEach((lang) => {
md.use(container, lang, {
render: (tokens: Token[], idx: number) =>
tokens[idx].nesting === 1 ? `<div lang="${lang}">\n` : '</div>\n',
render: (tokens: Token[], idx: number) => tokens[idx].nesting === 1 ? `<div lang="${lang}">\n` : '</div>\n',
})
})
}

View File

@ -1,18 +1,18 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"baseUrl": ".",
"resolveJsonModule": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": ["dist", "node_modules"]
}

4
eslint.config.js Normal file
View File

@ -0,0 +1,4 @@
// eslint.config.js
import antfu from '@antfu/eslint-config'
export default antfu()

View File

@ -1,8 +1,9 @@
{
"name": "@valaxyjs/monorepo",
"type": "module",
"version": "0.14.61",
"private": true,
"packageManager": "pnpm@8.7.5",
"packageManager": "pnpm@8.8.0",
"description": "📄 Vite & Vue powered static blog generator.",
"author": {
"email": "me@yunyoujun.cn",
@ -45,27 +46,27 @@
"prepare": "husky install"
},
"devDependencies": {
"@antfu/eslint-config": "^0.42.0",
"@microsoft/api-extractor": "^7.37.0",
"@types/debug": "^4.1.8",
"@types/markdown-it-attrs": "^4.1.0",
"@types/markdown-it-container": "^2.0.6",
"@antfu/eslint-config": "^1.0.0-beta.18",
"@microsoft/api-extractor": "^7.38.0",
"@types/debug": "^4.1.9",
"@types/markdown-it-attrs": "^4.1.1",
"@types/markdown-it-container": "^2.0.7",
"@types/markdown-it-emoji": "^2.0.2",
"@types/node": "^20.6.1",
"@types/prompts": "^2.4.4",
"@types/resolve": "^1.20.2",
"@types/semver": "^7.5.2",
"@types/node": "^20.8.0",
"@types/prompts": "^2.4.5",
"@types/resolve": "^1.20.3",
"@types/semver": "^7.5.3",
"cross-env": "^7.0.3",
"cypress": "^13.2.0",
"eslint": "^8.49.0",
"eslint-plugin-cypress": "^2.14.0",
"cypress": "^13.3.0",
"eslint": "^8.50.0",
"eslint-plugin-cypress": "^2.15.1",
"https-localhost": "^4.7.1",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prompts": "^2.4.2",
"rimraf": "^5.0.1",
"rimraf": "^5.0.5",
"tsup": "^7.2.0",
"tsx": "^3.12.10",
"tsx": "^3.13.0",
"typescript": "^5.2.2",
"valaxy": "workspace:*",
"valaxy-addon-algolia": "workspace:*",
@ -75,8 +76,8 @@
"valaxy-addon-waline": "workspace:*",
"valaxy-theme-press": "workspace:*",
"valaxy-theme-yun": "workspace:*",
"vitest": "^0.34.4",
"vue-tsc": "1.8.11",
"vitest": "^0.34.6",
"vue-tsc": "1.8.15",
"zx": "^7.2.3"
},
"pnpm": {

View File

@ -184,7 +184,6 @@ async function getValidPackageName(projectName) {
/**
* @param {string} dir
* @returns
*/
function emptyDir(dir) {
if (!fs.existsSync(dir))

View File

@ -1,21 +1,21 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./*"]
}
},
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": ["dist", "node_modules"]
}

6
packages/shims.d.ts vendored
View File

@ -10,12 +10,14 @@ declare module '@docsearch/react/dist/esm/types' {
declare module '*.md' {
import { type DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
const component: DefineComponent<object, object, any>
export default component
}
declare module '*.vue' {
import { type DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
const component: DefineComponent<object, object, any>
export default component
}

View File

@ -57,7 +57,7 @@ export function useAddonAlgolia() {
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
e.preventDefault()
load()
// eslint-disable-next-line @typescript-eslint/no-use-before-define
// eslint-disable-next-line ts/no-use-before-define
remove()
}
}

View File

@ -6,7 +6,6 @@ import pkg from '../package.json'
/**
* get addon config
* @returns
*/
export function useAddonAlgoliaConfig() {
const runtimeConfig = useRuntimeConfig()

View File

@ -10,6 +10,6 @@
],
"main": "index.ts",
"dependencies": {
"lightgallery": "^2.7.1"
"lightgallery": "^2.7.2"
}
}

View File

@ -5,7 +5,6 @@ import type { TwikooOptions } from '../types'
/**
* get addon config
* @returns
*/
export function useAddonTwikoo() {
const runtimeConfig = useRuntimeConfig()

View File

@ -35,8 +35,6 @@ export function useTwikoo(options: ComputedRef<TwikooOptions | undefined>, versi
/**
* init twikoo
* @param options twikoo options
* @returns
*/
function initTwikoo(twikooOptions: TwikooOptions) {
if (!isClient)

View File

@ -5,7 +5,6 @@ import type { WalineOptions } from '../types'
/**
* get addon config
* @returns
*/
export function useAddonWaline() {
const runtimeConfig = useRuntimeConfig()

View File

@ -1,6 +1,6 @@
{
"name": "valaxy-addon-waline",
"version": "0.1.0",
"version": "0.1.1",
"description": "Waline Composition API for Valaxy",
"repository": "https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-waline",
"keywords": [
@ -17,6 +17,6 @@
"valaxy": "latest"
},
"dependencies": {
"@waline/client": "^2.15.7"
"@waline/client": "^2.15.8"
}
}

View File

@ -2,7 +2,6 @@
* Get emojis cdn path
* @param cdn
* @param types
* @returns
*/
export function getEmojis(cdn = '//unpkg.com/', types = ['bilibili', 'qq', 'weibo']) {
return types.map(type => `${cdn}@waline/emojis/${type}/`)

View File

@ -4,7 +4,6 @@ import type { ThemeConfig } from '../types'
/**
* getThemeConfig
* @returns
*/
export function useThemeConfig<T = ThemeConfig>() {
const config = useConfig<T>()

View File

@ -2,26 +2,26 @@
// we need tsconfig.json to compile without
// error: This is likely not portable. A type annotation is necessary.
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"types": [
"vite/client",
"vue/ref-macros",
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client"
]
],
"resolveJsonModule": true,
"allowJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": ["**/dist/**", "node_modules"]
}

View File

@ -5,8 +5,8 @@ export namespace PressTheme {
export type Sidebar = any
export interface Footer {
message?: string;
copyright?: string;
message?: string
copyright?: string
}
export interface SocialLink {
@ -46,7 +46,6 @@ export namespace PressTheme {
*/
primary: string
}
nav: Array<NavItem>
sidebar: string[]
@ -80,8 +79,6 @@ export interface NavItemGroup {
export type NavItem = NavItemLink | NavItemGroup
/**
* Theme Config
*/

View File

@ -2,7 +2,6 @@
* get locale title
* @param locale
* @param frontmatter
* @returns
*/
export function getLocaleTitle(locale: string, frontmatter: any) {
return frontmatter[`title${locale === 'en' ? '' : `_${locale}`}`]

View File

@ -5,7 +5,7 @@ defineProps<{
</script>
<template>
<div class="yun-notice">
<div class="yun-notice m-auto">
<span v-html="content" />
<slot />
</div>

View File

@ -4,7 +4,6 @@ import type { YunTheme } from '../types'
/**
* getThemeConfig
* @returns
*/
export function useThemeConfig<ThemeConfig = YunTheme.Config>() {
const config = useValaxyConfig<ThemeConfig>()

View File

@ -5,7 +5,6 @@ import { isClient } from '@vueuse/core'
* fetch data from source, and random
* @param source
* @param random
* @returns
*/
export function useRandomData<T>(source: string | T[], random = false) {
const data = ref<T[]>()

View File

@ -3,8 +3,6 @@ import type { UserThemeConfig } from '../types'
/**
* generateSafelist by config
* @param themeConfig
* @returns
*/
export function generateSafelist(options: ResolvedValaxyOptions<UserThemeConfig>) {
const themeConfig = options.config.themeConfig || {}

View File

@ -19,11 +19,11 @@
"dependencies": {
"@explosions/fireworks": "^0.0.2",
"@iconify-json/ant-design": "^1.1.10",
"@iconify-json/simple-icons": "^1.1.70",
"@iconify-json/simple-icons": "^1.1.73",
"animejs": "^3.2.1"
},
"devDependencies": {
"@types/animejs": "^3.1.7",
"@types/animejs": "^3.1.8",
"valaxy": "workspace:*",
"valaxy-addon-waline": "workspace:*"
}

View File

@ -2,26 +2,26 @@
// we need tsconfig.json to compile without
// error: This is likely not portable. A type annotation is necessary.
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"types": [
"vite/client",
"vue/ref-macros",
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client"
]
],
"resolveJsonModule": true,
"allowJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": ["**/dist/**", "node_modules"]
}

View File

@ -4,7 +4,7 @@ export namespace YunTheme {
export type Config = ThemeConfig
export type Sidebar = any
export type Banner = {
export interface Banner {
/**
*
*/
@ -48,7 +48,7 @@ export interface ThemeConfig {
colors: {
/**
* @en primary color
*
*
* @zh
* @default '#0078E7'
*/
@ -84,9 +84,9 @@ export interface ThemeConfig {
}
/**
* @en
* @en
* say something
*
*
* @zh
* - API https://el-bot-api.elpsy.cn/api/words/young
* public json 使, public/young.json

View File

@ -40,7 +40,6 @@ export function isCategoryList(category: any): category is CategoryList {
* }
* ]
* }
* @returns
*/
export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
return computed(() => {

View File

@ -14,7 +14,6 @@ export function useFrontmatter() {
/**
* inject pageData
* @returns
*/
export function useData(): PageData {
const value = inject<PageData>('pageData', {} as any)

View File

@ -3,7 +3,6 @@ import { useSiteConfig } from 'valaxy'
/**
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/SubtleCrypto/deriveKey#pbkdf2_2
* @param password
* @returns
*/
export function getKeyMaterial(password: string) {
const enc = new TextEncoder()

View File

@ -5,7 +5,6 @@ import { ref } from 'vue'
/**
* trigger show invisible element
* @param target
* @returns
*/
export function useInvisibleElement(target: Ref<HTMLElement | undefined>) {
const isVisible = ref(false)

View File

@ -64,7 +64,6 @@ function addToParent(
/**
* export headers & handleClick to generate outline
* @returns
*/
export function useOutline() {
const frontmatter = useFrontmatter()
@ -104,7 +103,6 @@ export function useOutline() {
/**
* get headers from document directly
* @returns
*/
export function getHeaders(range: Exclude<DefaultTheme.Config['outline'], false>) {
const headers = Array.from(document.querySelectorAll('.markdown-body :where(h1,h2,h3,h4,h5,h6)'))

View File

@ -16,7 +16,6 @@ export function usePostTitle(post: ComputedRef<Post>) {
/**
* get all page in 'pages' folder
* @returns
*/
export function usePageList() {
return computed<Post[]>(() => {
@ -37,8 +36,6 @@ export function usePageList() {
/**
* get post list in 'pages/posts' folder
* todo: use vue provide/inject to global
* @param params
* @returns
*/
export function usePostList(params: {
type?: string
@ -67,7 +64,6 @@ export function usePostList(params: {
/**
* get prev and next post
* @param path
* @returns
*/
export function usePrevNext(path?: string) {
const route = useRoute()

View File

@ -9,7 +9,6 @@ export type Tags = Map<string, {
/**
* get tag map
* [tagName]: count
* @returns
*/
export function useTags() {
const site = useSiteStore()

View File

@ -15,7 +15,6 @@ import type { DefaultTheme, ValaxyConfig } from 'valaxy/types'
/**
* parse valaxy config
* @param data
* @returns
*/
function parse<T = any>(data: string): T {
const parsed = JSON.parse(data)
@ -55,7 +54,6 @@ export function initContext() {
/**
* get valaxy config
* @public
* @returns
*/
export function useValaxyConfig<ThemeConfig = DefaultTheme.Config>() {
const config = inject<ComputedRef<ValaxyConfig<ThemeConfig>>>(valaxyConfigSymbol)
@ -67,7 +65,6 @@ export function useValaxyConfig<ThemeConfig = DefaultTheme.Config>() {
/**
* alias for useSite
* @public
* @returns
*/
export function useConfig<ThemeConfig = DefaultTheme.Config>() {
return useValaxyConfig<ThemeConfig>()
@ -76,7 +73,6 @@ export function useConfig<ThemeConfig = DefaultTheme.Config>() {
/**
* get valaxy config
* @public
* @returns
*/
export function useSiteConfig<ThemeConfig = DefaultTheme.Config>() {
const config = useValaxyConfig<ThemeConfig>()
@ -88,7 +84,6 @@ export function useSiteConfig<ThemeConfig = DefaultTheme.Config>() {
* if you want to: import { useThemeConfig } from 'valaxy'
* you need pass themeConfig by yourself
* @internal
* @returns
*/
export function useThemeConfig<ThemeConfig = DefaultTheme.Config>() {
const config = useValaxyConfig<ThemeConfig>()

View File

@ -1,6 +1,5 @@
/**
* min max
* @returns
*/
export function random(min: number, max: number) {
return Math.random() * (max - min) + min

View File

@ -11,7 +11,6 @@ dayjs.extend(timezone)
* use dayjs format date
* @param date
* @param template
* @returns
*/
export function formatDate(date: string | number | Date, template = 'YYYY-MM-DD') {
const today = dayjs.tz(date)

View File

@ -1,6 +1,5 @@
/**
* wrap node
* @param className
*/
export function wrap(el: HTMLElement, className: string) {
const wrapper = document.createElement('div')

View File

@ -118,7 +118,8 @@ cli.command(
},
]
bindShortcut(SHORTCUTS)
})
},
)
cli.command(
'build [root]',
@ -185,6 +186,7 @@ cli.command(
}
catch (e) {
consola.error('[vite-ssg] An internal error occurred.')
// eslint-disable-next-line no-console
console.log(e)
}
}
@ -194,6 +196,7 @@ cli.command(
}
}
catch (e) {
// eslint-disable-next-line no-console
console.log(e)
}
finally {

View File

@ -15,7 +15,6 @@ import { commonOptions } from './options'
/**
* @description Generate Fuse List Data for Search
* @param options
* @returns
*/
export async function generateFuseList(options: ResolvedValaxyOptions) {
consola.start(`Generate List for Fuse Search by (${cyan('fuse.js')}) ...`)

View File

@ -33,12 +33,14 @@ export function registerNewCommand(cli: Argv<object>) {
})
.strict()
.help()
}, async ({ title, path, date, layout }) => {
},
async ({ title, path, date, layout }) => {
await create({
title,
date,
layout,
path,
} as CreatePostParams)
})
},
)
}

View File

@ -3,7 +3,6 @@ import type { Argv } from 'yargs'
/**
* set common options for cli
* @param args
* @returns
*/
export function commonOptions(args: Argv<object>) {
return args.positional('root', {

View File

@ -5,8 +5,8 @@ export async function exists(path: PathLike) {
try {
await access(path)
return true
// eslint-disable-next-line @typescript-eslint/brace-style
} catch (e) {
}
catch (e) {
return false
}
}

View File

@ -9,9 +9,6 @@ import { toAtFS } from './utils'
/**
* merge vite.config.ts (user & theme)
* @internal
* @param param
* @param command
* @returns
*/
export async function mergeViteConfigs({ userRoot, themeRoot }: ResolvedValaxyOptions, command: 'serve' | 'build') {
const configEnv: ConfigEnv = {
@ -39,8 +36,6 @@ export async function mergeViteConfigs({ userRoot, themeRoot }: ResolvedValaxyOp
/**
* generate index.html from user/theme/client
* @internal
* @param
* @returns
*/
export async function getIndexHtml({ clientRoot, themeRoot, userRoot, config }: ResolvedValaxyOptions): Promise<string> {
// get from template

View File

@ -9,7 +9,6 @@ export * from './addon'
/**
* Type helper for site.config.ts
* @param config
* @returns
*/
export function defineSiteConfig(config: UserSiteConfig) {
return config

View File

@ -5,8 +5,6 @@ import { loadConfigFromFile } from './utils'
/**
* resolve valaxy config from special root
* @param options
* @returns
*/
export async function resolveSiteConfigFromRoot(root: string) {
return loadConfigFromFile<UserSiteConfig>('site.config', {
@ -17,7 +15,6 @@ export async function resolveSiteConfigFromRoot(root: string) {
/**
* resolve site.config.ts and merge with default
* @param root
* @returns
*/
export async function resolveSiteConfig(root: string) {
const { config: userSiteConfig, configFile: siteConfigFile } = await resolveSiteConfigFromRoot(root)

View File

@ -5,8 +5,6 @@ import { loadConfigFromFile } from './utils'
/**
* resolve theme config from special root
* @param options
* @returns
*/
export async function resolveThemeConfigFromRoot(root: string) {
return loadConfigFromFile<UserSiteConfig>('theme.config', {
@ -16,8 +14,6 @@ export async function resolveThemeConfigFromRoot(root: string) {
/**
* resolve theme.config.ts and merge with default
* @param root
* @returns
*/
export async function resolveThemeConfig(root: string) {
const { config: userThemeConfig, configFile: themeConfigFile } = await resolveThemeConfigFromRoot(root)

View File

@ -59,9 +59,7 @@ export interface MarkdownCompileResult {
includes: string[]
}
function inferTitle(md: MarkdownRenderer,
frontmatter: Record<string, any>,
title: string) {
function inferTitle(md: MarkdownRenderer, frontmatter: Record<string, any>, title: string) {
if (typeof frontmatter.title === 'string') {
const titleToken = md.parseInline(frontmatter.title, {})[0]
if (titleToken) {
@ -74,8 +72,7 @@ function inferTitle(md: MarkdownRenderer,
return title
}
function getHeadMetaContent(head: HeadConfig[],
name: string): string | undefined {
function getHeadMetaContent(head: HeadConfig[], name: string): string | undefined {
if (!head || !head.length)
return undefined

View File

@ -116,8 +116,7 @@ export async function highlight(
return str
.replace(
preRE,
(_, attributes) =>
`<pre ${vPre}${attributes.replace(' tabindex="0"', '')}>`,
(_, attributes) => `<pre ${vPre}${attributes.replace(' tabindex="0"', '')}>`,
)
.replace(styleRE, (_, style) => _.replace(style, ''))
}

View File

@ -11,9 +11,7 @@ import type { MarkdownEnv } from '../env'
const indexRE = /(^|.*\/)index.md(#?.*)$/i
export function linkPlugin(md: MarkdownIt,
externalAttrs: Record<string, string>,
base: string) {
export function linkPlugin(md: MarkdownIt, externalAttrs: Record<string, string>, base: string) {
md.renderer.rules.link_open = (
tokens,
idx,

View File

@ -112,15 +112,13 @@ export function containerPlugin(md: MarkdownIt, options: Blocks = {}) {
// explicitly escape Vue syntax
md.use(container, 'v-pre', {
render: (tokens: Token[], idx: number) =>
tokens[idx].nesting === 1 ? '<div v-pre>\n' : '</div>\n',
render: (tokens: Token[], idx: number) => tokens[idx].nesting === 1 ? '<div v-pre>\n' : '</div>\n',
})
const languages = ['zh-CN', 'en']
languages.forEach((lang) => {
md.use(container, lang, {
render: (tokens: Token[], idx: number) =>
tokens[idx].nesting === 1 ? `<div lang="${lang}">\n` : '</div>\n',
render: (tokens: Token[], idx: number) => tokens[idx].nesting === 1 ? `<div lang="${lang}">\n` : '</div>\n',
})
})
}

View File

@ -24,12 +24,12 @@ export type ThemeOptions =
export interface MarkdownOptions {
/**
* markdown-it options
*/
* markdown-it options
*/
options?: MarkdownIt.Options
/**
* config markdown-it
*/
* config markdown-it
*/
config?: (md: MarkdownIt) => void
anchor?: anchorPlugin.AnchorOptions
attrs?: {

View File

@ -212,7 +212,6 @@ export async function resolveOptions(
/**
* resolve theme config
* @param options
* @returns
*/
export async function resolveThemeValaxyConfig(options: ResolvedValaxyOptions) {
logger.info(`Resolve ${cyan('valaxy.config.ts')} from ${yellow(`theme(${options.theme})`)}`)

View File

@ -15,7 +15,6 @@ import { presetStatistics } from './presets/statistics'
* get excerpt by type
* @param excerpt
* @param type
* @returns
*/
function getExcerptByType(excerpt = '', type: 'md' | 'html' | 'text' = 'html') {
switch (type) {
@ -31,7 +30,6 @@ function getExcerptByType(excerpt = '', type: 'md' | 'html' | 'text' = 'html') {
/**
* @see https://github.com/hannoeru/vite-plugin-pages
* @param options
* @returns
*/
export function createPagesPlugin(options: ResolvedValaxyOptions) {
const { roots, config: valaxyConfig } = options

View File

@ -19,20 +19,15 @@ export function count(content: string): CountData {
/**
* get read time by content & speed
* @param content
* @param param1
* @returns read time (minute)
*/
export function readTime({ cn, en }: CountData,
options: ReadTimeOptions) {
export function readTime({ cn, en }: CountData, options: ReadTimeOptions) {
const readingTime = cn / (options.speed.cn || 300) + en / (options.speed.en || 100)
return readingTime < 1 ? 1 : Math.ceil(readingTime)
}
/**
* return word count with k
* @param content
* @returns
*/
export function wordCount({ cn, en }: CountData) {
const num = cn + en

View File

@ -7,8 +7,6 @@ import { toAtFS } from '../utils'
/**
* setup client for defineAppSetup
* @param param
* @returns
*/
export function createClientSetupPlugin({ clientRoot, themeRoot, userRoot }: ResolvedValaxyOptions): PluginOption {
const setupEntry = slash(resolve(clientRoot, 'setup'))

View File

@ -8,7 +8,7 @@ import fs from 'fs-extra'
import type { Plugin, ResolvedConfig } from 'vite'
// import consola from 'consola'
import { pascalCase } from 'pascal-case'
import { pascalCase } from 'change-case/dist'
import { defu } from 'defu'
import { defaultSiteConfig } from '../config'
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
@ -23,7 +23,6 @@ import { resolveSiteConfig } from '../config/site'
/**
* for /@valaxyjs/styles
* @param roots
* @returns
*/
function generateStyles(roots: string[], options: ResolvedValaxyOptions) {
const imports: string[] = []
@ -98,7 +97,6 @@ const nullVue = 'import { defineComponent } from "vue"; export default defineCom
/**
* generate app vue from root/app.vue
* @param root
* @returns
*/
function generateAppVue(root: string) {
const appVue = join(root, 'App.vue')
@ -118,7 +116,6 @@ function generateAppVue(root: string) {
* @internal
* @param options
* @param serverOptions
* @returns
*/
export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions: ValaxyServerOptions = {}): Plugin {
let { config: valaxyConfig } = options
@ -231,7 +228,6 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
/**
* handle config hmr
* @param ctx
* @returns
*/
async handleHotUpdate(ctx) {
const { file, server, read } = ctx

View File

@ -22,7 +22,6 @@ const markdown = MarkdownIt({
/**
* generate rss
* @param options
* @returns
*/
export async function build(options: ResolvedValaxyOptions) {
const { config } = options

View File

@ -38,7 +38,6 @@ export async function parseAddons(addons: ValaxyAddons, userRoot = process.cwd()
* @internal
* @param name
* @param options
* @returns
*/
export async function readAddonModule(name: string, options: ReadAddonModuleOptions = {}) {
const root = getAddonRoot(name, options.cwd || process.cwd())
@ -66,7 +65,6 @@ export async function readAddonModule(name: string, options: ReadAddonModuleOpti
* get addon root
* @param name valaxy-addon-name
* @param entry
* @returns
*/
export function getAddonRoot(name: string, entry?: string) {
const addonModule = (name.startsWith('valaxy-addon') || name.startsWith('.')) ? name : `valaxy-addon-${name}`

View File

@ -1,3 +1,4 @@
/* eslint-disable no-console */
import * as readline from 'node:readline'
import path from 'node:path'
import os from 'node:os'

View File

@ -31,8 +31,6 @@ export const mergeValaxyConfig = createDefu((obj: any, key, value) => {
/**
* resolve valaxy config from special root
* @param options
* @returns
*/
export async function resolveValaxyConfigFromRoot(root: string, options?: ResolvedValaxyOptions) {
return loadConfigFromFile<ValaxyNodeConfig>('valaxy.config', {
@ -47,8 +45,6 @@ export async function resolveValaxyConfigFromRoot(root: string, options?: Resolv
* resolve user valaxy config
* options only have userRoot
* @param options
* @param viteConfig
* @returns
*/
export async function resolveValaxyConfig(options: ValaxyEntryOptions) {
// const resolved = await mergeValaxyConfig(options)

View File

@ -4,7 +4,6 @@ import { getGitTimestamp } from './getGitTimestamp'
/**
* get created time of file
* @param file
* @returns
*/
export async function getCreatedTime(file: string): Promise<Date | number> {
return (await getGitTimestamp(file, 'created')) || (await fs.stat(file)).ctime
@ -13,7 +12,6 @@ export async function getCreatedTime(file: string): Promise<Date | number> {
/**
* get created time of file
* @param file
* @returns
*/
export async function getUpdatedTime(file: string): Promise<Date | number> {
return (await getGitTimestamp(file, 'created')) || (await fs.stat(file)).mtime

View File

@ -3,7 +3,6 @@ import { webcrypto } from 'node:crypto'
/**
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/SubtleCrypto/deriveKey#pbkdf2_2
* @param password
* @returns
*/
export function getKeyMaterial(password: string) {
const enc = new TextEncoder()
@ -36,10 +35,7 @@ export function getKey(keyMaterial: CryptoKey, salt: Uint8Array) {
/**
* @see https://github.com/mdn/dom-examples/blob/main/web-crypto/encrypt-decrypt/aes-cbc.js
* @param password
* @param content
* @param iv
* @returns
*/
export async function encryptContent(content: string, options: {
password: string

View File

@ -3,7 +3,6 @@ import { EXTERNAL_URL_RE } from '../constants'
/**
* is url external (http/https:)
* @param str
* @returns
*/
export function isExternal(str: string) {
return EXTERNAL_URL_RE.test(str)
@ -12,7 +11,6 @@ export function isExternal(str: string) {
/**
* slash path for windows
* @param str
* @returns
*/
export function slash(str: string) {
return str.replace(/\\/g, '/')

View File

@ -12,7 +12,6 @@ export * from './config'
/**
* transform obj for vite code
* @param obj
* @returns
*/
export function transformObject(obj: any) {
return `JSON.parse(${JSON.stringify(JSON.stringify(obj))})`

View File

@ -6,7 +6,6 @@ import { isPath, resolveImportPath } from '../utils'
* get theme roots
* @param name
* @param entry
* @returns
*/
export function getModuleRoot(name: string, entry?: string) {
if (!name)

View File

@ -4,7 +4,6 @@ import { getModuleRoot } from './root'
* get theme roots
* @param name valaxy-theme-name
* @param entry
* @returns
*/
export function getThemeRoot(name: string, entry?: string) {
const themeModule = (name.startsWith('valaxy-theme') || name.startsWith('.')) ? name : `valaxy-theme-${name}`

View File

@ -42,10 +42,10 @@
"valaxy": "./bin/valaxy.cjs"
},
"files": [
"index.d.ts",
"bin",
"dist",
"client",
"dist",
"index.d.ts",
"types"
],
"engines": {
@ -54,7 +54,6 @@
"scripts": {
"build": "rimraf dist && tsup --splitting",
"dev": "tsup --splitting --watch",
"lint": "eslint .",
"preview": "vite preview",
"preview-https": "serve dist"
},
@ -63,19 +62,20 @@
"@ctrl/tinycolor": "^4.0.2",
"@iconify-json/carbon": "^1.1.21",
"@iconify-json/ri": "^1.1.12",
"@intlify/unplugin-vue-i18n": "^1.2.0",
"@intlify/unplugin-vue-i18n": "^1.4.0",
"@types/body-scroll-lock": "^3.1.0",
"@vitejs/plugin-vue": "^4.3.4",
"@vitejs/plugin-vue": "^4.4.0",
"@vueuse/core": "^10.4.1",
"@vueuse/head": "^2.0.0",
"@vueuse/integrations": "^10.4.1",
"@vueuse/schema-org": "^2.2.0",
"body-scroll-lock": "4.0.0-beta.0",
"change-case": "^5.0.1",
"consola": "^3.2.3",
"critters": "^0.0.20",
"cross-spawn": "^7.0.3",
"css-i18n": "^0.0.2",
"dayjs": "^1.11.9",
"dayjs": "^1.11.10",
"ejs": "^3.1.9",
"escape-html": "^1.0.3",
"feed": "^4.2.2",
@ -88,7 +88,7 @@
"katex": "^0.16.8",
"kolorist": "^1.8.0",
"lru-cache": "^10.0.1",
"markdown-it": "^13.0.1",
"markdown-it": "^13.0.2",
"markdown-it-anchor": "^8.6.7",
"markdown-it-attrs": "^4.1.6",
"markdown-it-container": "^3.0.0",
@ -98,40 +98,39 @@
"medium-zoom": "^1.0.8",
"nprogress": "^0.2.0",
"open": "8.4.2",
"pascal-case": "^3.1.2",
"pinia": "^2.1.6",
"sass": "^1.67.0",
"sass": "^1.68.0",
"shiki": "^0.14.4",
"star-markdown-css": "^0.4.2",
"unconfig": "^0.3.10",
"unocss": "^0.55.7",
"unconfig": "^0.3.11",
"unocss": "^0.56.4",
"unplugin-vue-components": "^0.25.2",
"vanilla-lazyload": "^17.8.4",
"vite": "^4.4.9",
"vite-plugin-pages": "^0.31.0",
"vite-plugin-vue-layouts": "^0.8.0",
"vite-ssg": "0.23.2",
"vite-ssg": "0.23.3",
"vite-ssg-sitemap": "0.5.1",
"vue": "^3.3.4",
"vue-i18n": "^9.4.1",
"vue-router": "^4.2.4",
"vue-i18n": "^9.5.0",
"vue-router": "^4.2.5",
"yargs": "^17.7.2"
},
"devDependencies": {
"@mdit-vue/plugin-component": "^0.12.1",
"@mdit-vue/plugin-frontmatter": "^0.12.1",
"@mdit-vue/plugin-headers": "^0.12.1",
"@mdit-vue/plugin-sfc": "^0.12.1",
"@mdit-vue/plugin-title": "^0.12.1",
"@mdit-vue/plugin-toc": "^0.12.1",
"@mdit-vue/shared": "^0.12.1",
"@mdit-vue/plugin-component": "^1.0.0",
"@mdit-vue/plugin-frontmatter": "^1.0.0",
"@mdit-vue/plugin-headers": "^1.0.0",
"@mdit-vue/plugin-sfc": "^1.0.0",
"@mdit-vue/plugin-title": "^1.0.0",
"@mdit-vue/plugin-toc": "^1.0.0",
"@mdit-vue/shared": "^1.0.0",
"@types/cross-spawn": "^6.0.3",
"@types/ejs": "^3.1.2",
"@types/html-to-text": "^9.0.1",
"@types/ejs": "^3.1.3",
"@types/html-to-text": "^9.0.2",
"@types/katex": "^0.16.3",
"@types/markdown-it": "^13.0.1",
"@types/nprogress": "^0.2.0",
"@types/yargs": "^17.0.24",
"@types/markdown-it": "^13.0.2",
"@types/nprogress": "^0.2.1",
"@types/yargs": "^17.0.26",
"debug": "^4.3.4",
"diacritics": "^1.3.0",
"https-localhost": "^4.7.1",

View File

@ -12,13 +12,15 @@ declare interface Window {
// markdowns can be treat as Vue components
declare module '*.md' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
const component: DefineComponent<object, object, any>
export default component
}
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
const component: DefineComponent<object, object, any>
export default component
}
@ -34,12 +36,13 @@ declare module '/@valaxyjs/context' {
}
declare module '/@valaxyjs/addons' {
import type { DefineComponent } from 'vue'
const components: { props: any, component: DefineComponent<{}, {}, any> }[]
const components: { props: any; component: DefineComponent<object, object, any> }[]
export default components
}
declare module '/@valaxyjs/locales' {
const messages: {}
const messages: object
export default messages
}

View File

@ -1,9 +1,9 @@
import type { ZoomOptions } from 'medium-zoom'
import type { FuseOptions } from '@vueuse/integrations/useFuse'
import type { ILazyLoadOptions } from 'vanilla-lazyload'
import type * as DefaultTheme from 'valaxy/default-theme'
import type { ValaxyAddon } from '../types'
import type { FuseListItem } from './node'
import type { DefaultTheme } from './default-theme'
export interface SocialLink {
/**

View File

@ -1,5 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace DefaultTheme {
declare module 'valaxy/default-theme' {
export interface Config {
/**
* Custom header levels of outline in the aside component.

View File

@ -1,4 +1,5 @@
// do not export node type here
export * from './addon'
export * from './config'
export * from './data'
@ -7,5 +8,4 @@ export * from './posts'
// used in node, but without node deps
export * from './node'
// theme
export * from './default-theme'
export type * as DefaultTheme from 'valaxy/default-theme'

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,11 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"types": [
"vitest",
"vite/client",
"vue/ref-macros",
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client",
"@intlify/unplugin-vue-i18n/messages"
],
"baseUrl": ".",
"paths": {
"~/*": ["demo/yun/*"],
"valaxy/client/*": ["packages/valaxy/client/*"],
@ -30,7 +14,23 @@
"valaxy": ["packages/valaxy/shim.ts"],
"valaxy-theme-yun/*": ["packages/valaxy-theme-yun/*"],
"valaxy-theme-yun": ["packages/valaxy-theme-yun/node/index.ts"]
}
},
"types": [
"vitest",
"vite/client",
"vue/ref-macros",
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client",
"@intlify/unplugin-vue-i18n/messages"
],
"resolveJsonModule": true,
"allowJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"include": [
"./*.ts",