Skip to content

Commit d7b8761

Browse files
authored
chore: migrate docusaurus.config to .ts format (#699)
1 parent a16a8a6 commit d7b8761

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

docusaurus.config.js renamed to docusaurus.config.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const path = require('path');
2-
const { themes } = require('prism-react-renderer');
3-
const progress = require("./scripts/progress_lang.json");
1+
import path from 'node:path';
2+
import { themes } from 'prism-react-renderer';
3+
import progress from "./scripts/progress_lang.json" with { type: "json" };
4+
import type { Config } from '@docusaurus/types';
5+
import type * as Preset from '@docusaurus/preset-classic';
46

57
const GITHUB_URL = 'https://github.com/pnpm/pnpm';
68
const GITHUB_SPONSOR_URL = 'https://github.com/sponsors/pnpm';
@@ -9,7 +11,7 @@ const TRANSLATE_URL = "https://translate.pnpm.io";
911
const CRYPTO_DONATIONS_HREF = '/crypto-donations';
1012
const LOCALE_CI = process.env.LOCALE_CI;
1113
const DEFAULT_LOCALE = 'en';
12-
const LOCALE_FULL_CODE = {
14+
const LOCALE_FULL_CODE: Record<string, string> = {
1315
zh: 'zh-CN',
1416
pt: 'pt-BR',
1517
es: 'es-ES',
@@ -19,7 +21,7 @@ const PROJECT_NAME = 'pnpm.io'
1921

2022
const lastDocsVersion = '10.x';
2123

22-
function makeEditUrl (locale, path1, path2) {
24+
function makeEditUrl (locale: string, path1: string, path2: string): string {
2325
// Link to Crowdin for non-English docs
2426
if (locale !== DEFAULT_LOCALE) {
2527
return `https://translate.pnpm.io/project/pnpm/${LOCALE_FULL_CODE[locale] || locale}`;
@@ -31,7 +33,7 @@ function makeEditUrl (locale, path1, path2) {
3133
return `https://github.com/pnpm/${PROJECT_NAME}/edit/main/${path1}/${path2}`;
3234
}
3335

34-
module.exports={
36+
const docusaurusConfig = {
3537
"title": "pnpm",
3638
"tagline": "Fast, disk space efficient package manager",
3739
"url": "https://pnpm.io",
@@ -74,7 +76,7 @@ module.exports={
7476
"theme": {
7577
customCss: require.resolve('./src/css/customTheme.css'),
7678
}
77-
}
79+
} satisfies Preset.Options
7880
]
7981
],
8082
"plugins": [
@@ -293,7 +295,7 @@ module.exports={
293295
"indexName": "pnpm",
294296
"contextualSearch": true,
295297
},
296-
},
298+
} satisfies Preset.ThemeConfig,
297299
i18n: {
298300
defaultLocale: DEFAULT_LOCALE,
299301
locales: LOCALE_CI ? [LOCALE_CI] : ['en', 'it', 'zh', 'ja', 'ko', 'pt', 'zh-TW', 'ru', 'uk', 'fr', 'tr', 'es', 'id'],
@@ -322,4 +324,6 @@ module.exports={
322324
// de: { label: `Deutsch (${progress["de"].translationProgress}%)` },
323325
},
324326
},
325-
}
327+
} satisfies Config;
328+
329+
export default docusaurusConfig;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@crowdin/crowdin-api-client": "1.41.2",
41+
"@docusaurus/types": "^3.8.1",
4142
"@types/node": "^20.12.2",
4243
"shx": "^0.3.4",
4344
"ts-node": "10.9.2"

pnpm-lock.yaml

Lines changed: 12 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)