Skip to content

Commit ee71978

Browse files
committed
Fix: 将网站部署到根路径,移除所有 basePath 依赖
- 移除部署工作流中的 NEXT_PUBLIC_BASE_PATH 和重定向配置 - 移除所有页面中的 withBase 函数使用 - 更新 metadataBase 为根路径 https://hint-lab.github.io - 修复所有图片和资源路径,直接使用绝对路径
1 parent a87d3db commit ee71978

File tree

7 files changed

+13
-20
lines changed

7 files changed

+13
-20
lines changed

app/components/LangSwitch.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Link from 'next/link';
44
import { usePathname } from 'next/navigation';
55
import { useEffect, useRef, useState } from 'react';
66
import Image from 'next/image';
7-
import { withBase } from '../lib/paths';
87
export default function LangSwitch() {
98
const pathname = usePathname();
109
const current = pathname.startsWith('/en') ? 'en' : pathname.startsWith('/ja') ? 'ja' : 'zh';
@@ -39,7 +38,7 @@ export default function LangSwitch() {
3938
<div className="lang-dropdown">
4039

4140
<button ref={btnRef} className="btn btn-outline btn-inline" aria-haspopup="menu" aria-expanded={open} onClick={() => setOpen(v => !v)}>
42-
<Image src={withBase("/language-svgrepo-com.svg")} alt="H!NT Lab" width={20} height={20} />
41+
<Image src="/language-svgrepo-com.svg" alt="H!NT Lab" width={20} height={20} />
4342
{currentLabel}
4443
</button>
4544
{open && (

app/en/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from '../components/LangSwitch';
22
import SideToc from '../components/SideToc';
33
import Link from 'next/link';
44
import { getDict } from '../lib/i18n';
5-
import { withBase } from '../lib/paths';
65
import Image from 'next/image';
76
import { Brain, Lightbulb, FileText } from 'lucide-react';
87

@@ -38,7 +37,7 @@ export default function HomePageEN() {
3837
<div className="container">
3938
{/* Logo */}
4039
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: '32px' }}>
41-
<Image src={withBase("/hint-lab-logo.svg")} alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
40+
<Image src="/hint-lab-logo.svg" alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
4241
</div>
4342

4443
{/* Title and Subtitle */}
@@ -120,7 +119,7 @@ export default function HomePageEN() {
120119
{t.projects.cards.map((project: any, idx: number) => (
121120
<a key={idx} href={project.link} target="_blank" rel="noopener noreferrer" className="project-card">
122121
{project.status && <div className="project-status">{project.status}</div>}
123-
<Image src={withBase(project.logo)} alt={project.name} width={160} height={120} className="project-logo" />
122+
<Image src={project.logo} alt={project.name} width={160} height={120} className="project-logo" />
124123
<div className="project-content">
125124
<h3>{project.name}</h3>
126125
<p>{project.description}</p>

app/ja/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from '../components/LangSwitch';
22
import Link from 'next/link';
33
import SideToc from '../components/SideToc';
44
import { getDict } from '../lib/i18n';
5-
import { withBase } from '../lib/paths';
65
import Image from 'next/image';
76
import { Brain, Lightbulb, FileText } from 'lucide-react';
87

@@ -38,7 +37,7 @@ export default function HomePageJA() {
3837
<div className="container">
3938
{/* Logo */}
4039
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: '32px' }}>
41-
<Image src={withBase("/hint-lab-logo.svg")} alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
40+
<Image src="/hint-lab-logo.svg" alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
4241
</div>
4342

4443
{/* タイトルとサブタイトル */}
@@ -120,7 +119,7 @@ export default function HomePageJA() {
120119
{t.projects.cards.map((project: any, idx: number) => (
121120
<a key={idx} href={project.link} target="_blank" rel="noopener noreferrer" className="project-card">
122121
{project.status && <div className="project-status">{project.status}</div>}
123-
<Image src={withBase(project.logo)} alt={project.name} width={160} height={120} className="project-logo" />
122+
<Image src={project.logo} alt={project.name} width={160} height={120} className="project-logo" />
124123
<div className="project-content">
125124
<h3>{project.name}</h3>
126125
<p>{project.description}</p>

app/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from './components/LangSwitch';
22
import Link from 'next/link';
33
import SideToc from './components/SideToc';
44
import { getDict } from './lib/i18n';
5-
import { withBase } from './lib/paths';
65
import Image from 'next/image';
76
import { Brain, Lightbulb, FileText } from 'lucide-react';
87

@@ -38,7 +37,7 @@ export default function HomePage() {
3837
<div className="container">
3938
{/* Logo */}
4039
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: '32px' }}>
41-
<Image src={withBase("/hint-lab-logo.svg")} alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
40+
<Image src="/hint-lab-logo.svg" alt="H!NT Lab Logo" width={300} height={300} style={{ width: 'auto', height: '120px' }} />
4241
</div>
4342

4443
{/* 标题和副标题 */}
@@ -108,7 +107,7 @@ export default function HomePage() {
108107
{t.projects.cards.map((project: any, idx: number) => (
109108
<a key={idx} href={project.link} target="_blank" rel="noopener noreferrer" className="project-card">
110109
{project.status && <div className="project-status">{project.status}</div>}
111-
<Image src={withBase(project.logo)} alt={project.name} width={160} height={120} className="project-logo" />
110+
<Image src={project.logo} alt={project.name} width={160} height={120} className="project-logo" />
112111
<div className="project-content">
113112
<h3>{project.name}</h3>
114113
<p>{project.description}</p>

app/people/wang_hao/en/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from '../../../components/LangSwitch';
22
import Link from 'next/link';
33
import SideToc from '../../../components/SideToc';
44
import { getDict } from '../../../lib/i18n';
5-
import { withBase } from '../../../lib/paths';
65
import Image from 'next/image';
76

87
export default function WangHaoPageEN() {
@@ -32,7 +31,7 @@ export default function WangHaoPageEN() {
3231
<h2 className="section-title">{t.about.title}</h2>
3332
<div className="about-grid">
3433
<div className="about-photo">
35-
<Image src={withBase("/wang_hao.jpeg")} alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
34+
<Image src="/wang_hao.jpeg" alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
3635
</div>
3736
<div>
3837
{t.profile && t.profile.name && Array.isArray(t.profile.lines) && (
@@ -141,7 +140,7 @@ export default function WangHaoPageEN() {
141140
{r.map((cell: any, cidx: number) => (
142141
<td key={cidx}>
143142
{cell && typeof cell === 'object' && 'href' in cell ? (
144-
<a href={withBase(cell.href)} target="_blank" rel="noopener noreferrer">{cell.text}</a>
143+
<a href={cell.href} target="_blank" rel="noopener noreferrer">{cell.text}</a>
145144
) : (
146145
cell
147146
)}

app/people/wang_hao/ja/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from '../../../components/LangSwitch';
22
import Link from 'next/link';
33
import SideToc from '../../../components/SideToc';
44
import { getDict } from '../../../lib/i18n';
5-
import { withBase } from '../../../lib/paths';
65
import Image from 'next/image';
76

87
export default function WangHaoPageJA() {
@@ -32,7 +31,7 @@ export default function WangHaoPageJA() {
3231
<h2 className="section-title">{t.about.title}</h2>
3332
<div className="about-grid ">
3433
<div className="about-photo">
35-
<Image src={withBase("/wang_hao.jpeg")} alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
34+
<Image src="/wang_hao.jpeg" alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
3635
</div>
3736
<div>
3837
{t.profile && t.profile.name && Array.isArray(t.profile.lines) && (
@@ -141,7 +140,7 @@ export default function WangHaoPageJA() {
141140
{r.map((cell: any, cidx: number) => (
142141
<td key={cidx}>
143142
{cell && typeof cell === 'object' && 'href' in cell ? (
144-
<a href={withBase(cell.href)} target="_blank" rel="noopener noreferrer">{cell.text}</a>
143+
<a href={cell.href} target="_blank" rel="noopener noreferrer">{cell.text}</a>
145144
) : (
146145
cell
147146
)}

app/people/wang_hao/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import LangSwitch from '../../components/LangSwitch';
22
import Link from 'next/link';
33
import SideToc from '../../components/SideToc';
44
import { getDict } from '../../lib/i18n';
5-
import { withBase } from '../../lib/paths';
65
import Image from 'next/image';
76

87
export default function WangHaoPage() {
@@ -32,7 +31,7 @@ export default function WangHaoPage() {
3231
<h2 className="section-title">{t.about.title}</h2>
3332
<div className="about-grid">
3433
<div className="about-photo">
35-
<Image src={withBase("/wang_hao.jpeg")} alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
34+
<Image src="/wang_hao.jpeg" alt="Hao WANG" width={300} height={300} style={{ width: '100%', height: 'auto' }} />
3635
</div>
3736
<div>
3837
{t.profile && t.profile.name && Array.isArray(t.profile.lines) && (
@@ -142,7 +141,7 @@ export default function WangHaoPage() {
142141
{r.map((cell: any, cidx: number) => (
143142
<td key={cidx}>
144143
{cell && typeof cell === 'object' && 'href' in cell ? (
145-
<a href={withBase(cell.href)} target="_blank" rel="noopener noreferrer">{cell.text}</a>
144+
<a href={cell.href} target="_blank" rel="noopener noreferrer">{cell.text}</a>
146145
) : (
147146
cell
148147
)}

0 commit comments

Comments
 (0)