Use relative paths for static resources, and fix some lint errors

pull/1131/head
Shihira Fung 2024-10-28 00:48:13 +08:00
parent fff01410d5
commit 7d0dc6d907
5 changed files with 13 additions and 19 deletions

View File

@ -30,7 +30,7 @@ export const toRealUrl = <T extends (string | URL)>(url : T) : T => {
export const toInternalUrl = (url : string) => {
if (url.startsWith('http://') || url.startsWith('https://')) {
var parsedUrl = new URL(url);
const parsedUrl = new URL(url);
if (parsedUrl.pathname.startsWith(urlPrefix)) {
parsedUrl.pathname = parsedUrl.pathname.substr(urlPrefix.length);
return parsedUrl.href;

View File

@ -40,7 +40,7 @@ export async function updateMarkdownPreview() {
"rhs",
2,
`
<link rel="stylesheet" href="/.client/main.css" />
<link rel="stylesheet" href=".client/main.css" />
<style>
${css}
${customStyles ?? ""}

View File

@ -287,7 +287,7 @@ export class HttpServer {
if (req.method === "GET") {
if (assetName === "service_worker.js") {
c.header("Cache-Control", "no-cache");
const textData = new TextDecoder().decode(data as Uint8Array);
const textData = new TextDecoder().decode(data);
// console.log(
// "Swapping out config hash in service worker",
// );
@ -302,12 +302,6 @@ export class HttpServer {
),
);
}
if (assetName.endsWith(".css")) {
const textData = new TextDecoder().decode(data as Uint8Array);
data = textData.replaceAll(
"{{URL_PREFIX}}",
urlPrefix);
}
return Promise.resolve(c.body(data));
} // else e.g. HEAD, OPTIONS, don't send body
} catch {

View File

@ -7,7 +7,7 @@
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<base href="{{URL_PREFIX}}/" />
<link rel="apple-touch-icon" href="{{URL_PREFIX}}/.client/logo.png" />
<link rel="apple-touch-icon" href=".client/logo.png" />
<meta
name="theme-color"
content="#e1e1e1"
@ -21,7 +21,7 @@
<meta name="referrer" content="no-referrer" />
<title>{{TITLE}}</title>
<meta property="og:image" content="{{URL_PREFIX}}/.client/logo.png" />
<meta property="og:image" content=".client/logo.png" />
<meta property="og:description" content="{{DESCRIPTION}}" />
<script>
@ -68,11 +68,11 @@
};
}
</script>
<link rel="stylesheet" href="{{URL_PREFIX}}/.client/main.css" />
<link rel="stylesheet" href=".client/main.css" />
<style id="custom-styles"></style>
<script type="module" src="{{URL_PREFIX}}/.client/client.js"></script>
<link rel="manifest" href="{{URL_PREFIX}}/.client/manifest.json" />
<link rel="icon" type="image/x-icon" href="{{URL_PREFIX}}/.client/favicon.png" />
<script type="module" src=".client/client.js"></script>
<link rel="manifest" href=".client/manifest.json" />
<link rel="icon" type="image/x-icon" href=".client/favicon.png" />
</head>
<body>

View File

@ -5,28 +5,28 @@
@font-face {
font-family: "iA-Mono";
src: url("{{URL_PREFIX}}/.client/iAWriterMonoS-Regular.woff2");
src: url("iAWriterMonoS-Regular.woff2");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "iA-Mono";
src: url("{{URL_PREFIX}}/.client/iAWriterMonoS-Bold.woff2");
src: url("iAWriterMonoS-Bold.woff2");
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: "iA-Mono";
src: url("{{URL_PREFIX}}/.client/iAWriterMonoS-Italic.woff2");
src: url("iAWriterMonoS-Italic.woff2");
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: "iA-Mono";
src: url("{{URL_PREFIX}}/.client/iAWriterMonoS-BoldItalic.woff2");
src: url("iAWriterMonoS-BoldItalic.woff2");
font-weight: bold;
font-style: italic;
}