Skip to content

Commit cdabf73

Browse files
authored
chore: Issue 2022 - Changes for new React boilerplate code (#88)
1 parent b8b91e2 commit cdabf73

8 files changed

Lines changed: 1252 additions & 916 deletions

File tree

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PUBLIC_URL=https://visual-framework.github.io/vf-react

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
CI: true
12+
PUBLIC_URL: /vf-react
1213

1314
jobs:
1415
# test:
@@ -44,8 +45,10 @@ jobs:
4445
run: yarn install
4546
- name: Build page
4647
run: yarn build
48+
env:
49+
PUBLIC_URL: /vf-react
4750
- name: Deploy to gh-pages
4851
uses: peaceiris/actions-gh-pages@v3
4952
with:
5053
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY_150525 }}
51-
publish_dir: ./build
54+
publish_dir: ./build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "vf-react",
33
"version": "0.1.0",
44
"private": true,
5+
"homepage": "https://visual-framework.github.io/vf-react/",
56
"dependencies": {
67
"@testing-library/jest-dom": "^5.17.0",
78
"@testing-library/react": "^13.4.0",

public/404.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Visual Framework React</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License
9+
// https://github.com/rafgraph/spa-github-pages
10+
var pathSegmentsToKeep = 1;
11+
12+
var l = window.location;
13+
l.replace(
14+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
15+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
16+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
17+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
18+
l.hash
19+
);
20+
</script>
21+
</head>
22+
<body>
23+
</body>
24+
</html>

public/index.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<base href="/">
6+
<base href="%PUBLIC_URL%/">
7+
8+
<!-- GitHub Pages SPA redirect script -->
9+
<script type="text/javascript">
10+
// Single Page Apps for GitHub Pages
11+
// MIT License
12+
// https://github.com/rafgraph/spa-github-pages
13+
(function(l) {
14+
if (l.search[1] === '/' ) {
15+
var decoded = l.search.slice(1).split('&').map(function(s) {
16+
return s.replace(/~and~/g, '&')
17+
}).join('?');
18+
window.history.replaceState(null, null,
19+
l.pathname.slice(0, -1) + decoded + l.hash
20+
);
21+
}
22+
}(window.location))
23+
</script>
24+
725
<link rel="stylesheet" media="all" href="https://dev.assets.emblstatic.net/vf/develop/css/styles.css"/>
826
<!--
927
Want to build a site with the Visual Framework?
@@ -43,4 +61,4 @@
4361
</head>
4462
<body class="vf-body | vf-stack embl-content-hub-loaded">
4563
</body>
46-
</html>
64+
</html>

src/App.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect } from 'react';
2-
import { BrowserRouter as Router, Routes, Route, useLocation } from 'react-router-dom';
2+
import { HashRouter as Router, Routes, Route, useLocation } from 'react-router-dom';
33
import Header from './components/Header';
44
import Footer from './components/Footer';
55
import Home from './components/Home';
@@ -31,6 +31,7 @@ function RouteChangeHandler({ children }) {
3131
}
3232

3333
function App() {
34+
// Use HashRouter instead of BrowserRouter for GitHub Pages
3435
return (
3536
<Router>
3637
<RouteChangeHandler>

yarn.lock

Lines changed: 1198 additions & 912 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)