Skip to content

Commit 2971089

Browse files
authored
Merge pull request #8 from QwenLM/sync
feat: add environment-aware asset prefix for GitHub Pages deployment
2 parents 781f8ac + 9e185c7 commit 2971089

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

website/app/layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ type LayoutProps = Readonly<{
3232
}>;
3333

3434
const RootLayout: FC<LayoutProps> = ({ children }) => {
35+
// 根据环境设置字体路径前缀
36+
const isProduction = process.env.NODE_ENV === "production";
37+
const fontPrefix = isProduction ? "/qwen-code-docs" : "";
38+
3539
return (
3640
<html suppressHydrationWarning>
3741
<Head
@@ -44,7 +48,9 @@ const RootLayout: FC<LayoutProps> = ({ children }) => {
4448
saturation: { dark: 74, light: 74 },
4549
}}
4650
/>
47-
<body>{children}</body>
51+
<body style={{ "--font-prefix": fontPrefix } as React.CSSProperties}>
52+
{children}
53+
</body>
4854
</html>
4955
);
5056
};

website/mdx-components.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import type { ImgHTMLAttributes } from "react";
88
// 自定义 img 组件,动态替换路径
99
const CustomImg = (props: ImgHTMLAttributes<HTMLImageElement>) => {
1010
const { src, ...rest } = props;
11-
// 将 ../assets/ 替换为 /assets/
12-
const adjustedSrc = src?.replace(/\.\.\/assets\//, "/assets/");
11+
// 根据环境设置资源前缀
12+
const isProduction = process.env.NODE_ENV === "production";
13+
const assetPrefix = isProduction ? "/qwen-code-docs" : "";
14+
// 将 ../assets/ 替换为带前缀的 /assets/
15+
const adjustedSrc = src?.replace(/\.\.\/assets\//, `${assetPrefix}/assets/`);
1316
return <img src={adjustedSrc} {...rest} />;
1417
};
1518

website/public/Orbitron.zip

-189 KB
Binary file not shown.

website/src/styles/globals.css

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,99 +4,113 @@
44
@source "../**/*.{ts,tsx}";
55

66
/* Terminal/Monospace Fonts */
7-
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Fira+Code:wght@300..700&display=swap');
7+
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Fira+Code:wght@300..700&display=swap");
88

99
/* Local Monoton Font */
1010
@font-face {
11-
font-family: 'Monoton';
12-
src: url('/Monoton/Monoton-Regular.ttf') format('truetype');
11+
font-family: "Monoton";
12+
src: url('var(--font-prefix, "")/Monoton/Monoton-Regular.ttf')
13+
format("truetype");
1314
font-weight: normal;
1415
font-style: normal;
1516
font-display: swap;
1617
}
1718

1819
/* Local Orbitron Font - Multiple Weights */
1920
@font-face {
20-
font-family: 'Orbitron';
21-
src: url('/Orbitron/Orbitron-VariableFont_wght.ttf') format('truetype-variations');
21+
font-family: "Orbitron";
22+
src: url('var(--font-prefix, "")/Orbitron/Orbitron-VariableFont_wght.ttf')
23+
format("truetype-variations");
2224
font-weight: 400 900;
2325
font-style: normal;
2426
font-display: swap;
2527
}
2628

2729
@font-face {
28-
font-family: 'Orbitron';
29-
src: url('/Orbitron/static/Orbitron-Regular.ttf') format('truetype');
30+
font-family: "Orbitron";
31+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-Regular.ttf')
32+
format("truetype");
3033
font-weight: 400;
3134
font-style: normal;
3235
font-display: swap;
3336
}
3437

3538
@font-face {
36-
font-family: 'Orbitron';
37-
src: url('/Orbitron/static/Orbitron-Medium.ttf') format('truetype');
39+
font-family: "Orbitron";
40+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-Medium.ttf')
41+
format("truetype");
3842
font-weight: 500;
3943
font-style: normal;
4044
font-display: swap;
4145
}
4246

4347
@font-face {
44-
font-family: 'Orbitron';
45-
src: url('/Orbitron/static/Orbitron-SemiBold.ttf') format('truetype');
48+
font-family: "Orbitron";
49+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-SemiBold.ttf')
50+
format("truetype");
4651
font-weight: 600;
4752
font-style: normal;
4853
font-display: swap;
4954
}
5055

5156
@font-face {
52-
font-family: 'Orbitron';
53-
src: url('/Orbitron/static/Orbitron-Bold.ttf') format('truetype');
57+
font-family: "Orbitron";
58+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-Bold.ttf')
59+
format("truetype");
5460
font-weight: 700;
5561
font-style: normal;
5662
font-display: swap;
5763
}
5864

5965
@font-face {
60-
font-family: 'Orbitron';
61-
src: url('/Orbitron/static/Orbitron-ExtraBold.ttf') format('truetype');
66+
font-family: "Orbitron";
67+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-ExtraBold.ttf')
68+
format("truetype");
6269
font-weight: 800;
6370
font-style: normal;
6471
font-display: swap;
6572
}
6673

6774
@font-face {
68-
font-family: 'Orbitron';
69-
src: url('/Orbitron/static/Orbitron-Black.ttf') format('truetype');
75+
font-family: "Orbitron";
76+
src: url('var(--font-prefix, "")/Orbitron/static/Orbitron-Black.ttf')
77+
format("truetype");
7078
font-weight: 900;
7179
font-style: normal;
7280
font-display: swap;
7381
}
7482

7583
/* Terminal cursor animation */
7684
@keyframes cursor-blink {
77-
0%, 50% { opacity: 1; }
78-
51%, 100% { opacity: 0; }
85+
0%,
86+
50% {
87+
opacity: 1;
88+
}
89+
51%,
90+
100% {
91+
opacity: 0;
92+
}
7993
}
8094

8195
.terminal-cursor {
8296
animation: cursor-blink 1s infinite;
8397
}
8498

8599
.terminal-text {
86-
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
100+
font-family: "JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace;
87101
}
88102

89103
.code-font {
90-
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
104+
font-family: "JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace;
91105
}
92106

93107
.monoton-font {
94-
font-family: 'Monoton', monospace;
108+
font-family: "Monoton", monospace;
95109
letter-spacing: 0.1em;
96110
}
97111

98112
.orbitron-font {
99-
font-family: 'Orbitron', sans-serif;
113+
font-family: "Orbitron", sans-serif;
100114
letter-spacing: 0.05em;
101115
}
102116

@@ -115,7 +129,7 @@
115129

116130
/* Scanline effect for terminal aesthetic with purple tint */
117131
.scanlines::before {
118-
content: '';
132+
content: "";
119133
position: absolute;
120134
top: 0;
121135
left: 0;

0 commit comments

Comments
 (0)