From 55ae0b627efce229238a572e3eb927e197416e06 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 7 Dec 2023 19:10:56 +0100 Subject: [PATCH 1/3] build: update `build_docs` and `deploy_docs` to deploy new docusaurus-based docs --- scripts/deploy/build_docs | 11 ++++++++++- scripts/deploy/deploy_docs | 9 ++++++++- website/docusaurus.config.ts | 4 +++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/deploy/build_docs b/scripts/deploy/build_docs index c15dd68305f..f27146d88a8 100755 --- a/scripts/deploy/build_docs +++ b/scripts/deploy/build_docs @@ -4,14 +4,23 @@ set -e NODE_IMG="docker.elastic.co/eui/ci:6.0" +# Docusaurus must know the base URL to work properly +DOCS_BASE_URL="/new-docs/" +if [ -n "${GIT_PULL_REQUEST_ID}" ] && [ "${GIT_PULL_REQUEST_ID}" != "false" ]; then + DOCS_BASE_URL="/pr_${GIT_PULL_REQUEST_ID}/new-docs/" +fi + +echo "Docusaurus base URL set to: ${DOCS_BASE_URL}" + # Compile using node image echo "Building docs using ${NODE_IMG} Docker image" docker pull $NODE_IMG docker run \ --rm -i \ --env HOME=/tmp \ + --env DOCS_BASE_URL="$DOCS_BASE_URL" \ --"user=$(id -u)":"$(id -g)" \ --volume "$PWD":/app \ --workdir /app \ $NODE_IMG \ - bash -c 'yarn && yarn build && yarn build-docs && yarn build-storybook' + bash -c 'yarn && yarn build && yarn build-docs && yarn build-storybook && yarn --cwd website && yarn --cwd website build' diff --git a/scripts/deploy/deploy_docs b/scripts/deploy/deploy_docs index 2470b3db98f..7c85074e994 100755 --- a/scripts/deploy/deploy_docs +++ b/scripts/deploy/deploy_docs @@ -55,7 +55,8 @@ post_comment_to_gh() printf '\nAdding comment to GitHub Pull Request: %i\n' "${GIT_PULL_REQUEST_ID}" comment="Preview staging links for this PR: - Docs site: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/ -- Storybook: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/storybook" +- Storybook: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/storybook +- New docs site (in development): https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/new-docs" curl \ --silent \ @@ -78,11 +79,17 @@ publish_to_bucket() -z js,css,html # enable gzip encoding for these extensions ) + # Current docs echo "Copying ${PWD}/docs/* to ${full_bucket_path}" gsutil "${copy_options[@]}" "${PWD}/docs/*" "${full_bucket_path}" + # Storybook echo "Copying ${PWD}/storybook-static/* to ${full_bucket_path}storybook/" gsutil "${copy_options[@]}" "${PWD}/storybook-static/*" "${full_bucket_path}storybook/" + + # New docs + echo "Copying ${PWD}/website/build/* to ${full_bucket_path}new-docs/" + gsutil "${copy_options[@]}" "${PWD}/website/build/*" "${full_bucket_path}new-docs/" } if [[ "$1" != "nodocker" ]]; then diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index feefaf38bcf..43f4bc41eaa 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -2,6 +2,8 @@ import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; +const baseUrl = process.env.DOCS_BASE_URL || '/'; + const config: Config = { title: 'Elastic UI Framework', tagline: 'The framework powering the Elastic Stack', @@ -11,7 +13,7 @@ const config: Config = { url: 'https://eui.elastic.co', // Set the // pathname under which your site is served - baseUrl: '/', + baseUrl, onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'warn', From 6c5494af3ee274dd5677b9ce5a68de0449f5de01 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 7 Dec 2023 21:13:16 +0100 Subject: [PATCH 2/3] build(website): set `trailingSlash: true` to ensure GCS routing works as expected --- website/docusaurus.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index 43f4bc41eaa..8cfeed82f83 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -8,6 +8,7 @@ const config: Config = { title: 'Elastic UI Framework', tagline: 'The framework powering the Elastic Stack', favicon: 'favicon.ico', + trailingSlash: true, // Set the production url of your site here url: 'https://eui.elastic.co', From 445db1fd6a5bc145d69e9bab12cd4b5ed995e4c1 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 7 Dec 2023 22:22:43 +0100 Subject: [PATCH 3/3] build: add trailing slash to new docs site URL in PR preview comment --- scripts/deploy/deploy_docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy/deploy_docs b/scripts/deploy/deploy_docs index 7c85074e994..95e8038834a 100755 --- a/scripts/deploy/deploy_docs +++ b/scripts/deploy/deploy_docs @@ -56,7 +56,7 @@ post_comment_to_gh() comment="Preview staging links for this PR: - Docs site: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/ - Storybook: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/storybook -- New docs site (in development): https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/new-docs" +- New docs site (in development): https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/new-docs/" curl \ --silent \