chore: lint & upgrade fuse to esm

This commit is contained in:
YunYouJun 2023-12-12 22:43:29 +08:00
parent 2591897acc
commit eb0c54543c
36 changed files with 948 additions and 843 deletions

12
demo/yun/.gitignore vendored
View File

@ -31,3 +31,15 @@ public/valaxy-fuse-list.json
# valaxy
public/valaxy-fuse-list.json
# valaxy
public/valaxy-fuse-list.json
# valaxy
public/valaxy-fuse-list.json
# valaxy
public/valaxy-fuse-list.json
# valaxy
public/valaxy-fuse-list.json

View File

@ -1,18 +1,19 @@
[build.environment]
# bypass npm auto install
NPM_FLAGS = "--version"
NODE_VERSION = "16"
[build]
publish = "dist"
command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
publish = "dist"
command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
[build.environment]
# bypass npm auto install
NPM_FLAGS = "--version"
NODE_VERSION = "16"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
from = "/*"
to = "/index.html"
status = 200
[[headers]]
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"

View File

@ -31,9 +31,7 @@ categories: Test
<!-- valaxy-encrypt-end -->
```md
<!-- valaxy-encrypt-start:valaxy -->
This should not be encrypted.
<!-- valaxy-encrypt-end -->
```
```

View File

@ -9,8 +9,8 @@ tags:
新的一年即将到来。
> 但是……很不幸,时间的流逝永远不会停止。
时光如箭,你的过去在不停增多,你的未来在不断减少,未知的可能性只会越来越少,而无法改变的后悔在累积如山。
> 但是……很不幸,时间的流逝永远不会停止。
时光如箭,你的过去在不停增多,你的未来在不断减少,未知的可能性只会越来越少,而无法改变的后悔在累积如山。
你明白了吗?
中文测试

View File

@ -5,10 +5,8 @@ categories:
- addon
end: false
---
## 开始编写
::: tip

View File

@ -42,7 +42,7 @@ export interface ValaxyExtendConfig {
markdown?: MarkdownOptions
extendMd?: (ctx: {
route: {
meta: { frontmatter: Record<string, any>; layout?: string } & object
meta: { frontmatter: Record<string, any>, layout?: string } & object
path: string
component: string
}

View File

@ -461,12 +461,10 @@ codeHeightLimit: 300
Example can refer to [Code Height Limit](/examples/code-height-limit).
:::
### 内容加密 {lang="zh-CN"}
### Content Encryption {lang="en"}
::: zh-CN
首先在 `site.config.ts` 中开启加密
:::

View File

@ -55,12 +55,10 @@ npm run build
> `gh-pages` 已由 `.github/workflows/gh-pages.yml` 自动部署。
> 注意修改 `gh-pages.yml` 中的 `on.push.branches` 为你源代码所在的分支,默认为 `main`
:::
::: en
When you use `pnpm create valaxy` to create a template project, it contains the file [`.github/workflows/gh-pages.yml`](https://github.com/YunYouJun/valaxy/blob/main/packages/create-valaxy/template-blog/.github/workflows/gh-pages.yml) for the CI workflow of GitHub Actions.

View File

@ -12,7 +12,7 @@ top: 98
:::
::: en
First, I'll introduce you to some easy
First, I'll introduce you to some easy
:::
## 热更新 {lang="zh-CN"}

View File

@ -120,12 +120,12 @@ If you are a Windows user, I strongly recommend using a Unix-like shell (such as
</div>
::: zh-CN
> 由于 `npm init` 会缓存您此前下载的版本,我更推荐您使用 `pnpm` 来创建模版。
> 由于 `npm init` 会缓存您此前下载的版本,我更推荐您使用 `pnpm` 来创建模版。
> 安装 [pnpm](https://pnpm.io/)`npm i -g pnpm`
:::
::: en
> Since `npm init` caches your previously downloaded version, I would recommend using `pnpm` to create templates.
> Since `npm init` caches your previously downloaded version, I would recommend using `pnpm` to create templates.
> Install [pnpm](https://pnpm.io/)`npm i -g pnpm`
:::
@ -148,14 +148,14 @@ npm init valaxy
::: zh-CN
跟随命令行提示完成创建!
> 默认使用主题 [valaxy-theme-yun](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-yun/),当然您也可以安装使用任意其他主题。
> 默认使用主题 [valaxy-theme-yun](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-yun/),当然您也可以安装使用任意其他主题。
> 本文档同样是一个 Valaxy 主题 [valaxy-theme-press](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-press/),它的灵感来自 [VitePress](https://vitepress.dev/)。
:::
::: en
Follow the prompt in the commandline to complete the process!
> The default theme used is [valaxy-theme-yun](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-yun/), but you can also install any other themes.
> The default theme used is [valaxy-theme-yun](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-yun/), but you can also install any other themes.
> This documentation is also a Valaxy theme: [valaxy-theme-press](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-theme-press/). It is inspired by [VitePress](https://vitepress.dev/).
:::

View File

@ -252,7 +252,6 @@ You can also specify the language inside the braces (`{}`) like this:
This is helpful if source language cannot be inferred from your file extension.
## Code Groups
You can group multiple code blocks like this:
@ -341,7 +340,6 @@ You can also [import snippets](#import-code-snippets) in code groups:
:::
## Container
::: zh-CN

View File

@ -55,7 +55,6 @@ hide: true
- `true` / `all`: When set to `true` or `all`, the article will be rendered, and you can view it by visiting the link directly. It will not be displayed in article cards or archives.
- `index`: When set to `index`, it will be hidden only in the front page. It will still be displayed in archives. (You can use this for some notes unnecessary for the front page, but good for the archive for reference sometimes)
:::
## 摘要 {lang="zh-CN"}

View File

@ -1,5 +1,5 @@
---
title: Use Vite/Vue Plugin
title: Use Vite/Vue Plugin
title_zh-CN: 使用 Vite/Vue 插件
categories:
- third

View File

@ -46,14 +46,14 @@ The relationship between Hexo blog directory and Valaxy blog directory is shown
::: zh-CN
参考 [Valaxy 配置文档](/guide/config/) 将 Hexo `_config.yml` 配置文件中的内容,迁移至 `valaxy.config.ts` 文件中。
> 配置示例:[demo/yun/valaxy.config.ts](https://github.com/YunYouJun/valaxy/blob/main/demo/yun/valaxy.config.ts)、[yunyoujun.github.io/valaxy.config.ts](https://github.com/YunYouJun/yunyoujun.github.io/blob/valaxy/valaxy.config.ts)
> 配置示例:[demo/yun/valaxy.config.ts](https://github.com/YunYouJun/valaxy/blob/main/demo/yun/valaxy.config.ts)、[yunyoujun.github.io/valaxy.config.ts](https://github.com/YunYouJun/yunyoujun.github.io/blob/valaxy/valaxy.config.ts)
> `valaxy.config.ts` 提供了完备的类型提示,这意味着你在 VSCode 中可以直接鼠标悬浮查看各参数注释。
:::
::: en
Refer to [Valaxy Config](/guide/config/) to migrate configurations from Hexo's `_config.yml` to Valaxy's `valaxy.config.ts`.
> Examples of configuration: [demo/yun/valaxy.config.ts](https://github.com/YunYouJun/valaxy/blob/main/demo/yun/valaxy.config.ts), [yunyoujun.github.io/valaxy.config.ts](https://github.com/YunYouJun/yunyoujun.github.io/blob/valaxy/valaxy.config.ts).
> Examples of configuration: [demo/yun/valaxy.config.ts](https://github.com/YunYouJun/valaxy/blob/main/demo/yun/valaxy.config.ts), [yunyoujun.github.io/valaxy.config.ts](https://github.com/YunYouJun/yunyoujun.github.io/blob/valaxy/valaxy.config.ts).
> `valaxy.config.ts` provides a complete type prompt, which means that you can hover on configuration fields directly to view the comments in VSCode.
:::

View File

@ -31,7 +31,7 @@ You can click this button to toggle locales.
> 此外还可使用 [crowdin](https://crowdin.com/) 平台辅助用户进行多语言翻译。
但对于博客来说,这显然都很麻烦。
当你需要 i18n 时,你不得不同时维护多个目录下的文章。
当你需要 i18n 时,你不得不同时维护多个目录下的文章。
当文章间存在相同的示例时,你还需要维护相同的内容。非常不优雅。
Valaxy 中,
@ -55,7 +55,7 @@ Common i18n schemes are maintained separately using different paths (e.g. `/zh-C
> In addition, the [crowdin](https://crowdin.com/) platform can be used to assist users with multilingual translations.
But for blogs, this is obviously all a hassle.
When you need i18n, you have to maintain articles in multiple directories at the same time.
When you need i18n, you have to maintain articles in multiple directories at the same time.
You also have to maintain the same content when the same examples exist between articles.
Very inelegant.
@ -291,7 +291,7 @@ app.use(i18n)
::: zh-CN
文章部分拥有大段的文本,而 `vue-i18n` 的场景则在于一些独立的字段翻译。
而传统的分文件独立管理的方式,对于博客来说其实并不方便。
而传统的分文件独立管理的方式,对于博客来说其实并不方便。
大多数情况,你并不会想专门建立一个文件夹来管理它。
因此我尝试使用纯 CSS 解决该问题。
@ -300,7 +300,7 @@ app.use(i18n)
::: en
While the article section has large sections of text, the scenario of `vue-i18n` lies in some separate field translations.
And the traditional way of managing them independently in separate files is not really convenient for blogs.
And the traditional way of managing them independently in separate files is not really convenient for blogs.
In most cases, you don't want to create a dedicated folder to manage it.
So I tried to solve the problem using pure CSS.
@ -309,7 +309,7 @@ So I tried to solve the problem using pure CSS.
<div lang="zh-CN">
::: tip 思路
即借助 CSS 规则,根据对应语言,显示对应区块内容。
即借助 CSS 规则,根据对应语言,显示对应区块内容。
大体方案:通过 [markdown-it-container](https://github.com/markdown-it/markdown-it-container) 设置 fence 预编译 Markdown
为需要进行 i18n 的段落包裹新的 `<div lang="zh-CN"></div>`,并使用 CSS 默认隐藏它们。
当页面初始化或切换语言时,为 html 添加对应语言类,编写对应 CSS 以在该类下显示对应语言的区块。
@ -320,7 +320,7 @@ So I tried to solve the problem using pure CSS.
<div lang="en">
::: tip IDEA
That is, with the help of CSS rules, the content of the corresponding block is displayed according to the corresponding language.
That is, with the help of CSS rules, the content of the corresponding block is displayed according to the corresponding language.
The general solution: set fence to pre-compile Markdown via [markdown-it-container](https://github.com/markdown-it/markdown-it-container).
Wrap new `<div lang="zh-CN"></div>`s for the paragraphs that need to be i18n and hide them by default with CSS.
When the page initializes or switches languages, add the corresponding language class to html and write the corresponding CSS to display the corresponding language block under that class.

View File

@ -130,7 +130,7 @@ export interface ValaxyConfig {
pages?: Parameters<typeof Pages>[0]
extendMd?: (ctx: {
route: {
meta: { frontmatter?: Record<string, any>; layout?: string }
meta: { frontmatter?: Record<string, any>, layout?: string }
path: string
component: string
}
@ -409,7 +409,7 @@ import valaxyLogoPng from '../assets/images/valaxy-logo.png'
Valaxy 决定通过插件中心化地提供各类封装好的评论组件和辅助函数。
譬如主题开发者,可以借助 `valaxy-addon-waline` 来快速实现 [Waline](https://waline.js.org/) 评论系统的集成。
譬如主题开发者,可以借助 `valaxy-addon-waline` 来快速实现 [Waline](https://waline.js.org/) 评论系统的集成。
而用户则可以使用相同的配置穿梭漫游于不同的主题之间。
> 集成参见 [valaxy-addon-waline](https://github.com/YunYouJun/valaxy/blob/main/packages/valaxy-addon-waline/README.md)。

View File

@ -8,4 +8,9 @@ export default antfu({
'packages/valaxy/index.d.ts',
'packages/valaxy/client.d.ts',
],
}, {
files: ['**/*.md'],
rules: {
'style/no-trailing-spaces': 'off',
},
})

View File

@ -1,19 +1,20 @@
[build.environment]
# bypass npm auto install
NPM_FLAGS = "--version"
NODE_VERSION = "16"
PLAYWRIGHT_BROWSERS_PATH = "0"
[build]
publish = "demo/yun/dist"
command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm build && npx pnpm run build:demo"
publish = "demo/yun/dist"
command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm build && npx pnpm run build:demo"
[build.environment]
# bypass npm auto install
NPM_FLAGS = "--version"
NODE_VERSION = "16"
PLAYWRIGHT_BROWSERS_PATH = "0"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
from = "/*"
to = "/index.html"
status = 200
[[headers]]
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"

View File

@ -7,7 +7,7 @@ Starter template generator for [valaxy](https://github.com/YunYouJun/valaxy).
## Usage
```bash
npm init valaxy
npm init valaxy
```
or

View File

@ -1,16 +1,17 @@
[build.environment]
NODE_VERSION = "16"
[build]
publish = "dist"
command = "npm run build"
publish = "dist"
command = "npm run build"
[build.environment]
NODE_VERSION = "16"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
from = "/*"
to = "/index.html"
status = 200
[[headers]]
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"

View File

@ -70,7 +70,7 @@ function initialize(userOptions: AlgoliaSearchOptions) {
})
})
},
hitComponent({ hit, children }: { hit: DocSearchHit; children: any }) {
hitComponent({ hit, children }: { hit: DocSearchHit, children: any }) {
const relativeHit = hit.url.startsWith('http')
? getRelativePath(hit.url as string)
: hit.url

View File

@ -72,7 +72,7 @@ export interface SearchOptions {
aroundLatLng?: string
aroundLatLngViaIP?: boolean
aroundRadius?: number | 'all'
aroundPrecision?: number | { from: number; value: number }[]
aroundPrecision?: number | { from: number, value: number }[]
minimumAroundRadius?: number
insideBoundingBox?: number[][]
insidePolygon?: number[][]

View File

@ -32,7 +32,7 @@ export namespace PressTheme {
export type Sidebar = SidebarItem[] | SidebarMulti
export interface SidebarMulti {
[path: string]: SidebarItem[] | { items: SidebarItem[]; base: string }
[path: string]: SidebarItem[] | { items: SidebarItem[], base: string }
}
export interface SidebarItem {
/**

View File

@ -44,13 +44,13 @@ onContentUpdated(() => {
// only intercept inbound links
if (
!e.ctrlKey
&& !e.shiftKey
&& !e.altKey
&& !e.metaKey
&& target !== '_blank'
&& protocol === currentUrl.protocol
&& hostname === currentUrl.hostname
&& !(extMatch && extMatch[0] !== '.html')
&& !e.shiftKey
&& !e.altKey
&& !e.metaKey
&& target !== '_blank'
&& protocol === currentUrl.protocol
&& hostname === currentUrl.hostname
&& !(extMatch && extMatch[0] !== '.html')
) {
if (pathname === currentUrl.pathname) {
e.preventDefault()

View File

@ -49,7 +49,7 @@ function onError(e: Event) {
</div>
</template>
<stye lang="scss" scoped>
<style lang="scss" scoped>
.link-item {
display: inline-flex;
}
@ -117,4 +117,4 @@ function onError(e: Event) {
justify-content: center;
}
}
</stye>
</style>

View File

@ -5,7 +5,7 @@ import 'valaxy/client/styles/common/view-transition.css'
export const isDark = useDark()
export const toggleDark = useToggle(isDark)
export function toggleDarkWithTransition(event: MouseEvent, options: { duration?: number; easing?: EffectTiming['easing'] } = {}) {
export function toggleDarkWithTransition(event: MouseEvent, options: { duration?: number, easing?: EffectTiming['easing'] } = {}) {
// @ts-expect-error startViewTransition is not defined
if (!document.startViewTransition) {
toggleDark()

View File

@ -3,4 +3,3 @@ layout: <%=layout%>
title: <%=title%>
date: <%=date%>
---

View File

@ -219,8 +219,8 @@ export async function createMarkdownToVueRenderFn(
)
: (
pages.includes(resolved)
|| fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`))
|| fs.existsSync(path.resolve(dir, publicDir, `${resolved}/index.html`))
|| fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`))
|| fs.existsSync(path.resolve(dir, publicDir, `${resolved}/index.html`))
)
)
)
@ -402,7 +402,7 @@ function injectPageDataCode(
tags[existingScriptIndex] = tagSrc.replace(
scriptRE,
`${code
+ (hasDefaultExport
+ (hasDefaultExport
? ''
: `\n${exportScript}`)
}</script>`,

View File

@ -26,7 +26,7 @@ function isValidDelim(state: any, pos: number) {
// Check non-whitespace conditions for opening and closing, and
// check that closing delimeter isn't followed by a number
if (prevChar === 0x20/* " " */ || prevChar === 0x09
||/* \t */ (nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */))
||/* \t */ (nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */))
can_close = false
if (nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */)
@ -157,8 +157,8 @@ function math_block(state: any, start: number, end: number, silent: boolean) {
const token = state.push('math_block', 'math', 0)
token.block = true
token.content = ((firstLine && firstLine.trim()) ? `${firstLine}\n` : '')
+ state.getLines(start + 1, next, state.tShift[start], true)
+ ((lastLine && lastLine.trim()) ? lastLine : '')
+ state.getLines(start + 1, next, state.tShift[start], true)
+ ((lastLine && lastLine.trim()) ? lastLine : '')
token.map = [start, state.line]
token.markup = '$$'
return true

View File

@ -20,7 +20,7 @@ import type { Blocks } from './plugins/markdown-it/container'
export type ThemeOptions =
| IThemeRegistration
| { light: IThemeRegistration; dark: IThemeRegistration }
| { light: IThemeRegistration, dark: IThemeRegistration }
export interface MarkdownOptions {
/**

View File

@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs'
import type { SiteConfig } from 'valaxy/types'
import type { ValaxyExtendConfig } from '../../types'
export interface CountData { cn: number; en: number }
export interface CountData { cn: number, en: number }
export type ReadTimeOptions = SiteConfig['statistics']['readTime']
/**

View File

@ -78,7 +78,7 @@ export interface ValaxyExtendConfig {
markdown?: MarkdownOptions
extendMd?: (ctx: {
route: {
meta: { frontmatter: Record<string, any>; layout?: string } & object
meta: { frontmatter: Record<string, any>, layout?: string } & object
path: string
component: string
}

View File

@ -104,7 +104,7 @@ export async function initServer(options: ResolvedValaxyOptions, viteConfig: Inl
/**
* bind shortcut for terminal
*/
export function bindShortcut(SHORTCUTS: { name: string; fullName: string; action: () => void }[]) {
export function bindShortcut(SHORTCUTS: { name: string, fullName: string, action: () => void }[]) {
process.stdin.resume()
process.stdin.setEncoding('utf8')
readline.emitKeypressEvents(process.stdin)

View File

@ -81,7 +81,7 @@
"escape-html": "^1.0.3",
"feed": "^4.2.2",
"fs-extra": "^11.2.0",
"fuse.js": "^6.6.2",
"fuse.js": "^7.0.0",
"gray-matter": "^4.0.3",
"hookable": "^5.5.3",
"html-to-text": "^9.0.5",

View File

@ -37,7 +37,7 @@ declare module '/@valaxyjs/context' {
declare module '/@valaxyjs/addons' {
import type { DefineComponent } from 'vue'
const components: { props: any; component: DefineComponent<object, object, any> }[]
const components: { props: any, component: DefineComponent<object, object, any> }[]
export default components
}

File diff suppressed because it is too large Load Diff