Skip to content

Commit

Permalink
modified: next.config.js
Browse files Browse the repository at this point in the history
	modified:   pages/_document.js
  • Loading branch information
MusherM committed May 30, 2024
1 parent a7eea8c commit 432ca0e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 37 deletions.
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const isProd = process.env.NODE_ENV === "production";
module.exports = {
basePath: isProd ? "/nobelium" : "",
assetPrefix: isProd ? "/nobelium/" : "",
publicRuntimeConfig: {
basePath: isProd ? "/nobelium" : "",
assetPrefix: isProd ? "/nobelium/" : "",
},
webpack5: true,
images: {
// domains: ['gravatar.com']
Expand Down
97 changes: 60 additions & 37 deletions pages/_document.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'
import BLOG from '@/blog.config'
import CJK from '@/lib/cjk'
import Document, { Html, Head, Main, NextScript } from "next/document";
import BLOG from "@/blog.config";
import CJK from "@/lib/cjk";
import { basePath } from "@/next.config";
class MyDocument extends Document {
static async getInitialProps (ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}

render () {
render() {
return (
<Html
lang={BLOG.lang}
className={BLOG.appearance === 'dark' ? 'dark' : undefined}
className={BLOG.appearance === "dark" ? "dark" : undefined}
>
<Head>
{BLOG.font && BLOG.font === 'serif'
? (
{BLOG.font && BLOG.font === "serif" ? (
<>
<link
rel="preload"
href="/fonts/SourceSerif.var.woff2"
href={basePath + "/fonts/SourceSerif.var.woff2"}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/fonts/SourceSerif-Italic.var.woff2"
href={basePath + "/fonts/SourceSerif-Italic.var.woff2"}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
</>
)
: (
) : (
<>
<link
rel="preload"
href="/fonts/IBMPlexSansVar-Roman.woff2"
href={basePath + "/fonts/IBMPlexSansVar-Roman.woff2"}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/fonts/IBMPlexSansVar-Italic.woff2"
href={basePath + "/fonts/IBMPlexSansVar-Italic.woff2"}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
</>
)}
)}

{['zh', 'ja', 'ko'].includes(
{["zh", "ja", "ko"].includes(
BLOG.lang.slice(0, 2).toLocaleLowerCase()
) && (
<>
Expand All @@ -65,48 +63,73 @@ class MyDocument extends Document {
rel="preload"
as="style"
href={`https://fonts.googleapis.com/css2?family=Noto+${
BLOG.font === 'serif' ? 'Serif' : 'Sans'
BLOG.font === "serif" ? "Serif" : "Sans"
}+${CJK()}:wght@400;500;700&display=swap`}
/>
<link
rel="stylesheet"
href={`https://fonts.googleapis.com/css2?family=Noto+${
BLOG.font === 'serif' ? 'Serif' : 'Sans'
BLOG.font === "serif" ? "Serif" : "Sans"
}+${CJK()}:wght@400;500;700&display=swap`}
/>
<noscript>
<link
rel="stylesheet"
href={`https://fonts.googleapis.com/css2?family=Noto+${
BLOG.font === 'serif' ? 'Serif' : 'Sans'
BLOG.font === "serif" ? "Serif" : "Sans"
}+${CJK()}:wght@400;500;700&display=swap`}
/>
</noscript>
</>
)}
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="192x192" href="/apple-touch-icon.png"></link>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/feed"></link>
{BLOG.appearance === 'auto'
? (
<link
rel="icon"
href={basePath + "/favicon.svg"}
type="image/svg+xml"
/>
<link rel="icon" href={basePath + "/favicon.ico"} />
<link
rel="apple-touch-icon"
sizes="192x192"
href={basePath + "/apple-touch-icon.png"}
></link>
<link
rel="alternate"
type="application/rss+xml"
title="RSS 2.0"
href={basePath + "/feed"}
></link>
{BLOG.appearance === "auto" ? (
<>
<meta name="theme-color" content={BLOG.lightBackground} media="(prefers-color-scheme: light)"/>
<meta name="theme-color" content={BLOG.darkBackground} media="(prefers-color-scheme: dark)"/>
<meta
name="theme-color"
content={BLOG.lightBackground}
media="(prefers-color-scheme: light)"
/>
<meta
name="theme-color"
content={BLOG.darkBackground}
media="(prefers-color-scheme: dark)"
/>
</>
)
: (
<meta name="theme-color" content={BLOG.appearance === 'dark' ? BLOG.darkBackground : BLOG.lightBackground} />
)
}
) : (
<meta
name="theme-color"
content={
BLOG.appearance === "dark"
? BLOG.darkBackground
: BLOG.lightBackground
}
/>
)}
</Head>
<body className="bg-day dark:bg-night">
<Main />
<NextScript />
</body>
</Html>
)
);
}
}

export default MyDocument
export default MyDocument;

0 comments on commit 432ca0e

Please sign in to comment.