Skip to content

Commit

Permalink
Fix SSR bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
shiro committed Apr 4, 2024
1 parent f63afaa commit 6e5a35a
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/components/SVG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function getInitialData(src: string, async?: boolean) {
} else {
// if (src.startsWith(config.resourceBaseURL))
// src = src.slice(config.resourceBaseURL.length);
if (src.startsWith(config.base)) src = src.slice(config.base.length);

src = path.join(process.cwd(), "public", src);

Expand Down
1 change: 0 additions & 1 deletion src/ssg/getArticles.ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const getArticlesSSG = () => {

const title = frontmatter.title ?? raw.match(/# [^\n]*/)![0].slice(2);
const description = raw.match(/# [^\n]+\n+([\s\S]+?)(?=\n\n)/)?.[1];
console.log(description);

const url = `/articles/${x.split(".")[0]}`;
const date = x.split("-").slice(0, 3).reverse().join(".");
Expand Down
54 changes: 29 additions & 25 deletions src/style/fontFaces.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { config } from "~/config";

type FontLoader = (font: string, format: string) => string;

const japaneseCodeRange = (show: boolean) =>
show ? `unicode-range: U+3000-30FF , U+FF00-FFEF , U+4E00-9FAF ;` : "";
const nameSuffix = (isFull: boolean) => (isFull ? "" : " JP Only");

const interPath = `/fonts/inter-3.19-roman/Inter`;
const fontPath = `${config.base}/fonts/`;
const interPath = `${fontPath}/inter-3.19-roman`;
const notoPath = `${fontPath}/noto-sans-jp-v40`;

// language=SCSS
const notoFragments = (isFull: boolean, fontLoader?: FontLoader) => `
Expand All @@ -15,17 +19,17 @@ const notoFragments = (isFull: boolean, fontLoader?: FontLoader) => `
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('${interPath}/noto-sans-jp-v40-japanese-regular.eot'); /* IE9 Compat Modes */
src: url('${notoPath}/noto-sans-jp-v40-japanese-regular.eot'); /* IE9 Compat Modes */
src: local('Noto Sans Japanese Regular'),
local('NotoSansJapanese-Regular'),
url('${interPath}/noto-sans-jp-v40-japanese-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('${interPath}/noto-sans-jp-v40-japanese-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/noto-sans-jp-v40-japanese-regular.woff') format('woff'), /* Modern Browsers */
url('${interPath}/noto-sans-jp-v40-japanese-regular.svg#NotoSansJP') format('svg'); /* Legacy iOS */
url('${notoPath}/noto-sans-jp-v40-japanese-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('${notoPath}/noto-sans-jp-v40-japanese-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('${notoPath}/noto-sans-jp-v40-japanese-regular.woff') format('woff'), /* Modern Browsers */
url('${notoPath}/noto-sans-jp-v40-japanese-regular.svg#NotoSansJP') format('svg'); /* Legacy iOS */
${
fontLoader != null
? `src: ${fontLoader(
`${interPath}/noto-sans-jp-v40-japanese-regular.woff2`,
`${notoPath}/noto-sans-jp-v40-japanese-regular.woff2`,
"woff2"
)};`
: ``
Expand All @@ -39,17 +43,17 @@ const notoFragments = (isFull: boolean, fontLoader?: FontLoader) => `
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('${interPath}/noto-sans-jp-v40-japanese-700.eot'); /* IE9 Compat Modes */
src: url('${notoPath}/noto-sans-jp-v40-japanese-700.eot'); /* IE9 Compat Modes */
src: local('Noto Sans Japanese Medium'),
local('NotoSansJapanese-Medium'),
url('${interPath}/noto-sans-jp-v40-japanese-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('${interPath}/noto-sans-jp-v40-japanese-700.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/noto-sans-jp-v40-japanese-700.woff') format('woff'), /* Modern Browsers */
url('${interPath}/noto-sans-jp-v40-japanese-700.svg#NotoSansJP') format('svg'); /* Legacy iOS */
url('${notoPath}/noto-sans-jp-v40-japanese-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('${notoPath}/noto-sans-jp-v40-japanese-700.woff2') format('woff2'), /* Super Modern Browsers */
url('${notoPath}/noto-sans-jp-v40-japanese-700.woff') format('woff'), /* Modern Browsers */
url('${notoPath}/noto-sans-jp-v40-japanese-700.svg#NotoSansJP') format('svg'); /* Legacy iOS */
${
fontLoader != null
? `src: ${fontLoader(
`${interPath}/noto-sans-jp-v40-japanese-700.woff2`,
`${notoPath}/noto-sans-jp-v40-japanese-700.woff2`,
"woff2"
)};`
: ``
Expand All @@ -75,11 +79,11 @@ export const fontFaceFragment = (fontLoader?: FontLoader) => `
font-weight: 400;
font-display: swap;
src: local(''),
url('${interPath}-Regular-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}-Regular-Roman.woff') format('woff'), /* Modern Browsers */
url('${interPath}/Inter-Regular-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/Inter-Regular-Roman.woff') format('woff'), /* Modern Browsers */
${
fontLoader != null
? `src: ${fontLoader(`${interPath}-Regular-Roman.woff2`, "woff2")};`
? `src: ${fontLoader(`${interPath}/Inter-Regular-Roman.woff2`, "woff2")};`
: ``
}
}
Expand All @@ -90,11 +94,11 @@ export const fontFaceFragment = (fontLoader?: FontLoader) => `
font-weight: 400;
font-display: swap;
src: local(''),
url('${interPath}-Italic-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}-Italic-Roman.woff') format('woff'), /* Modern Browsers */
url('${interPath}/Inter-Italic-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/Inter-Italic-Roman.woff') format('woff'), /* Modern Browsers */
${
fontLoader != null
? `src: ${fontLoader(`${interPath}-Italic-Roman.woff2`, "woff2")};`
? `src: ${fontLoader(`${interPath}/Inter-Italic-Roman.woff2`, "woff2")};`
: ``
}
}
Expand All @@ -106,11 +110,11 @@ export const fontFaceFragment = (fontLoader?: FontLoader) => `
font-weight: 600;
font-display: swap;
src: local('Inter SemiBold'),
url('${interPath}-SemiBold-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}-SemiBold-Roman.woff') format('woff'), /* Modern Browsers */
url('${interPath}/Inter-SemiBold-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/Inter-SemiBold-Roman.woff') format('woff'), /* Modern Browsers */
${
fontLoader != null
? `src: ${fontLoader(`${interPath}-SemiBold-Roman.woff2`, "woff2")};`
? `src: ${fontLoader(`${interPath}/Inter-SemiBold-Roman.woff2`, "woff2")};`
: ``
}
}
Expand All @@ -121,12 +125,12 @@ export const fontFaceFragment = (fontLoader?: FontLoader) => `
font-weight: 600;
font-display: swap;
src: local('Inter SemiBold'),
url('${interPath}-SemiBoldItalic-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}-SemiBoldItalic-Roman.woff') format('woff'), /* Modern Browsers */
url('${interPath}/Inter-SemiBoldItalic-Roman.woff2') format('woff2'), /* Super Modern Browsers */
url('${interPath}/Inter-SemiBoldItalic-Roman.woff') format('woff'), /* Modern Browsers */
${
fontLoader != null
? `src: ${fontLoader(
`${interPath}-SemiBoldItalic-Roman.woff2`,
`${interPath}/Inter-SemiBoldItalic-Roman.woff2`,
"woff2"
)};`
: ``
Expand Down

0 comments on commit 6e5a35a

Please sign in to comment.