Skip to content

Commit

Permalink
Merge pull request #916 from aehrc/fix/docs-hydration
Browse files Browse the repository at this point in the history
Fix docusarurus hydration issue
  • Loading branch information
fongsean authored Jul 11, 2024
2 parents 96cc429 + fa84a34 commit 1e82e51
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,6 @@ jobs:
- name: Upload static React site to S3
run: aws s3 sync apps/smart-forms-app/dist s3://smart-forms-react-app/

deploy-docusaurus-s3:
name: Deploy Docusaurus to S3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::209248795938:role/SmartFormsReactAppDeployment
aws-region: ap-southeast-2

- name: Install dependencies
run: npm ci

- name: Build documentation website
run: npm run build -w documentation

- name: Upload static Docusaurus site to S3
run: aws s3 sync documentation/build s3://smart-forms-docs/docs

chromatic:
name: Run Chromatic
runs-on: ubuntu-latest
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Smart Forms Docs Deployment Workflow

on:
push:

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy-docusaurus-s3:
name: Deploy Docusaurus to S3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::209248795938:role/SmartFormsReactAppDeployment
aws-region: ap-southeast-2

- name: Install dependencies
run: npm ci

- name: Build documentation website
run: npm run build -w documentation

- name: Upload static Docusaurus site to S3
run: aws s3 sync documentation/build s3://smart-forms-docs/docs --cache-control no-cache
19 changes: 13 additions & 6 deletions deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,28 @@ function handler(event) {
}


// Handle Docz routes
if (uri.includes('/docz')) {
// Reroute to smartforms.csiro.au/docz/index.html
if (uri === '/docz/') {
// Handle Docs routes
if (uri.includes('/docs')) {
// Reroute to smartforms.csiro.au/docs/index.html
if (uri === '/docs/') {
request.uri += 'index.html';
return request;
}

if (uri === '/docz') {
if (uri === '/docs') {
request.uri = '/redirect.html';
return request;
}

if (!uri.includes('.')) {
request.uri += '/index.html';
// For https://smartforms.csiro.au/docs/sdc/population/ cases
if (uri.endsWith('/')) {
request.uri += 'index.html';
}
// For https://smartforms.csiro.au/docs/sdc/population cases
else {
request.uri += '/index.html';
}
return request;
}

Expand Down
5 changes: 2 additions & 3 deletions documentation/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const config: Config = {
url: 'https://smartforms.csiro.au',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/docs',
baseUrl: '/docs/',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: '', // Usually your GitHub org/user name.
projectName: '', // Usually your repo name.\

onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
onBrokenMarkdownLinks: 'throw',

trailingSlash: false,

Expand Down Expand Up @@ -56,7 +56,6 @@ const config: Config = {
// Replace with your project's social card
image: 'img/logo-sf.svg',
navbar: {
title: 'Smart Forms',
logo: {
alt: 'Smart Forms',
src: 'img/logo-sf.svg',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e82e51

Please sign in to comment.