Skip to content

Commit acb59dd

Browse files
Add fixes for static styles not loading issue
1 parent 00e61f4 commit acb59dd

3 files changed

Lines changed: 61 additions & 32 deletions

File tree

.github/workflows/publish_docs.yaml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ on:
77
workflow_dispatch:
88

99
permissions:
10-
contents: write
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: false
1117

1218
jobs:
13-
release-wso2-open-healthcare-docs:
19+
build:
1420
runs-on: ubuntu-latest
1521
steps:
1622
- name: Check out code
@@ -27,19 +33,27 @@ jobs:
2733
cache-dependency-path: en/package-lock.json
2834

2935
- name: Install dependencies
30-
run: |
31-
cd en/
32-
npm ci
36+
run: npm ci
37+
working-directory: en
3338

3439
- name: Build Docusaurus site
35-
run: |
36-
cd en/
37-
npm run build
40+
run: npm run build
41+
working-directory: en
3842
env:
39-
BASE_URL: /open-healthcare-docs/
43+
BASE_URL: /${{ github.event.repository.name }}/
4044

41-
- name: Deploy to GitHub Pages
42-
uses: peaceiris/actions-gh-pages@v4
45+
- name: Upload GitHub Pages artifact
46+
uses: actions/upload-pages-artifact@v3
4347
with:
44-
github_token: ${{ secrets.GITHUB_TOKEN }}
45-
publish_dir: en/build
48+
path: en/build
49+
50+
deploy:
51+
needs: build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
steps:
57+
- name: Deploy to GitHub Pages
58+
id: deployment
59+
uses: actions/deploy-pages@v4

en/docusaurus.config.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ const rehypeFixAssetImages = require('./src/plugins/rehype-fix-asset-images');
33

44
const baseUrl = process.env.BASE_URL || '/';
55

6+
/** Prefix absolute static asset paths with baseUrl (required for GitHub Pages project sites). */
7+
function staticAsset(path) {
8+
const normalizedBase = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
9+
const normalizedPath = path.startsWith('/') ? path.slice(1) : path;
10+
return `${normalizedBase}${normalizedPath}`;
11+
}
12+
613
/** @type {import('@docusaurus/types').Config} */
714
const config = {
815
title: 'Healthcare Solution Documentation',
@@ -37,16 +44,16 @@ const config = {
3744
],
3845
],
3946
stylesheets: [
40-
'/assets/css/ohtheme.css',
41-
'/assets/css/blue-palette-alt1.css',
42-
'/assets/css/config-catalog.css',
43-
'/assets/css/redoc.css',
44-
'/assets/lib/json-formatter/json-formatter.css',
45-
'/assets/lib/fontawesome-free-6.3.0-web/css/all.min.css',
47+
staticAsset('/assets/css/ohtheme.css'),
48+
staticAsset('/assets/css/blue-palette-alt1.css'),
49+
staticAsset('/assets/css/config-catalog.css'),
50+
staticAsset('/assets/css/redoc.css'),
51+
staticAsset('/assets/lib/json-formatter/json-formatter.css'),
52+
staticAsset('/assets/lib/fontawesome-free-6.3.0-web/css/all.min.css'),
4653
],
4754
scripts: [
48-
'/assets/lib/json-formatter/json-formatter.umd.js',
49-
'/assets/js/ohtheme.js',
55+
staticAsset('/assets/lib/json-formatter/json-formatter.umd.js'),
56+
staticAsset('/assets/js/ohtheme.js'),
5057
],
5158
themeConfig: {
5259
image: 'img/logo.svg',

en/docusaurus.config.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import { themes as prismThemes } from 'prism-react-renderer';
22
import type { Config } from '@docusaurus/types';
33
import type * as Preset from '@docusaurus/preset-classic';
44

5+
const baseUrl = process.env.BASE_URL || '/';
6+
7+
function staticAsset(path: string): string {
8+
const normalizedBase = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
9+
const normalizedPath = path.startsWith('/') ? path.slice(1) : path;
10+
return `${normalizedBase}${normalizedPath}`;
11+
}
12+
513
const config: Config = {
614
title: 'Healthcare Solution Documentation',
715
tagline: 'Documentation for WSO2 Open Healthcare Accelerator',
816
favicon: 'img/favicon.svg',
917
url: 'https://oh.docs.wso2.com',
10-
baseUrl: process.env.BASE_URL || '/',
18+
baseUrl,
1119
organizationName: 'wso2',
1220
projectName: 'open-healthcare-docs',
1321
onBrokenLinks: 'warn',
@@ -35,18 +43,18 @@ const config: Config = {
3543
],
3644
],
3745
stylesheets: [
38-
'/assets/css/ohtheme.css',
39-
'/assets/css/blue-palette-alt1.css',
40-
'/assets/css/config-catalog.css',
41-
'/assets/css/redoc.css',
42-
'/assets/lib/highlightjs/styles/vs.min.css',
43-
'/assets/lib/json-formatter/json-formatter.css',
44-
'/assets/lib/fontawesome-free-6.3.0-web/css/all.min.css',
46+
staticAsset('/assets/css/ohtheme.css'),
47+
staticAsset('/assets/css/blue-palette-alt1.css'),
48+
staticAsset('/assets/css/config-catalog.css'),
49+
staticAsset('/assets/css/redoc.css'),
50+
staticAsset('/assets/lib/highlightjs/styles/vs.min.css'),
51+
staticAsset('/assets/lib/json-formatter/json-formatter.css'),
52+
staticAsset('/assets/lib/fontawesome-free-6.3.0-web/css/all.min.css'),
4553
],
4654
scripts: [
47-
'/assets/lib/highlightjs/highlight.min.js',
48-
'/assets/lib/json-formatter/json-formatter.umd.js',
49-
'/assets/js/ohtheme.js',
55+
staticAsset('/assets/lib/highlightjs/highlight.min.js'),
56+
staticAsset('/assets/lib/json-formatter/json-formatter.umd.js'),
57+
staticAsset('/assets/js/ohtheme.js'),
5058
],
5159
themeConfig: {
5260
image: 'img/logo.svg',

0 commit comments

Comments
 (0)