Skip to content

Commit

Permalink
Test github pages deployment #4
Browse files Browse the repository at this point in the history
  • Loading branch information
fongsean committed May 14, 2024
1 parent d3eb508 commit 8f99d9f
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
110 changes: 110 additions & 0 deletions deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
function handler(event) {
var request = event.request;
var uri = request.uri;

// Handle ACDC Pilot routes
if (uri.includes('/acdcpilot')) {
if (uri.startsWith('/acdcpilot/fhir/Questionnaire')) {
// Rewrite the URI to the specific S3 object path
request.uri = '/acdcpilot/fhir/Questionnaire.json';
}

return request;
}

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

if (uri === '/ig') {
request.uri += '/index.html';
return request;
}

// Append ".html to IG subroutes"
// if(uri.endsWith('.')) {
// request.uri += 'html';
// return request;
// }

// Replace http://example.com/ig/* into http://example.com/ig/*/index.html
if (uri.includes('.')) {
var parts = uri.split('.');
if (parts[parts.length - 1].match(/[0-9]/)) {
if (uri.match(/\/ig\/[a-z0-9]+/i)) {
if (uri.endsWith('/')) {
request.uri += 'redirect.html';
return request;
}

// if uri is /ig/* without a trailing slash
request.uri += '/redirect.html';
return request;
}
}
}

// Replace http://example.com/ig/* into http://example.com/ig/*/index.html
// if (uri.match(/\/ig\/[a-z0-9]+\//i)) {
// request.uri += "index.html";
// return request;
// }

var uriChunks = uri.split('/');
var lastUriChunk = uriChunks[uriChunks.length - 1];
if (!lastUriChunk.includes('.')) {
request.uri += '.html';
return request;
}
}

// Handle Storybook routes
if (uri.includes('/storybook')) {
// Reroute to smartforms.csiro.au/ig/index.html
if (uri === '/storybook/') {
request.uri += 'index.html';
return request;
}

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

return request;
}

// Handle Forms Server API routes
if (uri.includes('/api')) {
// Remove the /api prefix
if (uri.startsWith('/api/')) {
request.uri = uri.replace('/api', '');
return request;
}

if (uri === '/api') {
request.uri = '/';
return request;
}
}

// Handle EHR Launcher routes
if (uri.includes('/ehr')) {
// Remove the /ehr prefix
if (uri.startsWith('/ehr/')) {
request.uri = uri.replace('/ehr', '');
return request;
}

if (uri === '/ehr') {
request.uri = '/';
return request;
}
}

return request;
}
18 changes: 13 additions & 5 deletions documentation/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const config: Config = {
items: [
{
type: 'docSidebar',
sidebarId: 'gettingStartedSidebar',
sidebarId: 'tutorialSidebar',
position: 'left',
label: 'Getting Started'
label: 'Documentation'
},
// { to: '/blog', label: 'Blog', position: 'left' },
{
Expand All @@ -82,10 +82,18 @@ const config: Config = {
style: 'dark',
links: [
{
title: 'Docs',
title: 'Documentation',
items: [
{
label: 'Docs',
label: 'Developer Usage',
to: '/docs/intro'
},
{
label: 'Components',
to: '/docs/category/components'
},
{
label: 'Structured Data Capture',
to: '/docs/intro'
}
]
Expand Down Expand Up @@ -138,7 +146,7 @@ const config: Config = {
resolve: {
alias: {
// assuming root node_modules is up from "./packages/<your-docusaurus>
react: path.resolve('../../node_modules/react')
react: path.resolve('../node_modules/react')
}
}
};
Expand Down
1 change: 1 addition & 0 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 8f99d9f

Please sign in to comment.