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

@ -1,8 +1,9 @@
import paths from './paths'
export default {
async paths() {
return [
{ params: { id: 'foo' }, content: `# Foo` },
{ params: { id: 'bar' }, content: `# Bar` }
]
}
async paths(watchedFiles: string[]) {
console.log('watchedFiles', watchedFiles)
return paths
},
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 path from 'node:path'
import { fileURLToPath } from 'node:url'
import { bold, cyan, yellow } from 'picocolors'
import c from 'picocolors'
import { slash } from '../shared'
export enum ScaffoldThemeType {
@ -38,7 +38,7 @@ const getPackageManger = () => {
}
export async function init(root?: string) {
intro(bold(cyan('Welcome to VitePress!')))
intro(c.bold(c.cyan('Welcome to VitePress!')))
const options = await group(
{
@ -232,7 +232,7 @@ export function scaffold({
const gitignorePrefix = root ? `${slash(root)}/.vitepress` : '.vitepress'
if (fs.existsSync('.git')) {
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']
) {
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 pm = getPackageManger()
@ -261,8 +261,8 @@ export function scaffold({
Object.assign(userPkg.scripts || (userPkg.scripts = {}), scripts)
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 {
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$/, '')))
__dynamicRoutes = new Map(
siteConfig.dynamicRoutes.routes.map((r) => [
siteConfig.dynamicRoutes.map((r) => [
r.fullPath,
slash(path.join(siteConfig.srcDir, r.route))
])

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

Loading…
Cancel
Save