diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 80632ee45618..9898a3c57d78 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -54,7 +54,7 @@ jobs:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
- name: Install Playwright
- # does not need to explictly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
+ # does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium
- name: Build
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4caec9c59091..9c8773f9671c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,21 @@
+# [1.0.0-alpha.9](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2022-08-20)
+
+
+### Bug Fixes
+
+* **theme:** fix typo in carbon ads components ([#1192](https://github.com/vuejs/vitepress/issues/1192)) ([e0932ce](https://github.com/vuejs/vitepress/commit/e0932ce5f49535fb28c6b6e4d17b888dd09187dc))
+* **theme:** show footer message/copyright only if present ([#1191](https://github.com/vuejs/vitepress/issues/1191)) ([da2f8d2](https://github.com/vuejs/vitepress/commit/da2f8d28a6993b099a97b01ab2ff94104e84190c))
+* **theme:** show outline even without sidebar ([#1189](https://github.com/vuejs/vitepress/issues/1189)) ([3714ea3](https://github.com/vuejs/vitepress/commit/3714ea34635e69aa96de3da5f3cbc5b6198fdbc2))
+* **types:** explicitly re-export to resolve ambiguities ([#1193](https://github.com/vuejs/vitepress/issues/1193)) ([eacc18c](https://github.com/vuejs/vitepress/commit/eacc18c993cefa2922c13826c1d0498a9eafc4d1))
+* use junctions in Windows ([#1217](https://github.com/vuejs/vitepress/issues/1217)) ([0e14211](https://github.com/vuejs/vitepress/commit/0e14211b609c4694c7654ce381998ce751230480))
+
+
+### Features
+
+* **theme:** extend titleTemplate by replacing the title ([#1200](https://github.com/vuejs/vitepress/issues/1200)) ([c7def73](https://github.com/vuejs/vitepress/commit/c7def730c3d9266e7573b91e16e00dd2f3f3350b))
+
+
+
# [1.0.0-alpha.8](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-08-17)
diff --git a/docs/config/app-configs.md b/docs/config/app-configs.md
index b3d243c4b754..1875e4fc6d77 100644
--- a/docs/config/app-configs.md
+++ b/docs/config/app-configs.md
@@ -148,10 +148,8 @@ interface MarkdownOptions extends MarkdownIt.Options {
lineNumbers?: boolean
// markdown-it-anchor plugin options.
- // See: https://github.com/valeriangalliat/markdown-it-anchor
- anchor?: {
- permalink?: anchor.AnchorOptions['permalink']
- }
+ // See: https://github.com/valeriangalliat/markdown-it-anchor#usage
+ anchor?: anchorPlugin.AnchorOptions
// markdown-it-attrs plugin options.
// See: https://github.com/arve0/markdown-it-attrs
@@ -162,9 +160,9 @@ interface MarkdownOptions extends MarkdownIt.Options {
disable?: boolean
}
- // markdown-it-toc-done-right plugin options
- // See: https://github.com/nagaozen/markdown-it-toc-done-right
- toc?: any
+ // @mdit-vue/plugin-toc plugin options.
+ // See: https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
+ toc?: TocPluginOptions
// Configure the Markdown-it instance.
config?: (md: MarkdownIt) => void
diff --git a/docs/config/frontmatter-configs.md b/docs/config/frontmatter-configs.md
index 59fc9d1dbd44..96cc84891de6 100644
--- a/docs/config/frontmatter-configs.md
+++ b/docs/config/frontmatter-configs.md
@@ -31,7 +31,7 @@ title: VitePress
- Type: `string | boolean`
-The suffix for the title. It's same as [config.titleTemplate](../config/app-configs#titleTemplate), and it overrides the app config.
+The suffix for the title. It's same as [config.titleTemplate](../config/app-configs#titletemplate), and it overrides the app config.
```yaml
---
diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md
index b86366fdb984..67f0fac79f53 100644
--- a/docs/guide/markdown.md
+++ b/docs/guide/markdown.md
@@ -435,12 +435,13 @@ const anchor = require('markdown-it-anchor')
module.exports = {
markdown: {
// options for markdown-it-anchor
- // https://github.com/valeriangalliat/markdown-it-anchor#permalinks
+ // https://github.com/valeriangalliat/markdown-it-anchor#usage
anchor: {
permalink: anchor.permalink.headerLink()
},
- // options for markdown-it-toc-done-right
+ // options for @mdit-vue/plugin-toc
+ // https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
toc: { level: [1, 2] },
config: (md) => {
diff --git a/docs/guide/migration-from-vuepress.md b/docs/guide/migration-from-vuepress.md
index e646ae545c04..01e4c170d4ce 100644
--- a/docs/guide/migration-from-vuepress.md
+++ b/docs/guide/migration-from-vuepress.md
@@ -1,5 +1,11 @@
# Migration from VuePress
+## Config
+
+### Sidebar
+
+The sidebar is no longer automatically populated from frontmatter. You can [read the frontmatter yourself](https://github.com/vuejs/vitepress/issues/572#issuecomment-1170116225) to dynamically populate the sidebar. [Additional utilities for this](https://github.com/vuejs/vitepress/issues/96) may be provided in the future.
+
## Markdown
### Images
diff --git a/examples/minimal/__test__/content.spec.ts b/examples/minimal/__test__/content.spec.ts
index 317018723e09..f0bb4fc19e23 100644
--- a/examples/minimal/__test__/content.spec.ts
+++ b/examples/minimal/__test__/content.spec.ts
@@ -7,9 +7,9 @@ describe('render corrent content', () => {
})
test('main content', async () => {
- const h1Locator = await page.locator('h1')
- const h2Locator = await page.locator('h2')
- const pLocator = await page.locator('.Layout p')
+ const h1Locator = page.locator('h1')
+ const h2Locator = page.locator('h2')
+ const pLocator = page.locator('.Layout p')
const [h1Contents, h2Conetents, pContents] = await Promise.all([
h1Locator.allTextContents(),
@@ -28,11 +28,11 @@ describe('render corrent content', () => {
})
test('outline', async () => {
- const outlineLinksLocator = await page.locator(
+ const outlineLinksLocator = page.locator(
'.VPDocAsideOutline .root .outline-link'
)
const outlineLinksCount = await outlineLinksLocator.count()
- expect(outlineLinksCount).toEqual(0)
+ expect(outlineLinksCount).toEqual(4)
})
})
diff --git a/package.json b/package.json
index a846a46c276d..4aaa783ca5a5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vitepress",
- "version": "1.0.0-alpha.8",
+ "version": "1.0.0-alpha.9",
"description": "Vite & Vue powered static site generator",
"type": "module",
"packageManager": "pnpm@7.9.0",
@@ -92,6 +92,8 @@
"vue": "^3.2.37"
},
"devDependencies": {
+ "@mdit-vue/plugin-component": "^0.9.2",
+ "@mdit-vue/plugin-toc": "^0.9.2",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
@@ -135,7 +137,6 @@
"markdown-it-attrs": "^4.1.4",
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.2",
- "markdown-it-toc-done-right": "^4.2.0",
"micromatch": "^4.0.5",
"minimist": "^1.2.6",
"npm-run-all": "^4.1.5",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3c89b63edc2c..85e3e402b8b6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -6,6 +6,8 @@ importers:
specifiers:
'@docsearch/css': ^3.2.1
'@docsearch/js': ^3.2.1
+ '@mdit-vue/plugin-component': ^0.9.2
+ '@mdit-vue/plugin-toc': ^0.9.2
'@rollup/plugin-alias': ^3.1.9
'@rollup/plugin-commonjs': ^22.0.2
'@rollup/plugin-json': ^4.1.0
@@ -53,7 +55,6 @@ importers:
markdown-it-attrs: ^4.1.4
markdown-it-container: ^3.0.0
markdown-it-emoji: ^2.0.2
- markdown-it-toc-done-right: ^4.2.0
micromatch: ^4.0.5
minimist: ^1.2.6
npm-run-all: ^4.1.5
@@ -88,6 +89,8 @@ importers:
vite: 3.0.8
vue: 3.2.37
devDependencies:
+ '@mdit-vue/plugin-component': 0.9.2
+ '@mdit-vue/plugin-toc': 0.9.2
'@rollup/plugin-alias': 3.1.9_rollup@2.78.0
'@rollup/plugin-commonjs': 22.0.2_rollup@2.78.0
'@rollup/plugin-json': 4.1.0_rollup@2.78.0
@@ -131,7 +134,6 @@ importers:
markdown-it-attrs: 4.1.4_markdown-it@13.0.1
markdown-it-container: 3.0.0
markdown-it-emoji: 2.0.2
- markdown-it-toc-done-right: 4.2.0
micromatch: 4.0.5
minimist: 1.2.6
npm-run-all: 4.1.5
@@ -392,6 +394,34 @@ packages:
engines: {node: '>=6.9.0'}
dev: true
+ /@mdit-vue/plugin-component/0.9.2:
+ resolution: {integrity: sha512-sTi9SWiakUGUs330zNRfEYSzGAVAXJ7gjbg46e/4HJQXxC8uEBC+Xg6IgsYcTRGHuJpCP65pcHvCLeDoCdWpyQ==}
+ dependencies:
+ '@types/markdown-it': 12.2.3
+ markdown-it: 13.0.1
+ dev: true
+
+ /@mdit-vue/plugin-toc/0.9.2:
+ resolution: {integrity: sha512-Du3fFz+YezlXex9Syn+bc8ADDRx/kBfBokeHXfd/qCW5XqS7I4THLR/IRqlvi9CgIZ0dx7bJv0avxil9EX1PoQ==}
+ dependencies:
+ '@mdit-vue/shared': 0.9.2
+ '@mdit-vue/types': 0.9.2
+ '@types/markdown-it': 12.2.3
+ markdown-it: 13.0.1
+ dev: true
+
+ /@mdit-vue/shared/0.9.2:
+ resolution: {integrity: sha512-05Nk/o+kJCgeAa7oBGJOIazJq+6n0+VR4jPhzV3LGc9TyuMEqnrH5XzmBoy45vzyyoe7pGxJ/PBDxq4HebQHtQ==}
+ dependencies:
+ '@mdit-vue/types': 0.9.2
+ '@types/markdown-it': 12.2.3
+ markdown-it: 13.0.1
+ dev: true
+
+ /@mdit-vue/types/0.9.2:
+ resolution: {integrity: sha512-SuoxzZHS2/9bEqeJ+bjj2xBLjoZhRo6Ww/GVqNZS2ji9rkoM2teA0kbwSmj0X6Kf00K9HnLs6T0dtDtqpBqEHA==}
+ dev: true
+
/@nodelib/fs.scandir/2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -2728,10 +2758,6 @@ packages:
resolution: {integrity: sha512-zLftSaNrKuYl0kR5zm4gxXjHaOI3FAOEaloKmRA5hijmJZvSjmxcokOLlzycb/HXlUFWzXqpIEoyEMCE4i9MvQ==}
dev: true
- /markdown-it-toc-done-right/4.2.0:
- resolution: {integrity: sha512-UB/IbzjWazwTlNAX0pvWNlJS8NKsOQ4syrXZQ/C72j+jirrsjVRT627lCaylrKJFBQWfRsPmIVQie8x38DEhAQ==}
- dev: true
-
/markdown-it/13.0.1:
resolution: {integrity: sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==}
hasBin: true
diff --git a/src/client/theme-default/components/VPDoc.vue b/src/client/theme-default/components/VPDoc.vue
index f8979a5e5a28..7b29fd37a0fb 100644
--- a/src/client/theme-default/components/VPDoc.vue
+++ b/src/client/theme-default/components/VPDoc.vue
@@ -73,10 +73,6 @@ const pageName = computed(() =>
max-width: 992px;
}
- .VPDoc:not(.has-sidebar) .aside {
- display: block;
- }
-
.VPDoc:not(.has-sidebar) .content {
max-width: 752px;
}
diff --git a/src/client/theme-default/components/VPDocAsideCarbonAds.vue b/src/client/theme-default/components/VPDocAsideCarbonAds.vue
index 061a94d8b98f..c5e9f1ddbcd8 100644
--- a/src/client/theme-default/components/VPDocAsideCarbonAds.vue
+++ b/src/client/theme-default/components/VPDocAsideCarbonAds.vue
@@ -1,7 +1,7 @@
diff --git a/src/client/theme-default/components/VPFooter.vue b/src/client/theme-default/components/VPFooter.vue
index 9452ddd8bda8..381b82e89c35 100644
--- a/src/client/theme-default/components/VPFooter.vue
+++ b/src/client/theme-default/components/VPFooter.vue
@@ -9,8 +9,8 @@ const { hasSidebar } = useSidebar()
diff --git a/src/client/theme-default/composables/sidebar.ts b/src/client/theme-default/composables/sidebar.ts
index 414c5558f3b1..7cb1b05509fd 100644
--- a/src/client/theme-default/composables/sidebar.ts
+++ b/src/client/theme-default/composables/sidebar.ts
@@ -23,13 +23,9 @@ export function useSidebar() {
})
const hasAside = computed(() => {
- if (
- frontmatter.value.layout !== 'home' &&
- frontmatter.value.aside === false
+ return (
+ frontmatter.value.layout !== 'home' && frontmatter.value.aside !== false
)
- return false
-
- return hasSidebar.value
})
function open() {
diff --git a/src/node/build/build.ts b/src/node/build/build.ts
index 7f5d9b9fb2cc..3de81d06c727 100644
--- a/src/node/build/build.ts
+++ b/src/node/build/build.ts
@@ -109,7 +109,7 @@ function linkVue(root: string) {
// if user did not install vue by themselves, link VitePress' version
if (!fs.existsSync(dest)) {
const src = path.dirname(createRequire(import.meta.url).resolve('vue'))
- fs.ensureSymlinkSync(src, dest)
+ fs.ensureSymlinkSync(src, dest, 'junction')
return () => {
fs.unlinkSync(dest)
}
diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts
index 4b43918d8c81..c3bf51a7b4ee 100644
--- a/src/node/markdown/markdown.ts
+++ b/src/node/markdown/markdown.ts
@@ -1,11 +1,14 @@
import MarkdownIt from 'markdown-it'
+import anchorPlugin from 'markdown-it-anchor'
+import attrsPlugin from 'markdown-it-attrs'
+import emojiPlugin from 'markdown-it-emoji'
+import { componentPlugin } from '@mdit-vue/plugin-component'
+import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc'
import { IThemeRegistration } from 'shiki'
-import { parseHeader } from '../utils/parseHeader'
import { highlight } from './plugins/highlight'
import { slugify } from './plugins/slugify'
import { highlightLinePlugin } from './plugins/highlightLines'
import { lineNumberPlugin } from './plugins/lineNumbers'
-import { componentPlugin } from './plugins/component'
import { containerPlugin } from './plugins/containers'
import { snippetPlugin } from './plugins/snippet'
import { hoistPlugin } from './plugins/hoist'
@@ -14,10 +17,6 @@ import { linkPlugin } from './plugins/link'
import { headingPlugin } from './plugins/headings'
import { imagePlugin } from './plugins/image'
import { Header } from '../shared'
-import anchor from 'markdown-it-anchor'
-import attrs from 'markdown-it-attrs'
-import emoji from 'markdown-it-emoji'
-import toc from 'markdown-it-toc-done-right'
export type ThemeOptions =
| IThemeRegistration
@@ -26,9 +25,7 @@ export type ThemeOptions =
export interface MarkdownOptions extends MarkdownIt.Options {
lineNumbers?: boolean
config?: (md: MarkdownIt) => void
- anchor?: {
- permalink?: anchor.AnchorOptions['permalink']
- }
+ anchor?: anchorPlugin.AnchorOptions
attrs?: {
leftDelimiter?: string
rightDelimiter?: string
@@ -36,8 +33,7 @@ export interface MarkdownOptions extends MarkdownIt.Options {
disable?: boolean
}
theme?: ThemeOptions
- // https://github.com/nagaozen/markdown-it-toc-done-right
- toc?: any
+ toc?: TocPluginOptions
externalLinks?: Record
}
@@ -88,23 +84,19 @@ export const createMarkdownRenderer = async (
// 3rd party plugins
if (!options.attrs?.disable) {
- md.use(attrs, options.attrs)
+ md.use(attrsPlugin, options.attrs)
}
- md.use(anchor, {
+ md.use(anchorPlugin, {
slugify,
- permalink: anchor.permalink.ariaHidden({}),
+ permalink: anchorPlugin.permalink.ariaHidden({}),
...options.anchor
- })
- .use(toc, {
+ } as anchorPlugin.AnchorOptions)
+ .use(tocPlugin, {
slugify,
- level: [2, 3],
- format: (x: string, htmlencode: (s: string) => string) =>
- htmlencode(parseHeader(x)),
- listType: 'ul',
...options.toc
- })
- .use(emoji)
+ } as TocPluginOptions)
+ .use(emojiPlugin)
// apply user config
if (options.config) {
diff --git a/src/node/markdown/plugins/component.ts b/src/node/markdown/plugins/component.ts
deleted file mode 100644
index 6ca6b463a2dd..000000000000
--- a/src/node/markdown/plugins/component.ts
+++ /dev/null
@@ -1,202 +0,0 @@
-import MarkdownIt from 'markdown-it'
-import { RuleBlock } from 'markdown-it/lib/parser_block'
-import blockNames from 'markdown-it/lib/common/html_blocks'
-import { HTML_OPEN_CLOSE_TAG_RE } from 'markdown-it/lib/common/html_re'
-
-/**
- * Vue reserved tags
- *
- * @see https://vuejs.org/api/built-in-components.html
- */
-const vueReservedTags = [
- 'template',
- 'component',
- 'transition',
- 'transition-group',
- 'keep-alive',
- 'slot',
- 'teleport'
-]
-
-/**
- * According to markdown spec, all non-block html tags are treated as "inline"
- * tags (wrapped with ), including those "unknown" tags.
- *
- * Therefore, markdown-it processes "inline" tags and "unknown" tags in the
- * same way, and does not care if a tag is "inline" or "unknown".
- *
- * As we want to take those "unknown" tags as custom components, we should
- * treat them as "block" tags.
- *
- * So we have to distinguish between "inline" and "unknown" tags ourselves.
- *
- * The inline tags list comes from MDN.
- *
- * @see https://spec.commonmark.org/0.29/#raw-html
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
- */
-const inlineTags = [
- 'a',
- 'abbr',
- 'acronym',
- 'audio',
- 'b',
- 'bdi',
- 'bdo',
- 'big',
- 'br',
- 'button',
- 'canvas',
- 'cite',
- 'code',
- 'data',
- 'datalist',
- 'del',
- 'dfn',
- 'em',
- 'embed',
- 'i',
- // iframe is treated as HTML blocks in markdown spec
- // 'iframe',
- 'img',
- 'input',
- 'ins',
- 'kbd',
- 'label',
- 'map',
- 'mark',
- 'meter',
- 'noscript',
- 'object',
- 'output',
- 'picture',
- 'progress',
- 'q',
- 'ruby',
- 's',
- 'samp',
- 'script',
- 'select',
- 'slot',
- 'small',
- 'span',
- 'strong',
- 'sub',
- 'sup',
- 'svg',
- 'template',
- 'textarea',
- 'time',
- 'u',
- 'tt',
- 'var',
- 'video',
- 'wbr'
-]
-
-// replacing the default htmlBlock rule to allow using custom components at
-// root level
-//
-// an array of opening and corresponding closing sequences for html tags,
-// last argument defines whether it can terminate a paragraph or not
-const HTML_SEQUENCES: [RegExp, RegExp, boolean][] = [
- [/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true],
- [/^/, true],
- [/^<\?/, /\?>/, true],
- [/^/, true],
- [/^/, true],
-
- // MODIFIED HERE: treat vue reserved tags as block tags
- [
- new RegExp('^?(' + vueReservedTags.join('|') + ')(?=(\\s|/?>|$))', 'i'),
- /^$/,
- true
- ],
-
- // MODIFIED HERE: treat unknown tags as block tags (custom components),
- // excluding known inline tags
- [
- new RegExp(
- '^?(?!(' + inlineTags.join('|') + ')(?![\\w-]))\\w[\\w-]*[\\s/>]'
- ),
- /^$/,
- true
- ],
-
- [
- new RegExp('^?(' + blockNames.join('|') + ')(?=(\\s|/?>|$))', 'i'),
- /^$/,
- true
- ],
- [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false]
-]
-
-export const componentPlugin = (md: MarkdownIt) => {
- md.block.ruler.at('html_block', htmlBlock)
-}
-
-const htmlBlock: RuleBlock = (state, startLine, endLine, silent): boolean => {
- let i, nextLine, lineText
- let pos = state.bMarks[startLine] + state.tShift[startLine]
- let max = state.eMarks[startLine]
-
- // if it's indented more than 3 spaces, it should be a code block
- if (state.sCount[startLine] - state.blkIndent >= 4) {
- return false
- }
-
- if (!state.md.options.html) {
- return false
- }
-
- if (state.src.charCodeAt(pos) !== 0x3c /* < */) {
- return false
- }
-
- lineText = state.src.slice(pos, max)
-
- for (i = 0; i < HTML_SEQUENCES.length; i++) {
- if (HTML_SEQUENCES[i][0].test(lineText)) {
- break
- }
- }
-
- if (i === HTML_SEQUENCES.length) {
- return false
- }
-
- if (silent) {
- // true if this sequence can be a terminator, false otherwise
- return HTML_SEQUENCES[i][2]
- }
-
- nextLine = startLine + 1
-
- // if we are here - we detected HTML block. let's roll down till block end
- if (!HTML_SEQUENCES[i][1].test(lineText)) {
- for (; nextLine < endLine; nextLine++) {
- if (state.sCount[nextLine] < state.blkIndent) {
- break
- }
-
- pos = state.bMarks[nextLine] + state.tShift[nextLine]
- max = state.eMarks[nextLine]
- lineText = state.src.slice(pos, max)
-
- if (HTML_SEQUENCES[i][1].test(lineText)) {
- if (lineText.length !== 0) {
- nextLine++
- }
- break
- }
- }
- }
-
- state.line = nextLine
-
- const token = state.push('html_block', '', 0)
- token.map = [startLine, nextLine]
- token.content = state.getLines(startLine, nextLine, state.blkIndent, true)
-
- return true
-}
diff --git a/src/node/staticDataPlugin.ts b/src/node/staticDataPlugin.ts
index e61118252a11..9a49192bb801 100644
--- a/src/node/staticDataPlugin.ts
+++ b/src/node/staticDataPlugin.ts
@@ -1,5 +1,3 @@
-// TODO figure out why it causes full page reload
-
import { Plugin, ViteDevServer, loadConfigFromFile, normalizePath } from 'vite'
import { dirname, resolve } from 'path'
import { isMatch } from 'micromatch'
@@ -113,9 +111,6 @@ export const staticDataPlugin: Plugin = {
// invalidate loader file
delete idToLoaderModulesMap[id]
}
- if (pattern) {
- console.log(pattern, isMatch(ctx.file, pattern))
- }
if (isLoaderFile || (pattern && isMatch(ctx.file, pattern))) {
ctx.modules.push(server.moduleGraph.getModuleById(id)!)
}
diff --git a/src/shared/shared.ts b/src/shared/shared.ts
index 71c167cabce3..2bb1637db847 100644
--- a/src/shared/shared.ts
+++ b/src/shared/shared.ts
@@ -104,6 +104,11 @@ export function resolveSiteDataByRoute(
export function createTitle(siteData: SiteData, pageData: PageData): string {
const title = pageData.title || siteData.title
const template = pageData.titleTemplate ?? siteData.titleTemplate
+
+ if (typeof template === 'string' && template.includes(':title')) {
+ return template.replace(/:title/g, title)
+ }
+
const templateString = createTitleTemplate(siteData.title, template)
return `${title}${templateString}`
diff --git a/types/index.d.ts b/types/index.d.ts
index 8fe4969a563f..b466f16f7bea 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,2 +1,35 @@
-export * from '../dist/node/index.js'
-export * from '../dist/client/index.js'
+export * from './shared.js'
+
+export {
+ Content,
+ EnhanceAppContext,
+ Route,
+ Router,
+ Theme,
+ VitePressData,
+ inBrowser,
+ useData,
+ useRoute,
+ useRouter,
+ withBase
+} from '../dist/client/index.js'
+
+export {
+ MarkdownOptions,
+ MarkdownParsedData,
+ MarkdownRenderer,
+ RawConfigExports,
+ ServeOptions,
+ SiteConfig,
+ ThemeOptions,
+ UserConfig,
+ build,
+ createMarkdownRenderer,
+ createServer,
+ defineConfig,
+ defineConfigWithTheme,
+ resolveConfig,
+ resolveSiteData,
+ resolveSiteDataByRoute,
+ serve
+} from '../dist/node/index.js'