diff --git a/.cspell.json b/.cspell.json index 31dc3fd4279f..9dc6b4fd0602 100644 --- a/.cspell.json +++ b/.cspell.json @@ -20,6 +20,8 @@ } ], "ignorePaths": [ + ".claude", + ".codex", "**/dist/**", "**/lib/**", "**/build/**", diff --git a/.github/workflows/argos.yml b/.github/workflows/argos.yml index d1054f400e40..2a6c27057c0f 100644 --- a/.github/workflows/argos.yml +++ b/.github/workflows/argos.yml @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 diff --git a/.github/workflows/build-blog-only.yml b/.github/workflows/build-blog-only.yml index aabab0d264c1..443c91689655 100644 --- a/.github/workflows/build-blog-only.yml +++ b/.github/workflows/build-blog-only.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node diff --git a/.github/workflows/build-hash-router.yml b/.github/workflows/build-hash-router.yml index d41abc7fa02c..c8907b64d9d6 100644 --- a/.github/workflows/build-hash-router.yml +++ b/.github/workflows/build-hash-router.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node diff --git a/.github/workflows/build-perf.yml b/.github/workflows/build-perf.yml index 2a1d89b39c43..9e007afa4f05 100644 --- a/.github/workflows/build-perf.yml +++ b/.github/workflows/build-perf.yml @@ -41,7 +41,7 @@ jobs: DOCUSAURUS_INFRA: ['SLOWER', 'FASTER'] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node @@ -76,7 +76,7 @@ jobs: DOCUSAURUS_INFRA: ['SLOWER', 'FASTER'] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 74b25a3fa4be..c5c1c37416d6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Initialize CodeQL uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # 4.31.0 diff --git a/.github/workflows/continuous-releases.yml b/.github/workflows/continuous-releases.yml index 976e8e46f46b..039e3cc61b28 100644 --- a/.github/workflows/continuous-releases.yml +++ b/.github/workflows/continuous-releases.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 1ba4c0e179a7..0ec7debf4f21 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -13,6 +13,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Dependency Review uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # 5.0.0 diff --git a/.github/workflows/lighthouse-report.yml b/.github/workflows/lighthouse-report.yml index e65df7cb8a3a..827bfe9d6dea 100644 --- a/.github/workflows/lighthouse-report.yml +++ b/.github/workflows/lighthouse-report.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 diff --git a/.github/workflows/lint-autofix.yml b/.github/workflows/lint-autofix.yml index 29589779a206..d35ea2431c6d 100644 --- a/.github/workflows/lint-autofix.yml +++ b/.github/workflows/lint-autofix.yml @@ -19,7 +19,7 @@ jobs: contents: write steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.head_ref }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bc598fc30719..3a14cb11fade 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 22f7628bee14..8992e4f36966 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: fetch-depth: 0 # Needed to get the commit number with "git rev-list --count HEAD" - name: Install pnpm diff --git a/.github/workflows/security-supply-chain.yml b/.github/workflows/security-supply-chain.yml index 1d371e49a783..65286d7a0532 100644 --- a/.github/workflows/security-supply-chain.yml +++ b/.github/workflows/security-supply-chain.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 diff --git a/.github/workflows/showcase-test.yml b/.github/workflows/showcase-test.yml index 0eead9f158df..c63f6f249863 100644 --- a/.github/workflows/showcase-test.yml +++ b/.github/workflows/showcase-test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml index 9830b200d596..e5a0d1067b64 100644 --- a/.github/workflows/tests-e2e.yml +++ b/.github/workflows/tests-e2e.yml @@ -43,7 +43,7 @@ jobs: node: ['24.14', '26'] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js ${{ matrix.node }} @@ -82,7 +82,7 @@ jobs: runs-on: windows-8-core steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js LTS @@ -135,7 +135,7 @@ jobs: variant: [-s, -st] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js LTS @@ -209,7 +209,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js LTS @@ -251,7 +251,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js LTS diff --git a/.github/workflows/tests-swizzle.yml b/.github/workflows/tests-swizzle.yml index 9d53424b63ed..355edf820a75 100644 --- a/.github/workflows/tests-swizzle.yml +++ b/.github/workflows/tests-swizzle.yml @@ -26,7 +26,7 @@ jobs: variant: ['js', 'ts'] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Set up Node LTS diff --git a/.github/workflows/tests-windows.yml b/.github/workflows/tests-windows.yml index 92a02b559aa2..bb23f5585b45 100644 --- a/.github/workflows/tests-windows.yml +++ b/.github/workflows/tests-windows.yml @@ -33,7 +33,7 @@ jobs: - name: Support longpaths run: git config --system core.longpaths true - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js ${{ matrix.node }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e7e3b5937bc6..421ca5382249 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: node: ['24.14', '26'] steps: - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install pnpm uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Use Node.js ${{ matrix.node }} diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 4c663c06ad87..6a38f7dfffa7 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -4,6 +4,8 @@ "bracketSameLine": true, "bracketSpacing": false, "ignorePatterns": [ + ".claude", + ".codex", "dist", "node_modules", ".yarn", diff --git a/.stylelintignore b/.stylelintignore index d281b9fc6710..7bed557f3674 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -3,6 +3,8 @@ !*/ !*.css __tests__/ +.claude +.codex build .docusaurus coverage diff --git a/eslint.config.ts b/eslint.config.ts index 0aed3d97c2b0..a9f0df56e463 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -52,6 +52,8 @@ const plugins = defineConfig([ ]); const ignores = globalIgnores([ + '.claude', + '.codex', '**/dist/**', '**/lib/**', '**/build/**', diff --git a/package.json b/package.json index bf69281b90cf..f3ee3632e093 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "update-translations": "pnpm --filter @docusaurus/theme-translations update" }, "devDependencies": { - "@ai-sdk/react": "^2.0.30", + "@ai-sdk/react": "^3.0.177", "@crowdin/cli": "^4.14.2", "@docusaurus/eslint-plugin": "3.10.1", "@docusaurus/plugin-content-blog": "3.10.1", diff --git a/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts b/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts index b3b08839339f..0f9e3dd6cfb4 100644 --- a/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts +++ b/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import {describe, expect, it, vi} from 'vitest'; +import {describe, expect, it} from 'vitest'; import fs from 'fs-extra'; import {mkdtempDisposable, realpath} from 'node:fs/promises'; import {tmpdir} from 'node:os'; @@ -53,16 +53,10 @@ const default => { `, }); - using error = vi.spyOn(console, 'error'); - await expect( extractSourceCodeFileTranslations(sourceCodeFile.path, TestBabelOptions), - ).rejects.toThrow(); - - expect(error).toHaveBeenCalledWith( - expect.stringMatching( - /Error while attempting to extract Docusaurus translations from source code file at/, - ), + ).rejects.toThrow( + /Error while attempting to extract Docusaurus translations from source code file at/, ); }); diff --git a/packages/docusaurus-babel/src/babelTranslationsExtractor.ts b/packages/docusaurus-babel/src/babelTranslationsExtractor.ts index 744f1aaa2161..e53d21ce1a81 100644 --- a/packages/docusaurus-babel/src/babelTranslationsExtractor.ts +++ b/packages/docusaurus-babel/src/babelTranslationsExtractor.ts @@ -6,7 +6,6 @@ */ import fs from 'fs-extra'; -import logger from '@docusaurus/logger'; import traverse, {type Node} from '@babel/traverse'; import generate from '@babel/generator'; import { @@ -15,6 +14,7 @@ import { type NodePath, type TransformOptions, } from '@babel/core'; +import {logger} from '@docusaurus/logger'; import type {TranslationFileContent} from '@docusaurus/types'; export type SourceCodeFileTranslations = { @@ -56,8 +56,10 @@ export async function extractSourceCodeFileTranslations( ); return translations; } catch (err) { - logger.error`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`; - throw err; + throw new Error( + logger.interpolate`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`, + {cause: err}, + ); } } diff --git a/packages/docusaurus-mdx-loader/src/__tests__/frontMatter.test.ts b/packages/docusaurus-mdx-loader/src/__tests__/frontMatter.test.ts index 5ecfe820df96..8fddfe6b4ab8 100644 --- a/packages/docusaurus-mdx-loader/src/__tests__/frontMatter.test.ts +++ b/packages/docusaurus-mdx-loader/src/__tests__/frontMatter.test.ts @@ -6,7 +6,6 @@ */ import {describe, expect, it, test} from 'vitest'; -import escapeStringRegexp from 'escape-string-regexp'; import { validateMDXFrontMatter, DefaultMDXFrontMatter, @@ -58,7 +57,7 @@ function testField(params: { } catch (err) { // eslint-disable-next-line vitest/no-conditional-expect expect((err as Error).message).toMatch( - new RegExp(escapeStringRegexp(message)), + new RegExp(RegExp.escape(message)), ); } }); diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/frontMatter.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/frontMatter.test.ts index b071886e5f6d..03d996f3c319 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/frontMatter.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/frontMatter.test.ts @@ -6,7 +6,6 @@ */ import {describe, expect, it} from 'vitest'; -import {escapeRegexp} from '@docusaurus/utils'; import {validateBlogPostFrontMatter} from '../frontMatter'; import type {BlogPostFrontMatter} from '@docusaurus/plugin-content-blog'; @@ -55,7 +54,7 @@ function testField(params: { } catch (err) { // eslint-disable-next-line vitest/no-conditional-expect expect((err as Error).message).toMatch( - new RegExp(escapeRegexp(message)), + new RegExp(RegExp.escape(message)), ); } }); diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/frontMatter.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/frontMatter.test.ts index 5a166fc071f3..83fe59dc34da 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/frontMatter.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/frontMatter.test.ts @@ -6,7 +6,6 @@ */ import {describe, expect, it, test} from 'vitest'; -import {escapeRegexp} from '@docusaurus/utils'; import {validateDocFrontMatter} from '../frontMatter'; import type {DocFrontMatter} from '@docusaurus/plugin-content-docs'; @@ -55,7 +54,7 @@ function testField(params: { } catch (err) { // eslint-disable-next-line vitest/no-conditional-expect expect((err as Error).message).toMatch( - new RegExp(escapeRegexp(message)), + new RegExp(RegExp.escape(message)), ); } }); diff --git a/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts b/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts index 00460aab9e1f..5030e72c07ea 100644 --- a/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts +++ b/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts @@ -174,7 +174,7 @@ describe('validateThemeConfig', () => { ...DEFAULT_CONFIG, ...algolia, replaceSearchResultPathname: { - from: '/docs/some\\x2d\\\\special\\x2d\\.\\[regexp\\]\\{chars\\*\\}', + from: '\\/docs\\/some\\x2d\\\\special\\x2d\\.\\[regexp\\]\\{chars\\*\\}', to: '/abc', }, }, diff --git a/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts b/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts index 2df1266bae88..7ac9264f4906 100644 --- a/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts +++ b/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import {escapeRegexp} from '@docusaurus/utils'; import {Joi} from '@docusaurus/utils-validation'; import {docSearchV3} from './docSearchVersion'; import type {ThemeConfigValidationContext} from '@docusaurus/types'; @@ -50,7 +49,7 @@ export const Schema = Joi.object({ replaceSearchResultPathname: Joi.object({ from: Joi.custom((from) => { if (typeof from === 'string') { - return escapeRegexp(from); + return RegExp.escape(from); } else if (from instanceof RegExp) { return from.source; } diff --git a/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts b/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts index 775a83f5804e..08ccf37e999c 100644 --- a/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts +++ b/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts @@ -14,12 +14,11 @@ describe('extractThemeCodeMessages', () => { await expect(() => extractThemeCodeMessages([path.join(__dirname, '__fixtures__/theme')]), ).rejects.toThrowErrorMatchingInlineSnapshot(` - [Error: - Please make sure all theme translations are static! + [Error: Please make sure all theme translations are static! Some warnings were found! Translate content could not be extracted. It has to be a static string and use optional but static props, like text. - File: packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 5 + File: /packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 5 Full code: {index} ] `); diff --git a/packages/docusaurus-theme-translations/src/utils.ts b/packages/docusaurus-theme-translations/src/utils.ts index 9b3d313ff798..6eda4f98919a 100644 --- a/packages/docusaurus-theme-translations/src/utils.ts +++ b/packages/docusaurus-theme-translations/src/utils.ts @@ -72,8 +72,7 @@ export async function extractThemeCodeMessages( filesExtractedTranslations.forEach((fileExtractedTranslations) => { if (fileExtractedTranslations.warnings.length > 0) { - throw new Error(` -Please make sure all theme translations are static! + throw new Error(`Please make sure all theme translations are static! Some warnings were found! ${fileExtractedTranslations.warnings.join('\n\n')} diff --git a/packages/docusaurus-utils/package.json b/packages/docusaurus-utils/package.json index 136cf412fe2e..e80ebf9152cf 100644 --- a/packages/docusaurus-utils/package.json +++ b/packages/docusaurus-utils/package.json @@ -21,12 +21,10 @@ "@docusaurus/logger": "3.10.1", "@docusaurus/types": "3.10.1", "@docusaurus/utils-common": "3.10.1", - "escape-string-regexp": "^4.0.0", "execa": "^5.1.1", "file-loader": "^6.2.0", "fs-extra": "^11.2.0", "github-slugger": "^2.0.0", - "globby": "^11.1.0", "gray-matter": "^4.0.3", "jiti": "^2.7.0", "js-yaml": "^4.1.0", @@ -35,6 +33,7 @@ "p-queue": "^6.6.2", "prompts": "^2.4.2", "resolve-pathname": "^3.0.0", + "tinyglobby": "^0.2.15", "tslib": "^2.6.0", "url-loader": "^4.1.1", "utility-types": "^3.10.0", diff --git a/packages/docusaurus-utils/src/globUtils.ts b/packages/docusaurus-utils/src/globUtils.ts index ba6b5589751f..c26e84ab65d7 100644 --- a/packages/docusaurus-utils/src/globUtils.ts +++ b/packages/docusaurus-utils/src/globUtils.ts @@ -10,11 +10,15 @@ import path from 'path'; import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby import {addSuffix} from '@docusaurus/utils-common'; -import Globby from 'globby'; +import * as Tinyglobby from 'tinyglobby'; import {posixPath} from './pathUtils'; +type GlobOptions = Tinyglobby.GlobOptions; + +// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction +// See https://github.com/facebook/docusaurus/pull/11042 /** A re-export of the globby instance. */ -export {Globby}; +export const Globby = Tinyglobby.glob; /** * The default glob patterns we ignore when sourcing content. @@ -93,7 +97,7 @@ export function createAbsoluteFilePathMatcher( // See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329 export async function safeGlobby( patterns: string[], - options?: Globby.GlobbyOptions, + options?: GlobOptions, ): Promise { // Required for Windows support, as paths using \ should not be used by globby // (also using the windows hard drive prefix like c: is not a good idea) @@ -132,6 +136,8 @@ export const isTranslatableSourceFile: (filePath: string) => boolean = (() => { export async function globTranslatableSourceFiles( patterns: string[], ): Promise { - const filePaths = await safeGlobby(patterns); + const filePaths = await safeGlobby(patterns, { + absolute: true, + }); return filePaths.filter(isTranslatableSourceFile); } diff --git a/packages/docusaurus-utils/src/index.ts b/packages/docusaurus-utils/src/index.ts index ff097e3e6265..ed3106af890b 100644 --- a/packages/docusaurus-utils/src/index.ts +++ b/packages/docusaurus-utils/src/index.ts @@ -114,7 +114,6 @@ export { getFolderContainingFile, } from './dataFileUtils'; export {isDraft, isUnlisted} from './contentVisibilityUtils'; -export {escapeRegexp} from './regExpUtils'; export {flattenRoutes} from './routeUtils'; export { diff --git a/packages/docusaurus-utils/src/regExpUtils.ts b/packages/docusaurus-utils/src/regExpUtils.ts deleted file mode 100644 index 7240188ced96..000000000000 --- a/packages/docusaurus-utils/src/regExpUtils.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import escapeStringRegexp from 'escape-string-regexp'; - -export function escapeRegexp(string: string): string { - return escapeStringRegexp(string); -} diff --git a/packages/docusaurus/src/commands/swizzle/actions.ts b/packages/docusaurus/src/commands/swizzle/actions.ts index d5074697ecc0..f0b9d51bcb0e 100644 --- a/packages/docusaurus/src/commands/swizzle/actions.ts +++ b/packages/docusaurus/src/commands/swizzle/actions.ts @@ -62,6 +62,12 @@ export async function eject({ const globPatternPosix = posixPath(globPattern); const filesToCopy = await Globby(globPatternPosix, { + // Workaround for Tinyglobby bug? + // We glob absolute from the theme root path, not from cwd + // See https://github.com/SuperchupuDev/tinyglobby/issues/186 + cwd: themePath, + absolute: true, + ignore: _.compact([ '**/*.{story,stories,test,tests}.{js,jsx,ts,tsx}', // When ejecting JS components, we want to avoid emitting TS files diff --git a/packages/docusaurus/src/commands/writeHeadingIds.ts b/packages/docusaurus/src/commands/writeHeadingIds.ts index ae1033f68793..c5d6cf50e46f 100644 --- a/packages/docusaurus/src/commands/writeHeadingIds.ts +++ b/packages/docusaurus/src/commands/writeHeadingIds.ts @@ -89,9 +89,11 @@ export async function writeHeadingIds( const patterns = files.length ? files : await getPathsToWatch(siteDir); - const markdownFiles = await safeGlobby(patterns, { - expandDirectories: ['**/*.{md,mdx}'], - }); + const markdownFiles = ( + await safeGlobby(patterns, { + expandDirectories: true, + }) + ).filter((file) => file.endsWith('.md') || file.endsWith('.mdx')); if (markdownFiles.length === 0) { logger.warn`No markdown files found in siteDir path=${siteDir} for patterns: ${patterns}`; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fad58b9f7284..c17cde0dc4c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,8 +13,8 @@ importers: .: devDependencies: '@ai-sdk/react': - specifier: ^2.0.30 - version: 2.0.194(react@19.2.6)(zod@4.4.3) + specifier: ^3.0.177 + version: 3.0.177(react@19.2.6)(zod@4.4.3) '@crowdin/cli': specifier: ^4.14.2 version: 4.14.2(encoding@0.1.13) @@ -1769,7 +1769,7 @@ importers: version: 1.19.8(@algolia/client-search@5.52.1)(algoliasearch@5.52.1)(search-insights@2.17.3) '@docsearch/react': specifier: ^4.6.3 - version: 4.6.3(@algolia/client-search@5.52.1)(@types/react@19.2.14)(algoliasearch@5.52.1)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(search-insights@2.17.3) + version: 4.6.3(@algolia/client-search@5.52.1)(@types/react@19.2.15)(algoliasearch@5.52.1)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(search-insights@2.17.3) '@docusaurus/core': specifier: 3.10.1 version: link:../docusaurus @@ -1916,9 +1916,6 @@ importers: '@docusaurus/utils-common': specifier: 3.10.1 version: link:../docusaurus-utils-common - escape-string-regexp: - specifier: ^4.0.0 - version: 4.0.0 execa: specifier: ^5.1.1 version: 5.1.1 @@ -1931,9 +1928,6 @@ importers: github-slugger: specifier: ^2.0.0 version: 2.0.0 - globby: - specifier: ^11.1.0 - version: 11.1.0 gray-matter: specifier: ^4.0.3 version: 4.0.3 @@ -1958,6 +1952,9 @@ importers: resolve-pathname: specifier: ^3.0.0 version: 3.0.0 + tinyglobby: + specifier: ^0.2.15 + version: 0.2.16 tslib: specifier: ^2.6.0 version: 2.8.1 @@ -2239,31 +2236,27 @@ packages: '@adobe/css-tools@4.5.0': resolution: {integrity: sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==} - '@ai-sdk/gateway@2.0.93': - resolution: {integrity: sha512-aiWQIZIQ69HOySNRLKRPJGsmGtVpPN0qXobK6aKnm8NOEyPbZHYy2ljkSAG5tvaL/Kg015WMInG4x9t2MvnG6A==} + '@ai-sdk/gateway@3.0.110': + resolution: {integrity: sha512-sbv8+1L9/BRKydn8dMNwoMQKupA4iLJ9N+yvxgW6wMQ/94UepDf3FeYWMj/dLdzolAHZ6izRUP4s5WqQkmJ2Zg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@3.0.25': - resolution: {integrity: sha512-CvsRu+32Y8a167s+lrIBtsybvgTHp8j9y+6BeTvLeoW3Q+okw/b4CnNUFOLIXsRaKHQKAH+IHNJPYWywfpw0LA==} + '@ai-sdk/provider-utils@4.0.26': + resolution: {integrity: sha512-CsKNLKsOpvPujRlIYvoz+Ybw+kGn7J4/fIZa/58+R7iWLLfwn6ifE2G6Yq8K9XvH/I/3bzaDAJ3NhRwEMsLBKQ==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider@2.0.3': - resolution: {integrity: sha512-h88OPkavHTiN9tMn2l5awAznGB0lXzjcLhgR1/rvjB2zlLprsNxbM2tt6OJsHUxduLC3klq0/eqaSf6fX5XVww==} + '@ai-sdk/provider@3.0.10': + resolution: {integrity: sha512-Q3BZ27qfpYqnCYGvE3vt+Qi6LGOF9R5Nmzn+9JoM1lCRsD9mYaIhfJLkSunN48nfGXJ6n+XNV0J/XVpqGQl7Dw==} engines: {node: '>=18'} - '@ai-sdk/react@2.0.194': - resolution: {integrity: sha512-7ZLCBpXyFTPa3530H71Rsz3rYztwkEsNzoP35SdbXCz/QCQNnFpl2/+FRqOdj5RwiMahkVk6/HKovjETytthXg==} + '@ai-sdk/react@3.0.177': + resolution: {integrity: sha512-7K3bmj2ajbAkrqR7P8bByKp0w2iACGSIpahoEkeUhhZqVJO4/mxqk6Q5wcd12EaOi+5+86k2VH91BKgzCuCRaw==} engines: {node: '>=18'} peerDependencies: react: ^18 || ~19.0.1 || ~19.1.2 || ^19.2.1 - zod: ^3.25.76 || ^4.1.8 - peerDependenciesMeta: - zod: - optional: true '@algolia/abtesting@1.18.1': resolution: {integrity: sha512-aehCadlWOGvrT91KUIZpC0MbB8KBW9yUuvTJFd2xesR7le/IsT4nJUnjCCZ4ZqZCeTcPHPV5mo//fZ5oxcSVYw==} @@ -5974,6 +5967,9 @@ packages: '@types/react@19.2.14': resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==} + '@types/react@19.2.15': + resolution: {integrity: sha512-eRwcGNHve+E8qtEQSSRl6urh+rFop4v8gm6O8rGv25CodbvFdLjA1vVQ1KkiFE0w0UPOnb8tDiFKL5lp0rtY5Q==} + '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -6160,8 +6156,8 @@ packages: vue-router: optional: true - '@vercel/oidc@3.1.0': - resolution: {integrity: sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w==} + '@vercel/oidc@3.2.0': + resolution: {integrity: sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug==} engines: {node: '>= 20'} '@vitejs/plugin-react@5.2.0': @@ -6358,8 +6354,8 @@ packages: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} - ai@5.0.192: - resolution: {integrity: sha512-m46S3iEuIcX1TjNfIQf+jr2dj+vmOY6gfhj2aKZutxru1nUnRtbCFAe5pZ9mhDApOv/EpfCrWKudwQqtoMzF0g==} + ai@6.0.175: + resolution: {integrity: sha512-6fFFHzbh6FIZnYc31V6osOxq25ABJYCShfG0O6ajHiA4FB/DgnPi1mP8cO5aAU3HNSbQHiMazdlh9bIsp97mVA==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 @@ -6487,10 +6483,6 @@ packages: array-timsort@1.0.3: resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==} - array-union@2.1.0: - resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} - engines: {node: '>=8'} - array.prototype.findlast@1.2.5: resolution: {integrity: sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==} engines: {node: '>= 0.4'} @@ -7815,10 +7807,6 @@ packages: devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} - dir-glob@3.0.1: - resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} - engines: {node: '>=8'} - dns-packet@5.6.1: resolution: {integrity: sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==} engines: {node: '>=6'} @@ -8659,10 +8647,6 @@ packages: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} - globby@11.1.0: - resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} - engines: {node: '>=10'} - globby@16.2.0: resolution: {integrity: sha512-QrJia2qDf5BB/V6HYlDTs0I0lBahyjLzpGQg3KT7FnCdTonAyPy2RtY802m2k4ALx6Dp752f82WsOczEVr3l6Q==} engines: {node: '>=20'} @@ -13497,33 +13481,33 @@ snapshots: '@adobe/css-tools@4.5.0': {} - '@ai-sdk/gateway@2.0.93(zod@4.4.3)': + '@ai-sdk/gateway@3.0.110(zod@4.4.3)': dependencies: - '@ai-sdk/provider': 2.0.3 - '@ai-sdk/provider-utils': 3.0.25(zod@4.4.3) - '@vercel/oidc': 3.1.0 + '@ai-sdk/provider': 3.0.10 + '@ai-sdk/provider-utils': 4.0.26(zod@4.4.3) + '@vercel/oidc': 3.2.0 zod: 4.4.3 - '@ai-sdk/provider-utils@3.0.25(zod@4.4.3)': + '@ai-sdk/provider-utils@4.0.26(zod@4.4.3)': dependencies: - '@ai-sdk/provider': 2.0.3 + '@ai-sdk/provider': 3.0.10 '@standard-schema/spec': 1.1.0 eventsource-parser: 3.1.0 zod: 4.4.3 - '@ai-sdk/provider@2.0.3': + '@ai-sdk/provider@3.0.10': dependencies: json-schema: 0.4.0 - '@ai-sdk/react@2.0.194(react@19.2.6)(zod@4.4.3)': + '@ai-sdk/react@3.0.177(react@19.2.6)(zod@4.4.3)': dependencies: - '@ai-sdk/provider-utils': 3.0.25(zod@4.4.3) - ai: 5.0.192(zod@4.4.3) + '@ai-sdk/provider-utils': 4.0.26(zod@4.4.3) + ai: 6.0.175(zod@4.4.3) react: 19.2.6 swr: 2.4.1(react@19.2.6) throttleit: 2.1.0 - optionalDependencies: - zod: 4.4.3 + transitivePeerDependencies: + - zod '@algolia/abtesting@1.18.1': dependencies: @@ -15091,21 +15075,21 @@ snapshots: '@discoveryjs/json-ext@0.6.3': {} - '@docsearch/core@4.6.3(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': + '@docsearch/core@4.6.3(@types/react@19.2.15)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.15 react: 19.2.6 react-dom: 19.2.6(react@19.2.6) '@docsearch/css@4.6.3': {} - '@docsearch/react@4.6.3(@algolia/client-search@5.52.1)(@types/react@19.2.14)(algoliasearch@5.52.1)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(search-insights@2.17.3)': + '@docsearch/react@4.6.3(@algolia/client-search@5.52.1)(@types/react@19.2.15)(algoliasearch@5.52.1)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)(search-insights@2.17.3)': dependencies: '@algolia/autocomplete-core': 1.19.2(@algolia/client-search@5.52.1)(algoliasearch@5.52.1)(search-insights@2.17.3) - '@docsearch/core': 4.6.3(@types/react@19.2.14)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) + '@docsearch/core': 4.6.3(@types/react@19.2.15)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) '@docsearch/css': 4.6.3 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.15 react: 19.2.6 react-dom: 19.2.6(react@19.2.6) search-insights: 2.17.3 @@ -17572,6 +17556,11 @@ snapshots: dependencies: csstype: 3.2.3 + '@types/react@19.2.15': + dependencies: + csstype: 3.2.3 + optional: true + '@types/resolve@1.20.2': {} '@types/retry@0.12.2': {} @@ -17810,7 +17799,7 @@ snapshots: optionalDependencies: react: 19.2.6 - '@vercel/oidc@3.1.0': {} + '@vercel/oidc@3.2.0': {} '@vitejs/plugin-react@5.2.0(vite@8.0.14(@types/node@25.9.1)(jiti@2.7.0)(terser@5.48.0)(yaml@2.9.0))': dependencies: @@ -18035,11 +18024,11 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ai@5.0.192(zod@4.4.3): + ai@6.0.175(zod@4.4.3): dependencies: - '@ai-sdk/gateway': 2.0.93(zod@4.4.3) - '@ai-sdk/provider': 2.0.3 - '@ai-sdk/provider-utils': 3.0.25(zod@4.4.3) + '@ai-sdk/gateway': 3.0.110(zod@4.4.3) + '@ai-sdk/provider': 3.0.10 + '@ai-sdk/provider-utils': 4.0.26(zod@4.4.3) '@opentelemetry/api': 1.9.0 zod: 4.4.3 @@ -18169,8 +18158,6 @@ snapshots: array-timsort@1.0.3: {} - array-union@2.1.0: {} - array.prototype.findlast@1.2.5: dependencies: call-bind: 1.0.9 @@ -19633,10 +19620,6 @@ snapshots: dependencies: dequal: 2.0.3 - dir-glob@3.0.1: - dependencies: - path-type: 4.0.0 - dns-packet@5.6.1: dependencies: '@leichtgewicht/ip-codec': 2.0.5 @@ -20665,15 +20648,6 @@ snapshots: define-properties: 1.2.1 gopd: 1.2.0 - globby@11.1.0: - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.3.3 - ignore: 5.3.2 - merge2: 1.4.1 - slash: 3.0.0 - globby@16.2.0: dependencies: '@sindresorhus/merge-streams': 4.0.0 diff --git a/project-words.txt b/project-words.txt index 8f64f91336c0..c1fc134eee5e 100644 --- a/project-words.txt +++ b/project-words.txt @@ -79,8 +79,6 @@ ERRNAMETOOLONG externalwaiting failfast Fienny -Flightcontrol -Flightcontrol's forwardable FOUC FranΓ§ais @@ -101,7 +99,6 @@ hasura Heavener Hideable hideable -Hostman hoverable Husain HΓ©ctor @@ -127,10 +124,7 @@ Keycap keycap Keytar keytar -Kinsta Knapen -Koyeb -Koyeb's Lamana Lifecycles lifecycles @@ -184,7 +178,6 @@ nand Navigations navigations navlink -netrc newtab Nisarag noflash @@ -235,7 +228,6 @@ protobuffet PRPL Pyltsyn QJPUV -Qovery quasis Quddus QuddΓΊs @@ -271,7 +263,6 @@ runneradmin Samply samply saurus -Scaleway Sebastien sebastien sebastienlorber @@ -294,7 +285,6 @@ someexpression spΓ’ce stackblitz stackoverflow -Stormkit strikethroughs styl sublabel diff --git a/test/snapshotPathNormalizer.ts b/test/snapshotPathNormalizer.ts index 43f863c46f15..0c5e254a8549 100644 --- a/test/snapshotPathNormalizer.ts +++ b/test/snapshotPathNormalizer.ts @@ -15,6 +15,7 @@ import fs from 'fs'; import _ from 'lodash'; import stripAnsi from 'strip-ansi'; import {version} from '../packages/docusaurus/package.json'; +import {posixPath} from '../packages/docusaurus-utils/src'; /* This weird thing is to normalize paths on our Windows GitHub Actions runners @@ -41,8 +42,6 @@ function readPathsForNormalization() { const cwd = process.cwd(); const cwdEscaped = escapePath(cwd); - console.log({cwd, cwdEscaped}); - const tempDir = os.tmpdir(); const homeDir = os.homedir(); @@ -92,6 +91,7 @@ function normalizeString(value: string): string { (val) => (val.includes('keepAnsi') ? val : stripAnsi(val)), // Replace process.cwd with (val) => val.split(cwd).join(''), + (val) => val.split(posixPath(cwd)).join(''), // In case the CWD is escaped (val) => val.split(cwdEscaped).join(''), diff --git a/vitest.config.ts b/vitest.config.ts index d11264c7d49c..aea48d702867 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -17,6 +17,8 @@ process.env.TZ = 'UTC'; const rootDir = fileURLToPath(new URL('.', import.meta.url)); const ignorePatterns = [ + '.claude', + '.codex', '**/node_modules/**', '**/__fixtures__/**', '**/__mocks__/**', diff --git a/website/_dogfooding/testSwizzleThemeClassic.mjs b/website/_dogfooding/testSwizzleThemeClassic.mjs index 364958b4ec74..c294fc198397 100644 --- a/website/_dogfooding/testSwizzleThemeClassic.mjs +++ b/website/_dogfooding/testSwizzleThemeClassic.mjs @@ -80,6 +80,7 @@ async function getAllComponentNames() { } const componentNames = await getAllComponentNames(); +console.log('componentNames', componentNames); const componentsNotFound = Object.keys(swizzleConfig.components).filter( (componentName) => !componentNames.includes(componentName), diff --git a/website/docs/api/docusaurus.config.js.mdx b/website/docs/api/docusaurus.config.js.mdx index 414a4a1a0878..304235fa2f3e 100644 --- a/website/docs/api/docusaurus.config.js.mdx +++ b/website/docs/api/docusaurus.config.js.mdx @@ -149,7 +149,7 @@ Allow to customize the presence/absence of a trailing slash at the end of URLs/l Each static hosting provider serves static files differently (this behavior may even change over time). -Refer to the [deployment guide](../deployment.mdx) and [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) to choose the appropriate setting. +Refer to the [deployment guide](../deployment/index.mdx) and [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) to choose the appropriate setting. ::: diff --git a/website/docs/cli.mdx b/website/docs/cli.mdx index b294153e18b5..b90ef1159aa0 100644 --- a/website/docs/cli.mdx +++ b/website/docs/cli.mdx @@ -149,7 +149,7 @@ Unsafe components have a higher risk of breaking changes due to internal refacto ### `docusaurus deploy [siteDir]` {/* #docusaurus-deploy-sitedir */} -Deploys your site with [GitHub Pages](https://pages.github.com/). Check out the docs on [deployment](deployment.mdx#deploying-to-github-pages) for more details. +Deploys your site with [GitHub Pages](https://pages.github.com/). Check out the docs on [deployment](deployment/github-pages.mdx) for more details. #### Options {/* #options-3 */} diff --git a/website/docs/configuration.mdx b/website/docs/configuration.mdx index d84d07a46864..c2297b1577c7 100644 --- a/website/docs/configuration.mdx +++ b/website/docs/configuration.mdx @@ -136,7 +136,7 @@ They are used in several places such as your site's title and headings, browser Deployment configurations such as `projectName`, `organizationName`, and optionally `deploymentBranch` are used when you deploy your site with the `deploy` command. -It is recommended to check the [deployment docs](deployment.mdx) for more information. +It is recommended to check the [deployment docs](deployment/index.mdx) for more information. ### Theme, plugin, and preset configurations {/* #theme-plugin-and-preset-configurations */} diff --git a/website/docs/deployment.mdx b/website/docs/deployment.mdx deleted file mode 100644 index a7ddcdd97c0d..000000000000 --- a/website/docs/deployment.mdx +++ /dev/null @@ -1,938 +0,0 @@ ---- -description: Deploy your Docusaurus app for production on a range of static site hosting services. ---- - -# Deployment - -To build the static files of your website for production, run: - -```bash npm2yarn -npm run build -``` - -Once it finishes, the static files will be generated within the `build` directory. - -:::note - -The only responsibility of Docusaurus is to build your site and emit static files in `build`. - -It is now up to you to choose how to host those static files. - -::: - -You can deploy your site to static site hosting services such as [Vercel](https://vercel.com/), [GitHub Pages](https://pages.github.com/), [Netlify](https://www.netlify.com/), [Render](https://render.com/docs/static-sites), and [Surge](https://surge.sh/help/getting-started-with-surge). - -A Docusaurus site is statically rendered, and it can generally work without JavaScript! - -## Configuration {/* #configuration */} - -The following parameters are required in `docusaurus.config.js` to optimize routing and serve files from the correct location: - -| Name | Description | -| --- | --- | -| `url` | URL for your site. For a site deployed at `https://my-org.com/my-project/`, `url` is `https://my-org.com/`. | -| `baseUrl` | Base URL for your project, with a trailing slash. For a site deployed at `https://my-org.com/my-project/`, `baseUrl` is `/my-project/`. | - -## Testing your Build Locally {/* #testing-build-locally */} - -It is important to test your build locally before deploying it for production. Docusaurus provides a [`docusaurus serve`](cli.mdx#docusaurus-serve-sitedir) command for that: - -```bash npm2yarn -npm run serve -``` - -By default, this will load your site at [`http://localhost:3000/`](http://localhost:3000/). - -## Trailing slash configuration {/* #trailing-slashes */} - -Docusaurus has a [`trailingSlash` config](./api/docusaurus.config.js.mdx#trailingSlash) to allow customizing URLs/links and emitted filename patterns. - -The default value generally works fine. Unfortunately, each static hosting provider has a **different behavior**, and deploying the exact same site to various hosts can lead to distinct results. Depending on your host, it can be useful to change this config. - -:::tip - -Use [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) to understand better the behavior of your host and configure `trailingSlash` appropriately. - -::: - -## Using environment variables {/* #using-environment-variables */} - -Putting potentially sensitive information in the environment is common practice. However, in a typical Docusaurus website, the `docusaurus.config.js` file is the only interface to the Node.js environment (see [our architecture overview](advanced/architecture.mdx)), while everything else (MDX pages, React components, etc.) are client side and do not have direct access to the `process` global variable. In this case, you can consider using [`customFields`](api/docusaurus.config.js.mdx#customFields) to pass environment variables to the client side. - -```js title="docusaurus.config.js" -// If you are using dotenv (https://www.npmjs.com/package/dotenv) -import 'dotenv/config'; - -export default { - title: '...', - url: process.env.URL, // You can use environment variables to control site specifics as well - // highlight-start - customFields: { - // Put your custom environment here - teamEmail: process.env.EMAIL, - }, - // highlight-end -}; -``` - -```jsx title="home.jsx" -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; - -export default function Home() { - const { - siteConfig: {customFields}, - } = useDocusaurusContext(); - return
Contact us through {customFields.teamEmail}!
; -} -``` - -## Choosing a hosting provider {/* #choosing-a-hosting-provider */} - -There are a few common hosting options: - -- [Self hosting](#self-hosting) with an HTTP server like Apache2 or Nginx. -- Jamstack providers (e.g. [Netlify](#deploying-to-netlify) and [Vercel](#deploying-to-vercel)). We will use them as references, but the same reasoning can apply to other providers. -- [GitHub Pages](#deploying-to-github-pages) (by definition, it is also Jamstack, but we compare it separately). - -If you are unsure of which one to choose, ask the following questions: - -
- - - How many resources (money, person-hours, etc.) am I willing to invest in this? - - -- πŸ”΄ Self-hosting requires experience in networking as well as Linux and web server administration. It's the most difficult option, and would require the most time to manage successfully. Expense-wise, cloud services are almost never free, and purchasing/deploying an onsite server can be even more costly. -- 🟒 Jamstack providers can help you set up a working website in almost no time and offer features like server-side redirects that are easily configurable. Many providers offer generous build-time quotas even for free plans that you would almost never exceed. However, free plans have limits, and you would need to pay once you hit those limits. Check the pricing page of your provider for details. -- 🟑 The GitHub Pages deployment workflow can be tedious to set up. (Evidence: see the length of [Deploying to GitHub Pages](#deploying-to-github-pages)!) However, this service (including build and deployment) is always free for public repositories, and we have detailed instructions to help you make it work. - -
- -
- -How much server-side customization do I need? - -- 🟒 With self-hosting, you have access to the entire server's configuration. You can configure the virtual host to serve different content based on the request URL, you can do complicated server-side redirects, you can implement authentication, and so on. If you need a lot of server-side features, self-host your website. -- 🟑 Jamstack usually offers some server-side configuration (e.g. URL formatting (trailing slashes), server-side redirects, etc.). -- πŸ”΄ GitHub Pages doesn't expose server-side configuration besides enforcing HTTPS and setting CNAME records. - -
- -
- -Do I need collaboration-friendly deployment workflows? - -- 🟑 Self-hosted services can leverage continuous deployment functionality like Netlify, but more heavy-lifting is involved. Usually, you would designate a specific person to manage the deployment, and the workflow wouldn't be very git-based as opposed to the other two options. -- 🟒 Netlify and Vercel have deploy previews for every pull request, which is useful for a team to review work before merging to production. You can also manage a team with different member access to the deployment. -- 🟑 GitHub Pages cannot do deploy previews in a non-convoluted way. One repo can only be associated with one site deployment. On the other hand, you can control who has write access to the site's deployment. - -
- -There isn't a silver bullet. You need to weigh your needs and resources before making a choice. - -## Self-Hosting {/* #self-hosting */} - -Docusaurus can be self-hosted using [`docusaurus serve`](cli.mdx#docusaurus-serve-sitedir). Change port using `--port` and `--host` to change host. - -```bash npm2yarn -npm run serve -- --build --port 80 --host 0.0.0.0 -``` - -:::warning - -It is not the best option, compared to a static hosting provider / CDN. - -::: - -:::warning - -In the following sections, we will introduce a few common hosting providers and how they should be configured to deploy Docusaurus sites most efficiently. Docusaurus is not affiliated with any of these services, and this information is provided for convenience only. Some of the write-ups are provided by third-parties, and recent API changes may not be reflected on our side. If you see outdated content, PRs are welcome. - -Because we can only provide this content on a best-effort basis only, we have stopped accepting PRs adding new hosting options. You can, however, publish your writeup on a separate site (e.g. your blog, or the provider's official website), and ask us to include a link to your writeup. - -::: - -## Deploying to Netlify {/* #deploying-to-netlify */} - -To deploy your Docusaurus sites to [Netlify](https://www.netlify.com/), first make sure the following options are properly configured: - -```js title="docusaurus.config.js" -export default { - // highlight-start - url: 'https://docusaurus-2.netlify.app', // Url to your site with no trailing slash - baseUrl: '/', // Base directory of your site relative to your repo - // highlight-end - // ... -}; -``` - -Then, [create your site with Netlify](https://app.netlify.com/start). - -While you set up the site, specify the build commands and directories as follows: - -- build command: `npm run build` -- publish directory: `build` - -If you did not configure these build options, you may still go to "Site settings" -> "Build & deploy" after your site is created. - -Once properly configured with the above options, your site should deploy and automatically redeploy upon merging to your deploy branch, which defaults to `main`. - -:::warning - -Some Docusaurus sites put the `docs` folder outside of `website` (most likely former Docusaurus v1 sites): - -```bash -repo # git root -β”œβ”€β”€ docs # MD files -└── website # Docusaurus root -``` - -If you decide to use the `website` folder as Netlify's base directory, Netlify will not trigger builds when you update the `docs` folder, and you need to configure a [custom `ignore` command](https://docs.netlify.com/configure-builds/common-configurations/ignore-builds/): - -```toml title="website/netlify.toml" -[build] - ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/" -``` - -::: - -:::warning - -By default, Netlify adds trailing slashes to Docusaurus URLs. - -It is recommended to disable the Netlify setting `Post Processing > Asset Optimization > Pretty Urls` to prevent lowercase URLs, unnecessary redirects, and 404 errors. - -**Be very careful**: the `Disable asset optimization` global checkbox is broken and does not really disable the `Pretty URLs` setting in practice. Please make sure to **uncheck it independently**. - -If you want to keep the `Pretty Urls` Netlify setting on, adjust the `trailingSlash` Docusaurus config appropriately. - -Refer to [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) for more information. - -::: - -## Deploying to Vercel {/* #deploying-to-vercel */} - -Deploying your Docusaurus project to [Vercel](https://vercel.com/) will provide you with [various benefits](https://vercel.com/) in the areas of performance and ease of use. - -To deploy your Docusaurus project with a [Vercel for Git Integration](https://vercel.com/docs/concepts/git), make sure it has been pushed to a Git repository. - -Import the project into Vercel using the [Import Flow](https://vercel.com/import/git). During the import, you will find all relevant options preconfigured for you; however, you can choose to change any of these [options](https://vercel.com/docs/build-step#build-&-development-settings). - -After your project has been imported, all subsequent pushes to branches will generate [Preview Deployments](https://vercel.com/docs/platform/deployments#preview), and all changes made to the [Production Branch](https://vercel.com/docs/git-integrations#production-branch) (usually "main" or "master") will result in a [Production Deployment](https://vercel.com/docs/platform/deployments#production). - -## Deploying to GitHub Pages {/* #deploying-to-github-pages */} - -Docusaurus provides an easy way to publish to [GitHub Pages](https://pages.github.com/), which comes free with every GitHub repository. - -### Overview {/* #github-pages-overview */} - -Usually, there are two repositories (at least two branches) involved in a publishing process: the branch containing the source files, and the branch containing the build output to be served with GitHub Pages. In the following tutorial, they will be referred to as **"source"** and **"deployment"**, respectively. - -Each GitHub repository is associated with a GitHub Pages service. If the deployment repository is called `my-org/my-project` (where `my-org` is the organization name or username), the deployed site will appear at `https://my-org.github.io/my-project/`. If the deployment repository is called `my-org/my-org.github.io` (the _organization GitHub Pages repo_), the site will appear at `https://my-org.github.io/`. - -:::info - -In case you want to use your custom domain for GitHub Pages, create a `CNAME` file in the `static` directory. Anything within the `static` directory will be copied to the root of the `build` directory for deployment. When using a custom domain, you should be able to move back from `baseUrl: '/projectName/'` to `baseUrl: '/'`, and also set your `url` to your custom domain. - -You may refer to GitHub Pages' documentation [User, Organization, and Project Pages](https://help.github.com/en/articles/user-organization-and-project-pages) for more details. - -::: - -GitHub Pages picks up deploy-ready files (the output from `docusaurus build`) from the default branch (`master` / `main`, usually) or the `gh-pages` branch, and either from the root or the `/docs` folder. You can configure that through `Settings > Pages` in your repository. This branch will be called the "deployment branch". - -We provide a `docusaurus deploy` command that helps you deploy your site from the source branch to the deployment branch in one command: clone, build, and commit. - -### `docusaurus.config.js` settings {/* #docusaurusconfigjs-settings */} - -First, modify your `docusaurus.config.js` and add the following params: - -| Name | Description | -| --- | --- | -| `organizationName` | The GitHub user or organization that owns the deployment repository. | -| `projectName` | The name of the deployment repository. | -| `deploymentBranch` | The name of the deployment branch. It defaults to `'gh-pages'` for non-organization GitHub Pages repos (`projectName` not ending in `.github.io`). Otherwise, it needs to be explicit as a config field or environment variable. | - -These fields also have their environment variable counterparts which have a higher priority: `ORGANIZATION_NAME`, `PROJECT_NAME`, and `DEPLOYMENT_BRANCH`. - -:::warning - -GitHub Pages adds a trailing slash to Docusaurus URLs by default. It is recommended to set a `trailingSlash` config (`true` or `false`, not `undefined`). - -::: - -Example: - -```js title="docusaurus.config.js" -export default { - // ... - url: 'https://endiliey.github.io', // Your website URL - baseUrl: '/', - // highlight-start - projectName: 'endiliey.github.io', - organizationName: 'endiliey', - trailingSlash: false, - // highlight-end - // ... -}; -``` - -:::warning - -By default, GitHub Pages runs published files through [Jekyll](https://jekyllrb.com/). Since Jekyll will discard any files that begin with `_`, it is recommended that you disable Jekyll by adding an empty file named `.nojekyll` file to your `static` directory. - -::: - -### Environment settings {/* #environment-settings */} - -| Name | Description | -| --- | --- | -| `USE_SSH` | Set to `true` to use SSH instead of the default HTTPS for the connection to the GitHub repo. If the source repo URL is an SSH URL (e.g. `git@github.com:facebook/docusaurus.git`), `USE_SSH` is inferred to be `true`. | -| `GIT_USER` | The username for a GitHub account that **has push access to the deployment repo**. For your own repositories, this will usually be your GitHub username. Required if not using SSH, and ignored otherwise. | -| `GIT_PASS` | Personal access token of the git user (specified by `GIT_USER`), to facilitate non-interactive deployment (e.g. continuous deployment) | -| `CURRENT_BRANCH` | The source branch. Usually, the branch will be `main` or `master`, but it could be any branch except for `gh-pages`. If nothing is set for this variable, then the current branch from which `docusaurus deploy` is invoked will be used. | -| `GIT_USER_NAME` | The `git config user.name` value to use when pushing to the deployment repo | -| `GIT_USER_EMAIL` | The `git config user.email` value to use when pushing to the deployment repo | - -GitHub enterprise installations should work in the same manner as github.com; you only need to set the organization's GitHub Enterprise host as an environment variable: - -| Name | Description | -| ------------- | ----------------------------------------------- | -| `GITHUB_HOST` | The domain name of your GitHub enterprise site. | -| `GITHUB_PORT` | The port of your GitHub enterprise site. | - -### Deploy {/* #deploy */} - -Finally, to deploy your site to GitHub Pages, run: - -```mdx-code-block - - -``` - -```bash -GIT_USER= yarn deploy -``` - -```mdx-code-block - - -``` - -```batch -cmd /C "set "GIT_USER=" && yarn deploy" -``` - -```mdx-code-block - - -``` - -```powershell -cmd /C 'set "GIT_USER=" && yarn deploy' -``` - -```mdx-code-block - - -``` - -:::warning - -Beginning in August 2021, GitHub requires every command-line sign-in to use the **personal access token** instead of the password. When GitHub prompts for your password, enter the PAT instead. See the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for more information. - -Alternatively, you can use SSH (`USE_SSH=true`) to log in. - -::: - -### Triggering deployment with GitHub Actions {/* #triggering-deployment-with-github-actions */} - -[GitHub Actions](https://help.github.com/en/actions) allow you to automate, customize, and execute your software development workflows right in your repository. - -The workflow examples below assume your website source resides in the `main` branch of your repository (the _source branch_ is `main`), and your [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is configured for [publishing with a custom GitHub Actions Workflow](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). - -Our goal is that: - -1. When a new pull request is made to `main`, there's an action that ensures the site builds successfully, without actually deploying. This job will be called `test-deploy`. -2. When a pull request is merged to the `main` branch or someone pushes to the `main` branch directly, it will be built and deployed to GitHub Pages. This job will be called `deploy`. - -Here are two approaches to deploying your docs with GitHub Actions. Based on the location of your deployment repository, choose the relevant tab below: - -- Source repo and deployment repo are the **same** repository. -- The deployment repo is a **remote** repository, different from the source. Instructions for this scenario assume [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is the `gh-pages` branch. - -```mdx-code-block - - -``` - -While you can have both jobs defined in the same workflow file, the original `deploy` workflow will always be listed as skipped in the PR check suite status, which is not indicative of the actual status and provides no value to the review process. We therefore propose to manage them as separate workflows instead. - -
-GitHub action files - -Add these two workflow files: - -:::warning Tweak the parameters for your setup - -If your Docusaurus project is not at the root of your repo, you may need to configure a [default working directory](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-set-the-default-shell-and-working-directory), and adjust the paths accordingly. - -::: - - - - -```yml title=".github/workflows/deploy.yml" -name: Deploy to GitHub Pages - -on: - push: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - -jobs: - build: - name: Build Docusaurus - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: npm - - - name: Install dependencies - run: npm ci - - name: Build website - run: npm run build - - - name: Upload Build Artifact - uses: actions/upload-pages-artifact@v3 - with: - path: build - - deploy: - name: Deploy to GitHub Pages - needs: build - - # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 -``` - -```yml title=".github/workflows/test-deploy.yml" -name: Test deployment - -on: - pull_request: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - -jobs: - test-deploy: - name: Test deployment - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: npm - - - name: Install dependencies - run: npm ci - - name: Test build website - run: npm run build -``` - - - - -```yml title=".github/workflows/deploy.yml" -name: Deploy to GitHub Pages - -on: - push: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - -jobs: - build: - name: Build Docusaurus - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: yarn - - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Build website - run: yarn build - - - name: Upload Build Artifact - uses: actions/upload-pages-artifact@v3 - with: - path: build - - deploy: - name: Deploy to GitHub Pages - needs: build - - # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 -``` - -```yml title=".github/workflows/test-deploy.yml" -name: Test deployment - -on: - pull_request: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - -jobs: - test-deploy: - name: Test deployment - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: yarn - - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Test build website - run: yarn build -``` - - - - -
- -```mdx-code-block -
- -``` - -A cross-repo publish is more difficult to set up because you need to push to another repo with permission checks. We will be using SSH to do the authentication. - -1. Generate a new [SSH key](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). Since this SSH key will be used in CI, make sure to not enter any passphrase. -2. By default, your public key should have been created in `~/.ssh/id_rsa.pub`; otherwise, use the name you've provided in the previous step to add your key to [GitHub deploy keys](https://developer.github.com/v3/guides/managing-deploy-keys/). -3. Copy the key to clipboard with `pbcopy < ~/.ssh/id_rsa.pub` and paste it as a [deploy key](https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys) in the deployment repository. Copy the file content if the command line doesn't work for you. Check the box for `Allow write access` before saving your deployment key. -4. You'll need your private key as a [GitHub secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) to allow Docusaurus to run the deployment for you. -5. Copy your private key with `pbcopy < ~/.ssh/id_rsa` and paste a GitHub secret with the name `GH_PAGES_DEPLOY` on your source repository. Copy the file content if the command line doesn't work for you. Save your secret. -6. Create your [documentation workflow](https://docs.github.com/en/actions/use-cases-and-examples/creating-an-example-workflow) in the `.github/workflows/` directory. In this example it's the `deploy.yml` file. - -At this point, you should have: - -- the source repo with the GitHub workflow set with the private SSH key as the GitHub Secret, and -- your deployment repo set with the public SSH key in GitHub Deploy Keys. - -
- -GitHub action file - -:::warning - -Please make sure that you replace `actions@github.com` with your GitHub email and `gh-actions` with your name. - -This file assumes you are using Yarn. If you use npm, change `cache: yarn`, `yarn install --frozen-lockfile`, `yarn build` to `cache: npm`, `npm ci`, `npm run build` accordingly. - -::: - -```yml title=".github/workflows/deploy.yml" -name: Deploy to GitHub Pages - -on: - pull_request: - branches: [main] - push: - branches: [main] - -permissions: - contents: write - -jobs: - test-deploy: - if: github.event_name != 'push' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: yarn - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Test build website - run: yarn build - deploy: - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: yarn - - uses: webfactory/ssh-agent@v0.5.0 - with: - ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} - - name: Deploy to GitHub Pages - env: - USE_SSH: true - run: | - git config --global user.email "actions@github.com" - git config --global user.name "gh-actions" - yarn install --frozen-lockfile - yarn deploy -``` - -
- -```mdx-code-block -
-
-``` - -
- -Site not deployed properly? - -After pushing to main, if you don't see your site published at the desired location (for example, it says "There isn't a GitHub Pages site here", or it's showing your repo's README.md file), try the following: - -- Wait about three minutes and refresh. It may take a few minutes for GitHub pages to pick up the new files. -- Check your repo's landing page for a little green tick next to the last commit's title, indicating the CI has passed. If you see a cross, it means the build or deployment failed, and you should check the log for more debugging information. -- Click on the tick and make sure you see a "Deploy to GitHub Pages" workflow. Names like "pages build and deployment / deploy" are GitHub's default workflows, indicating your custom deployment workflow failed to be triggered at all. Make sure the YAML files are placed under the `.github/workflows` folder, and that the trigger condition is set correctly (e.g., if your default branch is "master" instead of "main", you need to change the `on.push` property). -- Under your repo's Settings > Pages, make sure the "Source" (which is the source for the _deployment_ files, not "source" as in our terminology) is set to "gh-pages" + "/ (root)", since we are using `gh-pages` as the deployment branch. - -If you are using a custom domain: - -- Verify that you have the correct DNS records set up if you're using a custom domain. See [GitHub pages documentation on configuring custom domains](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages). Also, please be aware that it may take up to 24 hours for DNS changes to propagate through the internet. - -
- -### Triggering deployment with Travis CI {/* #triggering-deployment-with-travis-ci */} - -Continuous integration (CI) services are typically used to perform routine tasks whenever new commits are checked in to source control. These tasks can be any combination of running unit tests and integration tests, automating builds, publishing packages to npm, and deploying changes to your website. All you need to do to automate the deployment of your website is to invoke the `yarn deploy` script whenever your website is updated. The following section covers how to do just that using [Travis CI](https://travis-ci.com/), a popular continuous integration service provider. - -1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). When creating the token, grant it the `repo` scope so that it has the permissions it needs. -2. Using your GitHub account, [add the Travis CI app](https://github.com/marketplace/travis-ci) to the repository you want to activate. -3. Open your Travis CI dashboard. The URL looks like `https://travis-ci.com/USERNAME/REPO`, and navigate to the `More options > Setting > Environment Variables` section of your repository. -4. Create a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username). -5. Create a `.travis.yml` on the root of your repository with the following: - -```yml title=".travis.yml" -language: node_js -node_js: - - 24 -branches: - only: - - main -cache: - yarn: true -script: - - git config --global user.name "${GH_NAME}" - - git config --global user.email "${GH_EMAIL}" - - echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc - - yarn install - - GIT_USER="${GH_NAME}" yarn deploy -``` - -Now, whenever a new commit lands in `main`, Travis CI will run your suite of tests and if everything passes, your website will be deployed via the `yarn deploy` script. - -### Triggering deployment with Buddy {/* #triggering-deployment-with-buddy */} - -[Buddy](https://buddy.works/) is an easy-to-use CI/CD tool that allows you to automate the deployment of your portal to different environments, including GitHub Pages. - -Follow these steps to create a pipeline that automatically deploys a new version of your website whenever you push changes to the selected branch of your project: - -1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). When creating the token, grant it the `repo` scope so that it has the permissions it needs. -2. Sign in to your Buddy account and create a new project. -3. Choose GitHub as your git hosting provider and select the repository with the code of your website. -4. Using the left navigation panel, switch to the `Pipelines` view. -5. Create a new pipeline. Define its name, set the trigger mode to `On push`, and select the branch that triggers the pipeline execution. -6. Add a `Node.js` action. -7. Add these commands in the action's terminal: - -```bash -GIT_USER= -git config --global user.email "" -git config --global user.name "" -yarn deploy -``` - -After creating this simple pipeline, each new commit pushed to the branch you selected deploys your website to GitHub Pages using `yarn deploy`. Read [this guide](https://buddy.works/guides/react-docusaurus) to learn more about setting up a CI/CD pipeline for Docusaurus. - -### Using Azure Pipelines {/* #using-azure-pipelines */} - -1. Sign Up at [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) if you haven't already. -2. Create an organization. Within the organization, create a project and connect your repository from GitHub. -3. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) with the `repo` scope. -4. In the project page (which looks like `https://dev.azure.com/ORG_NAME/REPO_NAME/_build`), create a new pipeline with the following text. Also, click on edit and add a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username). Make sure to mark them as secret. Alternatively, you can also add a file named `azure-pipelines.yml` at your repository root. - -```yml title="azure-pipelines.yml" -trigger: - - main - -pool: - vmImage: ubuntu-latest - -steps: - - checkout: self - persistCredentials: true - - - task: NodeTool@0 - inputs: - versionSpec: '24' - displayName: Install Node.js - - - script: | - git config --global user.name "${GH_NAME}" - git config --global user.email "${GH_EMAIL}" - git checkout -b main - echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc - yarn install - GIT_USER="${GH_NAME}" yarn deploy - env: - GH_NAME: $(GH_NAME) - GH_EMAIL: $(GH_EMAIL) - GH_TOKEN: $(GH_TOKEN) - displayName: Install and build -``` - -### Using Drone {/* #using-drone */} - -1. Create a new SSH key that will be the [deploy key](https://docs.github.com/en/free-pro-team@latest/developers/overview/managing-deploy-keys#deploy-keys) for your project. -2. Name your private and public keys to be specific and so that it does not overwrite your other [SSH keys](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). -3. Go to `https://github.com/USERNAME/REPO/settings/keys` and add a new deploy key by pasting in the public key you just generated. -4. Open your Drone.io dashboard and log in. The URL looks like `https://cloud.drone.io/USERNAME/REPO`. -5. Click on the repository, click on activate repository, and add a secret called `git_deploy_private_key` with your private key value that you just generated. -6. Create a `.drone.yml` on the root of your repository with the below text. - -```yml title=".drone.yml" -kind: pipeline -type: docker -trigger: - event: - - tag -- name: Website - image: node - commands: - - mkdir -p $HOME/.ssh - - ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts - - echo "$GITHUB_PRIVATE_KEY" > "$HOME/.ssh/id_rsa" - - chmod 0600 $HOME/.ssh/id_rsa - - cd website - - yarn install - - yarn deploy - environment: - USE_SSH: true - GITHUB_PRIVATE_KEY: - from_secret: git_deploy_private_key -``` - -Now, whenever you push a new tag to GitHub, this trigger will start the drone CI job to publish your website. - -## Deploying to Flightcontrol {/* #deploying-to-flightcontrol */} - -[Flightcontrol](https://www.flightcontrol.dev/?ref=docusaurus) is a service that automatically builds and deploys your web apps to AWS Fargate directly from your Git repository. It gives you full access to inspect and make infrastructure changes without the limitations of a traditional PaaS. - -Get started by following [Flightcontrol's step-by-step Docusaurus guide](https://www.flightcontrol.dev/docs/reference/examples/docusaurus/?ref=docusaurus). - -## Deploying to Koyeb {/* #deploying-to-koyeb */} - -[Koyeb](https://www.koyeb.com) is a developer-friendly serverless platform to deploy apps globally. The platform lets you seamlessly run Docker containers, web apps, and APIs with git-based deployment, native autoscaling, a global edge network, and built-in service mesh and discovery. Check out the [Koyeb's Docusaurus deployment guide](https://www.koyeb.com/tutorials/deploy-docusaurus-on-koyeb) to get started. - -## Deploying to Render {/* #deploying-to-render */} - -[Render](https://render.com) offers [free static site hosting](https://render.com/docs/static-sites) with fully managed SSL, custom domains, a global CDN, and continuous auto-deploy from your Git repo. Get started in just a few minutes by following [Render's guide to deploying Docusaurus](https://render.com/docs/deploy-docusaurus). - -## Deploying to Qovery {/* #deploying-to-qovery */} - -[Qovery](https://www.qovery.com) is a fully-managed cloud platform that runs on your AWS, Digital Ocean, and Scaleway account where you can host static sites, backend APIs, databases, cron jobs, and all your other apps in one place. - -1. Create a Qovery account. Visit the [Qovery dashboard](https://console.qovery.com) to create an account if you don't already have one. -2. Create a project. - - Click on **Create project** and give a name to your project. - - Click on **Next**. -3. Create a new environment. - - Click on **Create environment** and give a name (e.g. staging, production). -4. Add an application. - - Click on **Create an application**, give a name and select your GitHub or GitLab repository where your Docusaurus app is located. - - Define the main branch name and the root application path. - - Click on **Create**. After the application is created: - - Navigate to your application **Settings** - - Select **Port** - - Add port used by your Docusaurus application -5. Deploy - - All you have to do now is to navigate to your application and click on **Deploy**. - -![Deploy the app](https://hub.qovery.com/img/heroku/heroku-1.png) - -That's it. Watch the status and wait till the app is deployed. To open the application in your browser, click on **Action** and **Open** in your application overview. - -## Deploying to Hostman {/* #deploying-to-hostman */} - -[Hostman](https://hostman.com/) allows you to host static websites for free. Hostman automates everything, you just need to connect your repository and follow these easy steps: - -1. Create a service. - - To deploy a Docusaurus static website, click **Create** in the top-left corner of your [Dashboard](https://dashboard.hostman.com/) and choose **Front-end app or static website**. - -2. Select the project to deploy. - - If you are logged in to Hostman with your GitHub, GitLab, or Bitbucket account, you will see the repository with your projects, including the private ones. - - - Choose the project you want to deploy. It must contain the directory with the project's files (e.g. `website`). - - - To access a different repository, click **Connect another repository**. - - - If you didn't use your Git account credentials to log in, you'll be able to access the necessary account now, and then select the project. - -3. Configure the build settings. - - Next, the **Website customization** window will appear. Choose the **Static website** option from the list of frameworks. - - - The **Directory with app** points at the directory that will contain the project's files after the build. If you selected the repository with the contents of the website (or `my_website`) directory during Step 2, you can leave it empty. - - - The standard build command for Docusaurus is: - - ```bash npm2yarn - npm run build - ``` - - - You can modify the build command if needed. You can enter multiple commands separated by `&&`. - -4. Deploy. - - Click **Deploy** to start the build process. - - - Once it starts, you will enter the deployment log. If there are any issues with the code, you will get warning or error messages in the log specifying the cause of the problem. Usually, the log contains all the debugging data you'll need. - - - When the deployment is complete, you will receive an email notification and also see a log entry. All done! Your project is up and ready. - -## Deploying to Surge {/* #deploying-to-surge */} - -Surge is a [static web hosting platform](https://surge.sh/help/getting-started-with-surge) that you can use to deploy your Docusaurus project from the command line in seconds. Deploying your project to Surge is easy and free (including custom domains and SSL certs). - -Deploy your app in a matter of seconds using Surge with the following steps: - -1. First, install Surge using npm by running the following command: - ```bash npm2yarn - npm install -g surge - ``` -2. To build the static files of your site for production in the root directory of your project, run: - ```bash npm2yarn - npm run build - ``` -3. Then, run this command inside the root directory of your project: - ```bash - surge build/ - ``` - -First-time users of Surge would be prompted to create an account from the command line (which happens only once). - -Confirm that the site you want to publish is in the `build` directory. A randomly generated subdomain `*.surge.sh subdomain` is always given (which can be edited). - -### Using your domain {/* #using-your-domain */} - -If you have a domain name you can deploy your site using the command: - -```bash -surge build/ your-domain.com -``` - -Your site is now deployed for free at `subdomain.surge.sh` or `your-domain.com` depending on the method you chose. - -### Setting up CNAME file {/* #setting-up-cname-file */} - -Store your domain in a CNAME file for future deployments with the following command: - -```bash -echo subdomain.surge.sh > CNAME -``` - -You can deploy any other changes in the future with the command `surge`. - -## Deploying to Stormkit {/* #deploying-to-stormkit */} - -You can deploy your Docusaurus project to [Stormkit](https://www.stormkit.io), a deployment platform for static websites, single-page applications (SPAs), and serverless functions. For detailed instructions, refer to this [guide](https://www.stormkit.io/blog/how-to-deploy-docusarous). - -## Deploying to QuantCDN {/* #deploying-to-quantcdn */} - -1. Install [Quant CLI](https://docs.quantcdn.io/docs/cli/get-started) -2. Create a QuantCDN account by [signing up](https://dashboard.quantcdn.io/register) -3. Initialize your project with `quant init` and fill in your credentials: - ```bash - quant init - ``` -4. Deploy your site. - ```bash - quant deploy - ``` - -See [docs](https://docs.quantcdn.io/docs/cli/continuous-integration) and [blog](https://www.quantcdn.io/blog) for more examples and use cases for deploying to QuantCDN. - -## Deploying to Cloudflare {/* #deploying-to-cloudflare */} - -[Cloudflare](https://cloudflare.com/) offers two approaches for deploying your Docusaurus site: **Cloudflare Workers** and **Cloudflare Pages**. - -- [Cloudflare's framework guide for deploying Docusaurus with Workers](https://developers.cloudflare.com/workers/framework-guides/web-apps/more-web-frameworks/docusaurus/). -- [Cloudflare's guide to deploying Docusaurus with Pages](https://developers.cloudflare.com/pages/framework-guides/deploy-a-docusaurus-site/). - -## Deploying to Azure Static Web Apps {/* #deploying-to-azure-static-web-apps */} - -[Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/overview) is a service that automatically builds and deploys full-stack web apps to Azure directly from the code repository, simplifying the developer experience for CI/CD. Static Web Apps separates the web application's static assets from its dynamic (API) endpoints. Static assets are served from globally-distributed content servers, making it faster for clients to retrieve files using servers nearby. Dynamic APIs are scaled with serverless architectures using an event-driven functions-based approach that is more cost-effective and scales on demand. Get started in a few minutes by following [this step-by-step guide](https://dev.to/azure/11-share-content-with-docusaurus-azure-static-web-apps-30hc). - -## Deploying to Kinsta {/* #deploying-to-kinsta */} - -[Kinsta Static Site Hosting](https://kinsta.com/static-site-hosting) lets you deploy up to 100 static sites for free, custom domains with SSL, 100 GB monthly bandwidth, and 260+ Cloudflare CDN locations. - -Get started in just a few clicks by following our [Docusaurus on Kinsta](https://kinsta.com/docs/docusaurus-example/) article. diff --git a/website/docs/deployment/github-pages.mdx b/website/docs/deployment/github-pages.mdx new file mode 100644 index 000000000000..357199ed628a --- /dev/null +++ b/website/docs/deployment/github-pages.mdx @@ -0,0 +1,451 @@ +--- +sidebar_label: GitHub Pages +description: Deploy your Docusaurus app for production on GitHub Pages. +--- + +# Deploying to GitHub Pages + +```mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +``` + +Docusaurus provides an easy way to publish to [GitHub Pages](https://pages.github.com/), which comes free with every GitHub repository. + +## Overview {/* #github-pages-overview */} + +Usually, there are two repositories (at least two branches) involved in a publishing process: the branch containing the source files, and the branch containing the build output to be served with GitHub Pages. In the following tutorial, they will be referred to as **"source"** and **"deployment"**, respectively. + +Each GitHub repository is associated with a GitHub Pages service. If the deployment repository is called `my-org/my-project` (where `my-org` is the organization name or username), the deployed site will appear at `https://my-org.github.io/my-project/`. If the deployment repository is called `my-org/my-org.github.io` (the _organization GitHub Pages repo_), the site will appear at `https://my-org.github.io/`. + +:::info + +In case you want to use your custom domain for GitHub Pages, create a `CNAME` file in the `static` directory. Anything within the `static` directory will be copied to the root of the `build` directory for deployment. When using a custom domain, you should be able to move back from `baseUrl: '/projectName/'` to `baseUrl: '/'`, and also set your `url` to your custom domain. + +You may refer to GitHub Pages' documentation [User, Organization, and Project Pages](https://help.github.com/en/articles/user-organization-and-project-pages) for more details. + +::: + +GitHub Pages picks up deploy-ready files (the output from `docusaurus build`) from the default branch (`master` / `main`, usually) or the `gh-pages` branch, and either from the root or the `/docs` folder. You can configure that through `Settings > Pages` in your repository. This branch will be called the "deployment branch". + +We provide a `docusaurus deploy` command that helps you deploy your site from the source branch to the deployment branch in one command: clone, build, and commit. + +## `docusaurus.config.js` settings {/* #docusaurusconfigjs-settings */} + +First, modify your `docusaurus.config.js` and add the following params: + +| Name | Description | +| --- | --- | +| `organizationName` | The GitHub user or organization that owns the deployment repository. | +| `projectName` | The name of the deployment repository. | +| `deploymentBranch` | The name of the deployment branch. It defaults to `'gh-pages'` for non-organization GitHub Pages repos (`projectName` not ending in `.github.io`). Otherwise, it needs to be explicit as a config field or environment variable. | + +These fields also have their environment variable counterparts which have a higher priority: `ORGANIZATION_NAME`, `PROJECT_NAME`, and `DEPLOYMENT_BRANCH`. + +:::warning + +GitHub Pages adds a trailing slash to Docusaurus URLs by default. It is recommended to set a `trailingSlash` config (`true` or `false`, not `undefined`). + +::: + +Example: + +```js title="docusaurus.config.js" +export default { + // ... + url: 'https://endiliey.github.io', // Your website URL + baseUrl: '/', + // highlight-start + projectName: 'endiliey.github.io', + organizationName: 'endiliey', + trailingSlash: false, + // highlight-end + // ... +}; +``` + +:::warning + +By default, GitHub Pages runs published files through [Jekyll](https://jekyllrb.com/). Since Jekyll will discard any files that begin with `_`, it is recommended that you disable Jekyll by adding an empty file named `.nojekyll` file to your `static` directory. + +::: + +## Environment settings {/* #environment-settings */} + +| Name | Description | +| --- | --- | +| `USE_SSH` | Set to `true` to use SSH instead of the default HTTPS for the connection to the GitHub repo. If the source repo URL is an SSH URL (e.g. `git@github.com:facebook/docusaurus.git`), `USE_SSH` is inferred to be `true`. | +| `GIT_USER` | The username for a GitHub account that **has push access to the deployment repo**. For your own repositories, this will usually be your GitHub username. Required if not using SSH, and ignored otherwise. | +| `GIT_PASS` | Personal access token of the git user (specified by `GIT_USER`), to facilitate non-interactive deployment (e.g. continuous deployment) | +| `CURRENT_BRANCH` | The source branch. Usually, the branch will be `main` or `master`, but it could be any branch except for `gh-pages`. If nothing is set for this variable, then the current branch from which `docusaurus deploy` is invoked will be used. | +| `GIT_USER_NAME` | The `git config user.name` value to use when pushing to the deployment repo | +| `GIT_USER_EMAIL` | The `git config user.email` value to use when pushing to the deployment repo | + +GitHub enterprise installations should work in the same manner as github.com; you only need to set the organization's GitHub Enterprise host as an environment variable: + +| Name | Description | +| ------------- | ----------------------------------------------- | +| `GITHUB_HOST` | The domain name of your GitHub enterprise site. | +| `GITHUB_PORT` | The port of your GitHub enterprise site. | + +## Deploy {/* #deploy */} + +Finally, to deploy your site to GitHub Pages, run: + +```mdx-code-block + + +``` + +```bash +GIT_USER= yarn deploy +``` + +```mdx-code-block + + +``` + +```batch +cmd /C "set "GIT_USER=" && yarn deploy" +``` + +```mdx-code-block + + +``` + +```powershell +cmd /C 'set "GIT_USER=" && yarn deploy' +``` + +```mdx-code-block + + +``` + +:::warning + +Beginning in August 2021, GitHub requires every command-line sign-in to use the **personal access token** instead of the password. When GitHub prompts for your password, enter the PAT instead. See the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for more information. + +Alternatively, you can use SSH (`USE_SSH=true`) to log in. + +::: + +## Triggering deployment with GitHub Actions {/* #triggering-deployment-with-github-actions */} + +[GitHub Actions](https://help.github.com/en/actions) allow you to automate, customize, and execute your software development workflows right in your repository. + +The workflow examples below assume your website source resides in the `main` branch of your repository (the _source branch_ is `main`), and your [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is configured for [publishing with a custom GitHub Actions Workflow](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow). + +Our goal is that: + +1. When a new pull request is made to `main`, there's an action that ensures the site builds successfully, without actually deploying. This job will be called `test-deploy`. +2. When a pull request is merged to the `main` branch or someone pushes to the `main` branch directly, it will be built and deployed to GitHub Pages. This job will be called `deploy`. + +Here are two approaches to deploying your docs with GitHub Actions. Based on the location of your deployment repository, choose the relevant tab below: + +- Source repo and deployment repo are the **same** repository. +- The deployment repo is a **remote** repository, different from the source. Instructions for this scenario assume [publishing source](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) is the `gh-pages` branch. + +```mdx-code-block + + +``` + +While you can have both jobs defined in the same workflow file, the original `deploy` workflow will always be listed as skipped in the PR check suite status, which is not indicative of the actual status and provides no value to the review process. We therefore propose to manage them as separate workflows instead. + +
+GitHub action files + +Add these two workflow files: + +:::warning Tweak the parameters for your setup + +If your Docusaurus project is not at the root of your repo, you may need to configure a [default working directory](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-set-the-default-shell-and-working-directory), and adjust the paths accordingly. + +::: + + + + +```yml title=".github/workflows/deploy.yml" +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + build: + name: Build Docusaurus + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + + - name: Install dependencies + run: npm ci + - name: Build website + run: npm run build + + - name: Upload Build Artifact + uses: actions/upload-pages-artifact@v3 + with: + path: build + + deploy: + name: Deploy to GitHub Pages + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 +``` + +```yml title=".github/workflows/test-deploy.yml" +name: Test deployment + +on: + pull_request: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + + - name: Install dependencies + run: npm ci + - name: Test build website + run: npm run build +``` + + + + +```yml title=".github/workflows/deploy.yml" +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + build: + name: Build Docusaurus + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: yarn + + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Build website + run: yarn build + + - name: Upload Build Artifact + uses: actions/upload-pages-artifact@v3 + with: + path: build + + deploy: + name: Deploy to GitHub Pages + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 +``` + +```yml title=".github/workflows/test-deploy.yml" +name: Test deployment + +on: + pull_request: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: yarn + + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Test build website + run: yarn build +``` + + + + +
+ +```mdx-code-block +
+ +``` + +A cross-repo publish is more difficult to set up because you need to push to another repo with permission checks. We will be using SSH to do the authentication. + +1. Generate a new [SSH key](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). Since this SSH key will be used in CI, make sure to not enter any passphrase. +2. By default, your public key should have been created in `~/.ssh/id_rsa.pub`; otherwise, use the name you've provided in the previous step to add your key to [GitHub deploy keys](https://developer.github.com/v3/guides/managing-deploy-keys/). +3. Copy the key to clipboard with `pbcopy < ~/.ssh/id_rsa.pub` and paste it as a [deploy key](https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys) in the deployment repository. Copy the file content if the command line doesn't work for you. Check the box for `Allow write access` before saving your deployment key. +4. You'll need your private key as a [GitHub secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) to allow Docusaurus to run the deployment for you. +5. Copy your private key with `pbcopy < ~/.ssh/id_rsa` and paste a GitHub secret with the name `GH_PAGES_DEPLOY` on your source repository. Copy the file content if the command line doesn't work for you. Save your secret. +6. Create your [documentation workflow](https://docs.github.com/en/actions/use-cases-and-examples/creating-an-example-workflow) in the `.github/workflows/` directory. In this example it's the `deploy.yml` file. + +At this point, you should have: + +- the source repo with the GitHub workflow set with the private SSH key as the GitHub Secret, and +- your deployment repo set with the public SSH key in GitHub Deploy Keys. + +
+ +GitHub action file + +:::warning + +Please make sure that you replace `actions@github.com` with your GitHub email and `gh-actions` with your name. + +This file assumes you are using Yarn. If you use npm, change `cache: yarn`, `yarn install --frozen-lockfile`, `yarn build` to `cache: npm`, `npm ci`, `npm run build` accordingly. + +::: + +```yml title=".github/workflows/deploy.yml" +name: Deploy to GitHub Pages + +on: + pull_request: + branches: [main] + push: + branches: [main] + +permissions: + contents: write + +jobs: + test-deploy: + if: github.event_name != 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Test build website + run: yarn build + deploy: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: yarn + - uses: webfactory/ssh-agent@v0.5.0 + with: + ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} + - name: Deploy to GitHub Pages + env: + USE_SSH: true + run: | + git config --global user.email "actions@github.com" + git config --global user.name "gh-actions" + yarn install --frozen-lockfile + yarn deploy +``` + +
+ +```mdx-code-block +
+
+``` + +
+ +Site not deployed properly? + +After pushing to main, if you don't see your site published at the desired location (for example, it says "There isn't a GitHub Pages site here", or it's showing your repo's README.md file), try the following: + +- Wait about three minutes and refresh. It may take a few minutes for GitHub pages to pick up the new files. +- Check your repo's landing page for a little green tick next to the last commit's title, indicating the CI has passed. If you see a cross, it means the build or deployment failed, and you should check the log for more debugging information. +- Click on the tick and make sure you see a "Deploy to GitHub Pages" workflow. Names like "pages build and deployment / deploy" are GitHub's default workflows, indicating your custom deployment workflow failed to be triggered at all. Make sure the YAML files are placed under the `.github/workflows` folder, and that the trigger condition is set correctly (e.g., if your default branch is "master" instead of "main", you need to change the `on.push` property). +- Under your repo's Settings > Pages, make sure the "Source" (which is the source for the _deployment_ files, not "source" as in our terminology) is set to "gh-pages" + "/ (root)", since we are using `gh-pages` as the deployment branch. + +If you are using a custom domain: + +- Verify that you have the correct DNS records set up if you're using a custom domain. See [GitHub pages documentation on configuring custom domains](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages). Also, please be aware that it may take up to 24 hours for DNS changes to propagate through the internet. + +
diff --git a/website/docs/deployment/index.mdx b/website/docs/deployment/index.mdx new file mode 100644 index 000000000000..47510ef1aaec --- /dev/null +++ b/website/docs/deployment/index.mdx @@ -0,0 +1,165 @@ +--- +description: Deploy your Docusaurus app for production on a range of static site hosting services. +--- + +# Deployment + +To build the static files of your website for production, run: + +```bash npm2yarn +npm run build +``` + +Once it finishes, the static files will be generated within the `build` directory. + +:::note + +The only responsibility of Docusaurus is to build your site and emit static files in `build`. + +It is now up to you to choose how to host those static files. + +::: + +You can deploy your site to static site hosting services such as [Vercel](https://vercel.com/), [GitHub Pages](https://pages.github.com/), [Netlify](https://www.netlify.com/), [Render](https://render.com/docs/static-sites), and [Surge](https://surge.sh/help/getting-started-with-surge). + +A Docusaurus site is statically rendered, and it can generally work without JavaScript! + +## Configuration {/* #configuration */} + +The following parameters are required in `docusaurus.config.js` to optimize routing and serve files from the correct location: + +| Name | Description | +| --- | --- | +| `url` | URL for your site. For a site deployed at `https://my-org.com/my-project/`, `url` is `https://my-org.com/`. | +| `baseUrl` | Base URL for your project, with a trailing slash. For a site deployed at `https://my-org.com/my-project/`, `baseUrl` is `/my-project/`. | + +## Testing your Build Locally {/* #testing-build-locally */} + +It is important to test your build locally before deploying it for production. Docusaurus provides a [`docusaurus serve`](../cli.mdx#docusaurus-serve-sitedir) command for that: + +```bash npm2yarn +npm run serve +``` + +By default, this will load your site at [`http://localhost:3000/`](http://localhost:3000/). + +## Trailing slash configuration {/* #trailing-slashes */} + +Docusaurus has a [`trailingSlash` config](../api/docusaurus.config.js.mdx#trailingSlash) to allow customizing URLs/links and emitted filename patterns. + +The default value generally works fine. Unfortunately, each static hosting provider has a **different behavior**, and deploying the exact same site to various hosts can lead to distinct results. Depending on your host, it can be useful to change this config. + +:::tip + +Use [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) to understand better the behavior of your host and configure `trailingSlash` appropriately. + +::: + +## Using environment variables {/* #using-environment-variables */} + +Putting potentially sensitive information in the environment is common practice. However, in a typical Docusaurus website, the `docusaurus.config.js` file is the only interface to the Node.js environment (see [our architecture overview](../advanced/architecture.mdx)), while everything else (MDX pages, React components, etc.) are client side and do not have direct access to the `process` global variable. In this case, you can consider using [`customFields`](../api/docusaurus.config.js.mdx#customFields) to pass environment variables to the client side. + +```js title="docusaurus.config.js" +// If you are using dotenv (https://www.npmjs.com/package/dotenv) +import 'dotenv/config'; + +export default { + title: '...', + url: process.env.URL, // You can use environment variables to control site specifics as well + // highlight-start + customFields: { + // Put your custom environment here + teamEmail: process.env.EMAIL, + }, + // highlight-end +}; +``` + +```jsx title="home.jsx" +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; + +export default function Home() { + const { + siteConfig: {customFields}, + } = useDocusaurusContext(); + return
Contact us through {customFields.teamEmail}!
; +} +``` + +## Choosing a hosting provider {/* #choosing-a-hosting-provider */} + +There are a few common hosting options: + +- [Self-hosting](#self-hosting) with an HTTP server like Apache2 or Nginx. +- Static hosting providers (e.g. [Netlify](./netlify.mdx) and [Vercel](./vercel.mdx)). We will use them as references, but the same reasoning can apply to other providers. +- [GitHub Pages](./github-pages.mdx) (by definition, it is also static hosting provider, but we compare it separately). + +If you are unsure of which one to choose, ask the following questions: + +
+ + + How many resources (money, person-hours, etc.) am I willing to invest in this? + + +- πŸ”΄ Self-hosting requires experience in networking as well as Linux and web server administration. It's the most difficult option, and would require the most time to manage successfully. Expense-wise, cloud services are almost never free, and purchasing/deploying an onsite server can be even more costly. +- 🟒 Static hosting providers can help you set up a working website in almost no time and offer features like server-side redirects that are easily configurable. Many providers offer generous build-time quotas even for free plans that you would almost never exceed. However, free plans have limits, and you would need to pay once you hit those limits. Check the pricing page of your provider for details. +- 🟑 The GitHub Pages deployment workflow can be tedious to set up. (Evidence: see the length of [Deploying to GitHub Pages](./github-pages.mdx)!) However, this service (including build and deployment) is always free for public repositories, and we have detailed instructions to help you make it work. + +
+ +
+ +How much server-side customization do I need? + +- 🟒 With self-hosting, you have access to the entire server's configuration. You can configure the virtual host to serve different content based on the request URL, you can do complicated server-side redirects, you can implement authentication, and so on. If you need a lot of server-side features, self-host your website. +- 🟑 Static hosting providers usually offers some server-side configuration (e.g. URL formatting (trailing slashes), server-side redirects, etc.). +- πŸ”΄ GitHub Pages doesn't expose server-side configuration besides enforcing HTTPS and setting CNAME records. + +
+ +
+ +Do I need collaboration-friendly deployment workflows? + +- 🟑 Self-hosted services can leverage continuous deployment functionality like Netlify, but more heavy-lifting is involved. Usually, you would designate a specific person to manage the deployment, and the workflow wouldn't be very git-based as opposed to the other two options. +- 🟒 Netlify and Vercel have deploy previews for every pull request, which is useful for a team to review work before merging to production. You can also manage a team with different member access to the deployment. +- 🟑 GitHub Pages cannot do deploy previews in a non-convoluted way. One repo can only be associated with one site deployment. On the other hand, you can control who has write access to the site's deployment. + +
+ +There isn't a silver bullet. You need to weigh your needs and resources before making a choice. + +## Self-Hosting {/* #self-hosting */} + +Docusaurus can be self-hosted using [`docusaurus serve`](../cli.mdx#docusaurus-serve-sitedir). Change port using `--port` and `--host` to change host. + +```bash npm2yarn +npm run serve -- --build --port 80 --host 0.0.0.0 +``` + +:::warning + +It is not the best option, compared to a static hosting provider / CDN. + +::: + +## Hosting provider guides {/* #hosting-provider-guides */} + +Here's a list of popular hosting providers and how they should be configured to deploy Docusaurus sites most efficiently. Docusaurus is not affiliated with any of these services, and this information is provided for convenience only. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; + + +``` + +:::tip Other hosting solutions + +We can only officially document a small subset of hosting providers. + +However, a Docusaurus site is just static files, and almost any hosting provider able to serve static websites can deploy it. + +Check our **[Deployment Platforms](https://github.com/facebook/docusaurus/discussions/categories/deployment-platforms)** GitHub Discussions category: the community shares its experience with other platforms there, and hosting providers are welcome to explain how to deploy Docusaurus on their service. + +::: diff --git a/website/docs/deployment/netlify.mdx b/website/docs/deployment/netlify.mdx new file mode 100644 index 000000000000..55eb425abce7 --- /dev/null +++ b/website/docs/deployment/netlify.mdx @@ -0,0 +1,62 @@ +--- +sidebar_label: Netlify +description: Deploy your Docusaurus app for production on Netlify. +--- + +# Deploying to Netlify + +To deploy your Docusaurus sites to [Netlify](https://www.netlify.com/), first make sure the following options are properly configured: + +```js title="docusaurus.config.js" +export default { + // highlight-start + url: 'https://docusaurus-2.netlify.app', // Url to your site with no trailing slash + baseUrl: '/', // Base directory of your site relative to your repo + // highlight-end + // ... +}; +``` + +Then, [create your site with Netlify](https://app.netlify.com/start). + +While you set up the site, specify the build commands and directories as follows: + +- build command: `npm run build` +- publish directory: `build` + +If you did not configure these build options, you may still go to "Site settings" -> "Build & deploy" after your site is created. + +Once properly configured with the above options, your site should deploy and automatically redeploy upon merging to your deploy branch, which defaults to `main`. + +:::warning + +Some Docusaurus sites put the `docs` folder outside of `website` (most likely former Docusaurus v1 sites): + +```bash +repo # git root +β”œβ”€β”€ docs # MD files +└── website # Docusaurus root +``` + +If you decide to use the `website` folder as Netlify's base directory, Netlify will not trigger builds when you update the `docs` folder, and you need to configure a [custom `ignore` command](https://docs.netlify.com/configure-builds/common-configurations/ignore-builds/): + +```toml title="website/netlify.toml" +[build] + ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/" +``` + +::: + +:::warning + +By default, Netlify adds trailing slashes to Docusaurus URLs. + +It is recommended to disable the Netlify setting `Post Processing > Asset Optimization > Pretty Urls` to prevent lowercase URLs, unnecessary redirects, and 404 errors. + +**Be very careful**: the `Disable asset optimization` global checkbox is broken and does not really disable the `Pretty URLs` setting in practice. Please make sure to **uncheck it independently**. + +If you want to keep the `Pretty Urls` Netlify setting on, adjust the `trailingSlash` Docusaurus config appropriately. + +Refer to [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-guide) for more information. + +::: diff --git a/website/docs/deployment/vercel.mdx b/website/docs/deployment/vercel.mdx new file mode 100644 index 000000000000..53866252ceaa --- /dev/null +++ b/website/docs/deployment/vercel.mdx @@ -0,0 +1,14 @@ +--- +sidebar_label: Vercel +description: Deploy your Docusaurus app for production on Vercel. +--- + +# Deploying to Vercel + +Deploying your Docusaurus project to [Vercel](https://vercel.com/) will provide you with [various benefits](https://vercel.com/) in the areas of performance and ease of use. + +To deploy your Docusaurus project with a [Vercel for Git Integration](https://vercel.com/docs/concepts/git), make sure it has been pushed to a Git repository. + +Import the project into Vercel using the [Import Flow](https://vercel.com/import/git). During the import, you will find all relevant options preconfigured for you; however, you can choose to change any of these [options](https://vercel.com/docs/build-step#build-&-development-settings). + +After your project has been imported, all subsequent pushes to branches will generate [Preview Deployments](https://vercel.com/docs/platform/deployments#preview), and all changes made to the [Production Branch](https://vercel.com/docs/git-integrations#production-branch) (usually "main" or "master") will result in a [Production Deployment](https://vercel.com/docs/platform/deployments#production). diff --git a/website/docs/guides/docs/versioning.mdx b/website/docs/guides/docs/versioning.mdx index 9c444c34d1cd..a8193e42ac78 100644 --- a/website/docs/guides/docs/versioning.mdx +++ b/website/docs/guides/docs/versioning.mdx @@ -327,11 +327,11 @@ Should you cut a new documentation version 1.0.1? **You probably shouldn't**. 1. ### Keep the number of versions small {/* #keep-the-number-of-versions-small */} -As a good rule of thumb, try to keep the number of your versions below 10. You will **very likely** to have a lot of obsolete versioned documentation that nobody even reads anymore. For example, [Jest](https://jestjs.io/versions) is currently in version `27.4`, and only maintains several latest documentation versions with the lowest being `25.X`. Keep it small 😊 +As a good rule of thumb, try to keep the number of your versions below 10. You will **very likely** have a lot of obsolete versioned documentation that nobody even reads anymore. For example, [Jest](https://jestjs.io/versions) is currently in version `30.x`, however many older versions are archived but remain available, linking to immutable standalone deployment. :::tip archive older versions -If you deploy your site on a Jamstack provider (e.g. [Netlify](../../deployment.mdx)), the provider will save each production build as a snapshot under an immutable URL. You can include archived versions that will never be rebuilt as external links to these immutable URLs. The Jest website and the Docusaurus website both use such pattern to keep the number of actively built versions low. +If you [deploy your site](../../deployment/index.mdx) on a static hosting provider, you can configure it to create a separate deployment at any point in time, and keep that deployment alive indefinitely as an immutable snapshot under a permanent URL. This means you can archive versioned docs as standalone immutable websites, and then link to these standalone websites. The [Jest](https://jestjs.io/versions), [React Native](https://reactnative.dev/versions) and [Docusaurus](/versions) websites all use such pattern to keep the number of actively built versions low. ::: diff --git a/website/docs/guides/whats-next.mdx b/website/docs/guides/whats-next.mdx index 00d2793f3745..43eb0d1750f4 100644 --- a/website/docs/guides/whats-next.mdx +++ b/website/docs/guides/whats-next.mdx @@ -11,7 +11,7 @@ Congratulations! You have understood most core features of Docusaurus now. You h - [Added search](../search.mdx) to your site - Understood how [browser support](../browser-support.mdx) and [SEO](../seo.mdx) are done through standard Docusaurus APIs - Learned about how [individual plugins](../using-plugins.mdx) are installed and configured -- [Deployed](../deployment.mdx) your site to a content host +- [Deployed](../deployment/index.mdx) your site to a content host - [Internationalized](../i18n/i18n-tutorial.mdx) your site to include multiple languages At this point, you probably have a big `docusaurus.config.js` alreadyπŸ˜„ However, you haven't written much code yet! Most of the features are implemented through calling encapsulated Docusaurus APIs. As you continue your journey, you can take three paths: diff --git a/website/docs/i18n/i18n-introduction.mdx b/website/docs/i18n/i18n-introduction.mdx index 2c91ddc53e1c..b44b8bf63d2f 100644 --- a/website/docs/i18n/i18n-introduction.mdx +++ b/website/docs/i18n/i18n-introduction.mdx @@ -34,7 +34,7 @@ The goals of the Docusaurus i18n system are: We don't provide support for: -- **Automatic locale detection**: opinionated, and best done on the [server (your hosting provider)](../deployment.mdx) +- **Automatic locale detection**: opinionated, and best done on the [server (your hosting provider)](../deployment/index.mdx) - **Translation SaaS software**: you are responsible to understand the external tools of your choice - **Translation of slugs**: technically complicated, little SEO value diff --git a/website/docs/i18n/i18n-tutorial.mdx b/website/docs/i18n/i18n-tutorial.mdx index 1f01f32de518..176df3ec69e6 100644 --- a/website/docs/i18n/i18n-tutorial.mdx +++ b/website/docs/i18n/i18n-tutorial.mdx @@ -477,7 +477,7 @@ Docusaurus will build **one single-page application per locale**: - `website/build`: for the default, English language - `website/build/fr`: for the French language -You can now [deploy](../deployment.mdx) the `build` folder to the static hosting solution of your choice. +You can now [deploy](../deployment/index.mdx) the `build` folder to the static hosting solution of your choice. :::note @@ -508,7 +508,7 @@ npm run build -- --locale fr When building a single locale at a time, Docusaurus will not add the `/fr/` URL prefix automatically, assuming you want to deploy each locale to a distinct domain. -On your [static hosting provider](../deployment.mdx): +On your [static hosting provider](../deployment/index.mdx): - create one deployment per locale - configure the appropriate build command, using the `--locale` option diff --git a/website/docs/installation.mdx b/website/docs/installation.mdx index e9cdd49dcd07..0846919e480c 100644 --- a/website/docs/installation.mdx +++ b/website/docs/installation.mdx @@ -122,7 +122,7 @@ my-monorepo In this case, you should run `npx create-docusaurus` within the `./my-monorepo` folder. -If you're using a hosting provider such as Netlify or Vercel, you will need to change the `Base directory` of the site to where your Docusaurus root is. In this case, that would be `./website`. Read more about configuring ignore commands in the [deployment docs](./deployment.mdx#deploying-to-netlify). +If you're using a hosting provider such as Netlify or Vercel, you will need to change the `Base directory` of the site to where your Docusaurus root is. In this case, that would be `./website`. Read more about configuring ignore commands in the [deployment docs](./deployment/netlify.mdx). Read more about monorepos in the [Yarn documentation](https://yarnpkg.com/features/workspaces) (Yarn is not the only way to set up a monorepo, but it's a common solution), or check out [Docusaurus](https://github.com/facebook/docusaurus) and [Jest](https://github.com/facebook/jest) for some real-world examples. @@ -147,7 +147,7 @@ Docusaurus is a modern static website generator, so we need to build the website npm run build ``` -and contents will be generated within the `/build` directory, which can be copied to any static file hosting service like [GitHub pages](https://pages.github.com/), [Vercel](https://vercel.com/) or [Netlify](https://www.netlify.com/). Check out the docs on [deployment](deployment.mdx) for more details. +and contents will be generated within the `/build` directory, which can be copied to any static file hosting service like [GitHub pages](https://pages.github.com/), [Vercel](https://vercel.com/) or [Netlify](https://www.netlify.com/). Check out the docs on [deployment](deployment/index.mdx) for more details. ## Updating your Docusaurus version {/* #updating-your-docusaurus-version */} diff --git a/website/docs/introduction.mdx b/website/docs/introduction.mdx index 8cfcd9a854a6..3c7d7a0119da 100644 --- a/website/docs/introduction.mdx +++ b/website/docs/introduction.mdx @@ -74,7 +74,7 @@ A [lot of users](/showcase) are already using Docusaurus v2+ ([trends](https://w **Use Docusaurus v2+ if:** -- :white_check_mark: You want a modern Jamstack documentation site +- :white_check_mark: You want a modern static documentation site - :white_check_mark: You want a single-page application (SPA) with client-side routing - :white_check_mark: You want the full power of React and MDX - :white_check_mark: You do not need support for IE11 diff --git a/website/docs/seo.mdx b/website/docs/seo.mdx index 3fb599de6b73..8bf40c13f362 100644 --- a/website/docs/seo.mdx +++ b/website/docs/seo.mdx @@ -185,7 +185,7 @@ Read more about the robots file in [the Google documentation](https://developers **Important**: the `robots.txt` file does **not** prevent HTML pages from being indexed. -To prevent your whole Docusaurus site from being indexed, use the [`noIndex`](./api/docusaurus.config.js.mdx#noIndex) site config. Some [hosting providers](./deployment.mdx) may also let you configure a `X-Robots-Tag: noindex` HTTP header (GitHub Pages does not support this). +To prevent your whole Docusaurus site from being indexed, use the [`noIndex`](./api/docusaurus.config.js.mdx#noIndex) site config. Some [hosting providers](./deployment/index.mdx) may also let you configure a `X-Robots-Tag: noindex` HTTP header (GitHub Pages does not support this). To prevent a single page from being indexed, use `` as [page metadata](#single-page-metadata). Read more about the [robots meta tag](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag). diff --git a/website/sidebars.ts b/website/sidebars.ts index 09ddffdb7784..ee8ae9d46a2b 100644 --- a/website/sidebars.ts +++ b/website/sidebars.ts @@ -92,7 +92,16 @@ const sidebars: SidebarsConfig = { 'browser-support', 'seo', 'using-plugins', - 'deployment', + { + type: 'category', + label: 'Deployment', + link: {type: 'doc', id: 'deployment/index'}, + items: [ + 'deployment/github-pages', + 'deployment/netlify', + 'deployment/vercel', + ], + }, { type: 'category', label: 'Internationalization',