Skip to content

Commit 2373559

Browse files
authored
feat: specify lang via cli (#187)
1 parent 1ef6f3d commit 2373559

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

.changeset/good-wombats-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": patch
3+
---
4+
5+
feat: specify lang via cli

docs/en/start.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sourceSHA: 166fda7d9b168a1be0333c3b744b7dffb18ccbd32f7f9c6da426ce4c980b4b8a
2+
sourceSHA: fa1b3035de2eb1166334fa4c487575bc32fe4886a888be9b9a5efbf7486044cb
33
---
44

55
# Getting Started \{#start}
@@ -104,6 +104,7 @@ Options:
104104
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
105105
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
106106
-n, --no-open Do not open the browser after starting the server
107+
--lang <language> Specify the language of the documentation
107108
-h, --help display help for command
108109

109110
Commands:

docs/zh/start.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Options:
100100
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
101101
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
102102
-n, --no-open Do not open the browser after starting the server
103+
--lang <language> Specify the language of the documentation
103104
-h, --help display help for command
104105

105106
Commands:

packages/doom/src/cli/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ program
114114
false,
115115
)
116116
.option('-n, --no-open', 'Do not open the browser after starting the server')
117+
.option('--lang <language>', 'Specify the language of the documentation')
117118
.command('dev', { isDefault: true })
118119
.description('Start the development server')
119120
.argument('[root]', 'Root directory of the documentation')

packages/doom/src/cli/load-config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const getCommonConfig = async ({
132132
editRepo,
133133
algolia,
134134
siteUrl,
135+
lang,
135136
}: {
136137
config: UserConfig
137138
configFilePath?: string
@@ -150,7 +151,12 @@ const getCommonConfig = async ({
150151
editRepo?: boolean | string
151152
algolia?: boolean | 'alauda' | 'alauda-ru'
152153
siteUrl?: boolean
154+
lang?: string
153155
}): Promise<UserConfig> => {
156+
if (lang != null) {
157+
config.lang = lang
158+
}
159+
154160
const fallbackToZh = 'lang' in config && !config.lang
155161
root = resolveDocRoot(root, config.root)
156162
const localBasePath = configFilePath ? path.dirname(configFilePath) : root
@@ -410,6 +416,7 @@ export async function loadConfig(
410416
editRepo,
411417
algolia,
412418
siteUrl,
419+
lang,
413420
}: GlobalCliOptions = {},
414421
): Promise<{
415422
config: UserConfig
@@ -495,6 +502,7 @@ export async function loadConfig(
495502
editRepo,
496503
algolia,
497504
siteUrl,
505+
lang,
498506
})
499507

500508
base = commonConfig.base!

packages/doom/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface GlobalCliOptions {
3232
editRepo?: boolean | string
3333
algolia?: boolean | 'alauda'
3434
siteUrl?: boolean
35+
lang?: string
3536
}
3637

3738
export interface TranslateOptions {

0 commit comments

Comments
 (0)