Skip to content

Commit

Permalink
fix: github pages paths
Browse files Browse the repository at this point in the history
  • Loading branch information
xtools-at committed Oct 20, 2023
1 parent 52a3169 commit 4a3e83a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions config/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
basePath: "/smartcontract-ui",
};
6 changes: 4 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const config = require("./config/app");

module.exports = {
reactStrictMode: true,
assetPrefix: process.env.ASSET_PREFIX || "/smartcontract-ui",
basePath: "/smartcontract-ui",
assetPrefix: config.basePath ? `${config.basePath}/` : "",
basePath: config.basePath,
};
13 changes: 10 additions & 3 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react";
import Document, { Html, Head, Main, NextScript } from "next/document";
import createEmotionServer from "@emotion/server/create-instance";
import createEmotionCache from "utils/createEmotionCache";
import { basePath } from "../config/app";

export default class MyDocument extends Document {
render() {
Expand All @@ -12,8 +13,12 @@ export default class MyDocument extends Document {
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<link rel="icon" href="/icons/fav.png" type="image/png" />
<link rel="manifest" href="/manifest.json" />
<link
rel="icon"
href={`${basePath || ""}/icons/fav.png`}
type="image/png"
/>
<link rel="manifest" href={`${basePath || ""}/manifest.json`} />
<script
dangerouslySetInnerHTML={{
__html: `
Expand Down Expand Up @@ -41,7 +46,9 @@ export default class MyDocument extends Document {

<script
dangerouslySetInnerHTML={{
__html: `if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/smartcontract-ui/sw.js') }`,
__html: `if ('serviceWorker' in navigator) { navigator.serviceWorker.register('${
basePath || ""
}/sw.js') }`,
}}
></script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "Smart Contract UI",
"icons": [
{
"src": "smartcontract-ui/icons/192.png",
"src": "/smartcontract-ui/icons/192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "smartcontract-ui/icons/512.png",
"src": "/smartcontract-ui/icons/512.png",
"type": "image/png",
"sizes": "512x512"
}
Expand Down

0 comments on commit 4a3e83a

Please sign in to comment.