Skip to content

Commit

Permalink
Merge branch 'main' into siteLocaleData
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Apr 11, 2024
2 parents 5701209 + d837efc commit 1774670
Show file tree
Hide file tree
Showing 20 changed files with 501 additions and 436 deletions.
13 changes: 7 additions & 6 deletions .commitlintrc.cjs → commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const fs = require('fs')
const path = require('path')
import * as fs from 'node:fs'
import * as path from 'node:path'
import type { UserConfig } from '@commitlint/types'

const getSubDirectories = (dir) =>
const getSubDirectories = (dir: string): string[] =>
fs
.readdirSync(dir)
.filter((item) => fs.statSync(path.join(dir, item)).isDirectory())
const packages = getSubDirectories(path.resolve(__dirname, 'packages'))

module.exports = {
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [2, 'always', packages],
'scope-enum': [2, 'always', [...packages, 'e2e']],
'footer-max-line-length': [0],
},
}
} satisfies UserConfig
16 changes: 16 additions & 0 deletions e2e/docs/router/navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<button id="home" @click="goHome">Home</button>
<button id="404" @click="go404">404</button>

<script setup lang="ts">
import { useRouter } from 'vuepress/client';

const router = useRouter();

const goHome = () => {
router.push('/?home=true');
}

const go404 = () => {
router.push('/404.html#404');
}
</script>
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"@vuepress-e2e/conditional-exports": "file:./modules/conditional-exports",
"@vuepress/bundler-vite": "workspace:*",
"@vuepress/bundler-webpack": "workspace:*",
"sass": "^1.72.0",
"sass": "^1.74.1",
"sass-loader": "^14.1.1",
"vue": "^3.4.21",
"vuepress": "workspace:*"
},
"devDependencies": {
"anywhere": "^1.6.0",
"cross-env": "^7.0.3",
"cypress": "^13.7.1",
"cypress": "^13.7.2",
"process": "^0.11.10",
"start-server-and-test": "^2.0.3"
}
Expand Down
21 changes: 21 additions & 0 deletions e2e/tests/router/navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
it('should preserve query', () => {
const E2E_BASE = Cypress.env('E2E_BASE')

cy.visit('/router/navigation.html')

cy.get('#home').click()

cy.location('pathname').should('eq', E2E_BASE)
cy.location('search').should('eq', '?home=true')
})

it('should preserve hash', () => {
const E2E_BASE = Cypress.env('E2E_BASE')

cy.visit('/router/navigation.html')

cy.get('#404').click()

cy.location('pathname').should('eq', `${E2E_BASE}404.html`)
cy.location('hash').should('eq', '#404')
})
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@types/node": "^20.11.30",
"@commitlint/types": "^19.0.3",
"@types/node": "^20.12.5",
"@types/webpack-env": "^1.18.4",
"@vitest/coverage-istanbul": "^1.4.0",
"bumpp": "^9.4.0",
Expand All @@ -46,14 +47,14 @@
"prettier": "^3.2.5",
"prettier-config-vuepress": "^4.4.0",
"rimraf": "^5.0.5",
"sort-package-json": "^2.8.0",
"sort-package-json": "^2.10.0",
"tsconfig-vuepress": "^4.5.0",
"tsup": "^8.0.2",
"typescript": "^5.4.3",
"vite": "~5.2.2",
"typescript": "^5.4.4",
"vite": "~5.2.8",
"vitest": "^1.4.0"
},
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@8.15.6",
"engines": {
"node": ">=18.16.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"connect-history-api-fallback": "^2.0.0",
"postcss": "^8.4.38",
"postcss-load-config": "^5.0.3",
"rollup": "^4.13.0",
"vite": "~5.2.2",
"rollup": "^4.14.1",
"vite": "~5.2.8",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-vite/src/plugins/vuepressMainPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const resolveDefine = async ({
// enable options API by default
__VUE_OPTIONS_API__: JSON.stringify(true),
__VUE_PROD_DEVTOOLS__: JSON.stringify(app.env.isDebug),
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false),
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(app.env.isDebug),
}

// override vite built-in define config in debug mode
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"autoprefixer": "^10.4.19",
"chokidar": "^3.6.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^6.10.0",
"css-loader": "^7.0.0",
"esbuild-loader": "~4.1.0",
"express": "^4.19.1",
"express": "^4.19.2",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.8.1",
"postcss": "^8.4.38",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/config/handlePluginDefine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const handlePluginDefine = async ({
// enable options API by default
__VUE_OPTIONS_API__: JSON.stringify(true),
__VUE_PROD_DEVTOOLS__: JSON.stringify(app.env.isDebug),
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false),
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(app.env.isDebug),
},
])

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@vuepress/utils": "workspace:*",
"cac": "^6.7.14",
"chokidar": "^3.6.0",
"envinfo": "^7.11.1",
"envinfo": "^7.12.0",
"esbuild": "~0.20.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/router/createVueRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export const createVueRouter = (): Router => {
// and save page data to route meta
router.beforeResolve(async (to, from): Promise<string | void> => {
if (to.path !== from.path || from === START_LOCATION) {
const route = resolveRoute(to.path)
const route = resolveRoute(to.fullPath)

if (route.path !== to.path) {
if (route.path !== to.fullPath) {
return route.path
}
const pageChunk = await route.loader()
Expand Down
20 changes: 10 additions & 10 deletions packages/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
"clean": "rimraf dist"
},
"dependencies": {
"@mdit-vue/plugin-component": "^2.0.0",
"@mdit-vue/plugin-frontmatter": "^2.0.0",
"@mdit-vue/plugin-headers": "^2.0.0",
"@mdit-vue/plugin-sfc": "^2.0.0",
"@mdit-vue/plugin-title": "^2.0.0",
"@mdit-vue/plugin-toc": "^2.0.0",
"@mdit-vue/shared": "^2.0.0",
"@mdit-vue/types": "^2.0.0",
"@types/markdown-it": "^13.0.7",
"@types/markdown-it-emoji": "^2.0.4",
"@mdit-vue/plugin-component": "^2.1.0",
"@mdit-vue/plugin-frontmatter": "^2.1.0",
"@mdit-vue/plugin-headers": "^2.1.0",
"@mdit-vue/plugin-sfc": "^2.1.0",
"@mdit-vue/plugin-title": "^2.1.0",
"@mdit-vue/plugin-toc": "^2.1.0",
"@mdit-vue/shared": "^2.1.0",
"@mdit-vue/types": "^2.1.0",
"@types/markdown-it": "^14.0.0",
"@types/markdown-it-emoji": "^2.0.5",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"markdown-it": "^14.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/src/plugins/assetsPlugin/assetsPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PluginWithOptions } from 'markdown-it'
import type { RenderRule } from 'markdown-it/lib/renderer.js'
import type { RenderRule } from 'markdown-it/lib/renderer.mjs'
import type { MarkdownEnv } from '../../types.js'
import { resolveLink } from './resolveLink.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type HighlightLinesRange = [number, number]
export type HighlightLinesRange = [start: number, end: number]

/**
* Resolve highlight-lines ranges from token info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from '@vuepress/utils'
import type { RuleBlock } from 'markdown-it/lib/parser_block.js'
import type ParserBlock from 'markdown-it/lib/parser_block.mjs'
import type { ImportCodePluginOptions } from './importCodePlugin.js'
import type { ImportCodeTokenMeta } from './types.js'

Expand All @@ -13,7 +13,9 @@ const START_CODES = [64, 91, 99, 111, 100, 101]
const SYNTAX_RE = /^@\[code(?:{(?:(\d+)?-(\d+)?)})?(?: ([^\]]+))?\]\(([^)]*)\)/

export const createImportCodeBlockRule =
({ handleImportPath = (str) => str }: ImportCodePluginOptions): RuleBlock =>
({
handleImportPath = (str) => str,
}: ImportCodePluginOptions): ParserBlock.RuleBlock =>
(state, startLine, endLine, silent): boolean => {
// if it's indented more than 3 spaces, it should be a code block
/* istanbul ignore if */
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/src/plugins/linksPlugin/linksPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isLinkExternal, normalizeRoutePath } from '@vuepress/shared'
import type { PluginWithOptions } from 'markdown-it'
import type Token from 'markdown-it/lib/token.js'
import type Token from 'markdown-it/lib/token.mjs'
import type { MarkdownEnv } from '../../types.js'
import { resolvePaths } from './resolvePaths.js'

Expand Down
3 changes: 2 additions & 1 deletion packages/markdown/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { MarkdownSfcBlocks } from '@mdit-vue/plugin-sfc'
import type { MarkdownItEnv } from '@mdit-vue/types'
import type { PageFrontmatter, PageHeader } from '@vuepress/shared'
import type MarkdownIt from 'markdown-it'
import type { Options } from 'markdown-it'
import type {
AnchorPluginOptions,
AssetsPluginOptions,
Expand All @@ -18,7 +19,7 @@ import type {
export type Markdown = MarkdownIt
export type { MarkdownSfcBlocks }

export interface MarkdownOptions extends MarkdownIt.Options {
export interface MarkdownOptions extends Options {
anchor?: false | AnchorPluginOptions
assets?: false | AssetsPluginOptions
code?: false | CodePluginOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"clean": "rimraf dist"
},
"dependencies": {
"@mdit-vue/types": "^2.0.0"
"@mdit-vue/types": "^2.1.0"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 1774670

Please sign in to comment.