Skip to content

Commit cb74b7e

Browse files
authored
Revert "feat(cli): support custom srcDir (#4270)"
This reverts commit 518c094.
1 parent 518c094 commit cb74b7e

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

src/node/init/init.ts

+2-19
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export enum ScaffoldThemeType {
2121

2222
export interface ScaffoldOptions {
2323
root: string
24-
srcDir: string
2524
title?: string
2625
description?: string
2726
theme: ScaffoldThemeType
@@ -54,13 +53,6 @@ export async function init(root: string | undefined) {
5453
})
5554
},
5655

57-
srcDir: async () => {
58-
return text({
59-
message: 'Where should VitePress look for your markdown files?',
60-
initialValue: './'
61-
})
62-
},
63-
6456
title: () =>
6557
text({
6658
message: 'Site title:',
@@ -137,7 +129,6 @@ export async function init(root: string | undefined) {
137129

138130
export function scaffold({
139131
root = './',
140-
srcDir = './',
141132
title = 'My Awesome Project',
142133
description = 'A VitePress Site',
143134
theme,
@@ -147,14 +138,12 @@ export function scaffold({
147138
npmScriptsPrefix = 'docs'
148139
}: ScaffoldOptions): string {
149140
const resolvedRoot = path.resolve(root)
150-
const resolvedSrcDir = path.resolve(root, srcDir)
151141
const templateDir = path.resolve(
152142
path.dirname(fileURLToPath(import.meta.url)),
153143
'../../template'
154144
)
155145

156146
const data = {
157-
srcDir: srcDir === './' ? undefined : JSON.stringify(srcDir), // omit if default
158147
title: JSON.stringify(title),
159148
description: JSON.stringify(description),
160149
useTs,
@@ -173,20 +162,14 @@ export function scaffold({
173162
const renderFile = (file: string) => {
174163
const filePath = path.resolve(templateDir, file)
175164
let targetPath = path.resolve(resolvedRoot, file)
176-
177165
if (useMjs && file === '.vitepress/config.js') {
178166
targetPath = targetPath.replace(/\.js$/, '.mjs')
179167
}
180168
if (useTs) {
181169
targetPath = targetPath.replace(/\.(m?)js$/, '.$1ts')
182170
}
183-
if (file.endsWith('.md')) {
184-
targetPath = path.resolve(resolvedSrcDir, file)
185-
}
186-
187-
const content = fs.readFileSync(filePath, 'utf-8')
188-
const compiled = template(content)(data)
189-
171+
const src = fs.readFileSync(filePath, 'utf-8')
172+
const compiled = template(src)(data)
190173
fs.outputFileSync(targetPath, compiled)
191174
}
192175

template/.vitepress/config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { defineConfig } from 'vitepress'
22

33
// https://vitepress.dev/reference/site-config
4-
export default defineConfig({<% if (srcDir) { %>
5-
srcDir: <%= srcDir %>,
6-
<% } %>
4+
export default defineConfig({
75
title: <%= title %>,
86
description: <%= description %><% if (defaultTheme) { %>,
97
themeConfig: {

0 commit comments

Comments
 (0)