Skip to content

Commit

Permalink
Merge pull request #2644 from doc4d/gk/router
Browse files Browse the repository at this point in the history
Add static build
  • Loading branch information
guillaume-kotulski authored Jan 13, 2025
2 parents 623b696 + 05ce9d3 commit 0358dc0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 27 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ on:
- '!main'

jobs:
workflow-check:
check:
uses: ./.github/workflows/workflow-syntax-check.yml
workflow-build:
build:
uses: ./.github/workflows/workflow-build.yml
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-build
cancel-in-progress: true
build-static:
uses: ./.github/workflows/workflow-build-static.yml
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
uses: ./.github/workflows/workflow-syntax-check.yml
workflow-build:
uses: ./.github/workflows/workflow-build.yml
workflow-static:
uses: ./.github/workflows/workflow-build-static.yml

gh-release:
needs: [workflow-build]
Expand All @@ -22,3 +24,21 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/

publish-release:
needs: [workflow-static]
name: 'Publish Release'
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: static-doc-*
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
files: |
static-doc-*
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true

31 changes: 31 additions & 0 deletions .github/workflows/workflow-build-static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build static documentation

on:
workflow_call:

jobs:
build:
strategy:
matrix:
language: ["en", "fr", "es", "ja", "pt"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Build
run: |
if [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run build -- --locale ${{ matrix.language }}
env:
DOCUSAURUS_LANGUAGE: ${{ matrix.language }}
DOCUSAURUS_ROUTER: 'hash'
- uses: actions/upload-artifact@v4
with:
path: ./build
name: static-doc-${{ matrix.language }}
2 changes: 1 addition & 1 deletion .github/workflows/workflow-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
- name: Build
run: |
if [ -e package-lock.json ]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-syntax-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
- name: Diff images
env:
CLICOLOR_FORCE: 1
Expand Down
49 changes: 28 additions & 21 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,33 @@ const darkTheme = themes.palenight;


const isProduction = process.env.GITHUB_REPOSITORY_OWNER === '4d';
const router = process.env.DOCUSAURUS_ROUTER
const isStatic = process.env.DOCUSAURUS_ROUTER === "hash"
const language = process.env.DOCUSAURUS_LANGUAGE ?? "en"

const locales = isStatic ? [language] : ["en", "fr", "es", "ja", "pt"]
const localeConfigs = isStatic ? {} : {
en: {
label: "English",
},
fr: {
label: "Français",
},
es: {
label: "Español",
},
ja: {
label: "日本語",
},
pt: {
label: "Português",
},
}

module.exports = {
title: "4D Docs",
tagline: "Documentation for 4D developers",
baseUrl: "/docs/",
baseUrl: isStatic ? "/" : "/docs/",
//url: "https://4d.github.io/",
url: "https://developer.4d.com/",
organizationName: "4D",
Expand Down Expand Up @@ -79,27 +101,12 @@ module.exports = {
rspackBundler: true,
mdxCrossCompilerCache: true,
},
experimental_router: router,
},
i18n: {
defaultLocale: "en",
locales: ["en", "fr", "es", "ja", "pt"],
localeConfigs: {
en: {
label: "English",
},
fr: {
label: "Français",
},
es: {
label: "Español",
},
ja: {
label: "日本語",
},
pt: {
label: "Português",
},
},
defaultLocale: language,
locales: locales,
localeConfigs: localeConfigs,
},
plugins: [
[
Expand Down Expand Up @@ -250,5 +257,5 @@ module.exports = {
maintainCase: false,
},
},
themes: ['@docusaurus/theme-mermaid'],
themes: ['@docusaurus/theme-mermaid'],
}

0 comments on commit 0358dc0

Please sign in to comment.