Skip to content

Commit

Permalink
Merge branch 'main' into normalizeRoutePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed May 11, 2024
2 parents 62af79c + bab6ae9 commit de56943
Show file tree
Hide file tree
Showing 16 changed files with 5,748 additions and 4,428 deletions.
8 changes: 4 additions & 4 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"@vuepress-e2e/conditional-exports": "file:./modules/conditional-exports",
"@vuepress/bundler-vite": "workspace:*",
"@vuepress/bundler-webpack": "workspace:*",
"sass": "^1.74.1",
"sass-loader": "^14.1.1",
"vue": "^3.4.21",
"sass": "^1.75.0",
"sass-loader": "^14.2.1",
"vue": "^3.4.23",
"vuepress": "workspace:*"
},
"devDependencies": {
"@playwright/test": "^1.43.0",
"@playwright/test": "^1.43.1",
"anywhere": "^1.6.0",
"cross-env": "^7.0.3"
}
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
},
"prettier": "prettier-config-vuepress",
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@commitlint/cli": "^19.2.2",
"@commitlint/config-conventional": "^19.2.2",
"@commitlint/types": "^19.0.3",
"@types/node": "^20.12.5",
"@types/node": "^20.12.7",
"@types/webpack-env": "^1.18.4",
"@vitest/coverage-istanbul": "^1.4.0",
"@vitest/coverage-istanbul": "^1.5.0",
"bumpp": "^9.4.0",
"conventional-changelog-cli": "^4.1.0",
"eslint": "^8.57.0",
Expand All @@ -49,11 +49,11 @@
"sort-package-json": "^2.10.0",
"tsconfig-vuepress": "^4.5.0",
"tsup": "^8.0.2",
"typescript": "^5.4.4",
"vite": "~5.2.8",
"vitest": "^1.4.0"
"typescript": "^5.4.5",
"vite": "~5.2.10",
"vitest": "^1.5.0"
},
"packageManager": "pnpm@8.15.6",
"packageManager": "pnpm@9.0.4",
"engines": {
"node": ">=18.16.0"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/bundler-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"connect-history-api-fallback": "^2.0.0",
"postcss": "^8.4.38",
"postcss-load-config": "^5.0.3",
"rollup": "^4.14.1",
"vite": "~5.2.8",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
"rollup": "^4.16.0",
"vite": "~5.2.10",
"vue": "^3.4.23",
"vue-router": "^4.3.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 2 additions & 0 deletions packages/bundler-vite/src/plugins/vuepressMainPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ import 'vuepress/client-app'
host: app.options.host,
port: app.options.port,
open: app.options.open,
// ref: https://github.com/vitejs/vite/issues/15784#issuecomment-1923683823
fs: { cachedChecks: false },
},
build: {
ssr: isServer,
Expand Down
10 changes: 5 additions & 5 deletions packages/bundler-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@
"autoprefixer": "^10.4.19",
"chokidar": "^3.6.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.0.0",
"css-loader": "^7.1.1",
"esbuild-loader": "~4.1.0",
"express": "^4.19.2",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.8.1",
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.38",
"postcss-csso": "^6.0.1",
"postcss-loader": "^8.1.1",
"style-loader": "^3.3.4",
"vue": "^3.4.21",
"style-loader": "^4.0.0",
"vue": "^3.4.23",
"vue-loader": "^17.4.2",
"vue-router": "^4.3.0",
"vue-router": "^4.3.2",
"webpack": "^5.91.0",
"webpack-chain": "^6.5.1",
"webpack-dev-server": "^5.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"dependencies": {
"@vue/devtools-api": "^6.6.1",
"@vuepress/shared": "workspace:*",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
"vue": "^3.4.23",
"vue-router": "^4.3.2"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@vuepress/markdown": "workspace:*",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"vue": "^3.4.21"
"vue": "^3.4.23"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/page/resolvePageChunkInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path, sanitizeFileName } from '@vuepress/utils'
import { path, transformPathToFileName } from '@vuepress/utils'
import type { App } from '../types/index.js'

/**
Expand All @@ -17,7 +17,7 @@ export const resolvePageChunkInfo = ({
} => {
const chunkFilePathRelative = path.join('pages', `${htmlFilePathRelative}.js`)
const chunkFilePath = app.dir.temp(chunkFilePathRelative)
const chunkName = sanitizeFileName(path.basename(htmlFilePathRelative))
const chunkName = transformPathToFileName(htmlFilePathRelative)

return {
chunkFilePath,
Expand Down
36 changes: 13 additions & 23 deletions packages/core/src/page/resolvePagePermalink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ export const resolvePagePermalink = ({
pathInferred: string | null
pathLocale: string
}): string | null => {
// use permalink in frontmatter directly
// frontmatter.permalink has the highest priority
if (frontmatter.permalink === null) {
return null
}
if (isString(frontmatter.permalink)) {
return frontmatter.permalink
}

// get permalink pattern
const permalinkPattern = getPermalinkPattern({ app, frontmatter })
if (permalinkPattern === null) {
// frontmatter.permalinkPattern has higher priority than app.options.permalinkPattern
if (frontmatter.permalinkPattern === null) {
return null
}

const permalinkPattern =
frontmatter.permalinkPattern || app.options.permalinkPattern

if (!isString(permalinkPattern)) {
return null
}

Expand All @@ -45,22 +54,3 @@ export const resolvePagePermalink = ({

return ensureLeadingSlash(link)
}

/**
* Get permalink pattern from frontmatter or app options
*/
const getPermalinkPattern = ({
app,
frontmatter,
}: {
app: App
frontmatter: PageFrontmatter
}): string | null => {
if (frontmatter.permalinkPattern === null) {
return null
}
if (isString(frontmatter.permalinkPattern)) {
return frontmatter.permalinkPattern
}
return app.options.permalinkPattern
}
15 changes: 15 additions & 0 deletions packages/core/tests/page/resolvePagePermalink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ describe('core > page > resolvePagePermalink', () => {
expect(resolved).toBe('/frontmatter')
})

it('should return null', () => {
const resolved = resolvePagePermalink({
app: appWithPermalinkPattern,
frontmatter: {
permalink: null,
},
slug: '',
date: '',
pathInferred: '/inferred',
pathLocale: '',
})

expect(resolved).toBe(null)
})

it('should use permalinkPattern in frontmatter', () => {
const resolved = resolvePagePermalink({
app,
Expand Down
16 changes: 8 additions & 8 deletions packages/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"clean": "rimraf dist"
},
"dependencies": {
"@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/plugin-component": "^2.1.2",
"@mdit-vue/plugin-frontmatter": "^2.1.2",
"@mdit-vue/plugin-headers": "^2.1.2",
"@mdit-vue/plugin-sfc": "^2.1.2",
"@mdit-vue/plugin-title": "^2.1.2",
"@mdit-vue/plugin-toc": "^2.1.2",
"@mdit-vue/shared": "^2.1.2",
"@mdit-vue/types": "^2.1.0",
"@types/markdown-it": "^14.0.0",
"@types/markdown-it": "^14.0.1",
"@types/markdown-it-emoji": "^2.0.5",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/types/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type PageFrontmatter<
head?: HeadConfig[]
lang?: string
layout?: string
permalink?: string
permalink?: string | null
permalinkPattern?: string | null
routeMeta?: Record<string, unknown>
title?: string
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './getDirname.js'
export * from './importFile.js'
export * from './isChildPath.js'
export * from './sanitizeFileName.js'
export * from './transformPathToFileName.js'
7 changes: 7 additions & 0 deletions packages/utils/src/module/transformPathToFileName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { sanitizeFileName } from './sanitizeFileName.js'

/**
* Transforms a path to a file name, replacing slashes with underscores
*/
export const transformPathToFileName = (rawPath: string): string =>
sanitizeFileName(rawPath.replace(/\//g, '_'))
2 changes: 1 addition & 1 deletion packages/vuepress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@vuepress/markdown": "workspace:*",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"vue": "^3.4.21"
"vue": "^3.4.23"
},
"peerDependencies": {
"@vuepress/bundler-vite": "workspace:*",
Expand Down
Loading

0 comments on commit de56943

Please sign in to comment.