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) => { export const toInternalUrl = (url : string) => {
if (url.startsWith('http://') || url.startsWith('https://')) { if (url.startsWith('http://') || url.startsWith('https://')) {
var parsedUrl = new URL(url); const parsedUrl = new URL(url);
if (parsedUrl.pathname.startsWith(urlPrefix)) { if (parsedUrl.pathname.startsWith(urlPrefix)) {
parsedUrl.pathname = parsedUrl.pathname.substr(urlPrefix.length); parsedUrl.pathname = parsedUrl.pathname.substr(urlPrefix.length);
return parsedUrl.href; return parsedUrl.href;

View File

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

View File

@ -287,7 +287,7 @@ export class HttpServer {
if (req.method === "GET") { if (req.method === "GET") {
if (assetName === "service_worker.js") { if (assetName === "service_worker.js") {
c.header("Cache-Control", "no-cache"); c.header("Cache-Control", "no-cache");
const textData = new TextDecoder().decode(data as Uint8Array); const textData = new TextDecoder().decode(data);
// console.log( // console.log(
// "Swapping out config hash in service worker", // "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)); return Promise.resolve(c.body(data));
} // else e.g. HEAD, OPTIONS, don't send body } // else e.g. HEAD, OPTIONS, don't send body
} catch { } 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" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/> />
<base href="{{URL_PREFIX}}/" /> <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 <meta
name="theme-color" name="theme-color"
content="#e1e1e1" content="#e1e1e1"
@ -21,7 +21,7 @@
<meta name="referrer" content="no-referrer" /> <meta name="referrer" content="no-referrer" />
<title>{{TITLE}}</title> <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}}" /> <meta property="og:description" content="{{DESCRIPTION}}" />
<script> <script>
@ -68,11 +68,11 @@
}; };
} }
</script> </script>
<link rel="stylesheet" href="{{URL_PREFIX}}/.client/main.css" /> <link rel="stylesheet" href=".client/main.css" />
<style id="custom-styles"></style> <style id="custom-styles"></style>
<script type="module" src="{{URL_PREFIX}}/.client/client.js"></script> <script type="module" src=".client/client.js"></script>
<link rel="manifest" href="{{URL_PREFIX}}/.client/manifest.json" /> <link rel="manifest" href=".client/manifest.json" />
<link rel="icon" type="image/x-icon" href="{{URL_PREFIX}}/.client/favicon.png" /> <link rel="icon" type="image/x-icon" href=".client/favicon.png" />
</head> </head>
<body> <body>

View File

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