pull/4525/head
Divyansh Singh 7 months ago
parent 22118c6f0b
commit c61800b341

@ -1,8 +1,9 @@
import paths from './paths'
export default { export default {
async paths() { async paths(watchedFiles: string[]) {
return [ console.log('watchedFiles', watchedFiles)
{ params: { id: 'foo' }, content: `# Foo` }, return paths
{ params: { id: 'bar' }, content: `# Bar` } },
] watch: ['**/data-loading/**/*.json']
}
} }

@ -0,0 +1,4 @@
export default [
{ params: { id: 'foo' }, content: `# Foo` },
{ params: { id: 'bar' }, content: `# Bar` }
]

@ -11,7 +11,7 @@ import fs from 'fs-extra'
import template from 'lodash.template' import template from 'lodash.template'
import path from 'node:path' import path from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
import { bold, cyan, yellow } from 'picocolors' import c from 'picocolors'
import { slash } from '../shared' import { slash } from '../shared'
export enum ScaffoldThemeType { export enum ScaffoldThemeType {
@ -38,7 +38,7 @@ const getPackageManger = () => {
} }
export async function init(root?: string) { export async function init(root?: string) {
intro(bold(cyan('Welcome to VitePress!'))) intro(c.bold(c.cyan('Welcome to VitePress!')))
const options = await group( const options = await group(
{ {
@ -232,7 +232,7 @@ export function scaffold({
const gitignorePrefix = root ? `${slash(root)}/.vitepress` : '.vitepress' const gitignorePrefix = root ? `${slash(root)}/.vitepress` : '.vitepress'
if (fs.existsSync('.git')) { if (fs.existsSync('.git')) {
tips.push( tips.push(
`Make sure to add ${cyan(`${gitignorePrefix}/dist`)} and ${cyan(`${gitignorePrefix}/cache`)} to your ${cyan(`.gitignore`)} file.` `Make sure to add ${c.cyan(`${gitignorePrefix}/dist`)} and ${c.cyan(`${gitignorePrefix}/cache`)} to your ${c.cyan(`.gitignore`)} file.`
) )
} }
@ -242,11 +242,11 @@ export function scaffold({
!userPkg.devDependencies?.['vue'] !userPkg.devDependencies?.['vue']
) { ) {
tips.push( tips.push(
`Since you've chosen to customize the theme, you should also explicitly install ${cyan(`vue`)} as a dev dependency.` `Since you've chosen to customize the theme, you should also explicitly install ${c.cyan(`vue`)} as a dev dependency.`
) )
} }
const tip = tips.length ? yellow([`\n\nTips:`, ...tips].join('\n- ')) : `` const tip = tips.length ? c.yellow([`\n\nTips:`, ...tips].join('\n- ')) : ``
const dir = root ? ' ' + root : '' const dir = root ? ' ' + root : ''
const pm = getPackageManger() const pm = getPackageManger()
@ -261,8 +261,8 @@ export function scaffold({
Object.assign(userPkg.scripts || (userPkg.scripts = {}), scripts) Object.assign(userPkg.scripts || (userPkg.scripts = {}), scripts)
fs.writeFileSync(pkgPath, JSON.stringify(userPkg, null, 2)) fs.writeFileSync(pkgPath, JSON.stringify(userPkg, null, 2))
return `Done! Now run ${cyan(`${pm} run ${prefix}dev`)} and start writing.${tip}` return `Done! Now run ${c.cyan(`${pm} run ${prefix}dev`)} and start writing.${tip}`
} else { } else {
return `You're all set! Now run ${cyan(`${pm === 'npm' ? 'npx' : pm} vitepress dev${dir}`)} and start writing.${tip}` return `You're all set! Now run ${c.cyan(`${pm === 'npm' ? 'npx' : pm} vitepress dev${dir}`)} and start writing.${tip}`
} }
} }

@ -51,7 +51,7 @@ function getResolutionCache(siteConfig: SiteConfig) {
__pages = siteConfig.pages.map((p) => slash(p.replace(/\.md$/, ''))) __pages = siteConfig.pages.map((p) => slash(p.replace(/\.md$/, '')))
__dynamicRoutes = new Map( __dynamicRoutes = new Map(
siteConfig.dynamicRoutes.routes.map((r) => [ siteConfig.dynamicRoutes.map((r) => [
r.fullPath, r.fullPath,
slash(path.join(siteConfig.srcDir, r.route)) slash(path.join(siteConfig.srcDir, r.route))
]) ])

@ -221,9 +221,7 @@ export interface SiteConfig<ThemeConfig = any>
cacheDir: string cacheDir: string
tempDir: string tempDir: string
pages: string[] pages: string[]
dynamicRoutes: { dynamicRoutes: ResolvedRouteConfig[]
routes: ResolvedRouteConfig[]
}
rewrites: { rewrites: {
map: Record<string, string | undefined> map: Record<string, string | undefined>
inv: Record<string, string | undefined> inv: Record<string, string | undefined>

Loading…
Cancel
Save