Skip to content

Commit

Permalink
chore: 修改basePath
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryFan626 committed Dec 5, 2024
1 parent ee54726 commit 55c38bb
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 85 deletions.
2 changes: 1 addition & 1 deletion components/code-block/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({ type }) => {
<div className={styles.wrapper}>
<div className={styles.logo}>
<img
src={`/images/${type}.png`}
src={`/fastexcel/images/${type}.png`}
alt="FastExcel"
width={136}
height={40}
Expand Down
2 changes: 1 addition & 1 deletion components/contributors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Contributors: React.FC = () => {
{contributors.map((contributor, index) => (
<div key={index} className={styles.contributorItem}>
<img
src={contributor.avatar}
src={`/fastexcel${contributor.avatar}`}
alt={contributor.name}
className={styles.avatar}
/>
Expand Down
2 changes: 1 addition & 1 deletion components/features/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Features: React.FC = () => {
{features.map((feature, index) => (
<div key={index} className={styles.featureCard}>
<Image
src={feature.icon}
src={`/fastexcel${feature.icon}`}
alt={feature.title}
width={40}
height={40}
Expand Down
5 changes: 4 additions & 1 deletion components/footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import Link from "next/link";
import styles from "./index.module.css";
import { LanguageSelector } from "../language-switch";
import { useTranslation } from '../../hooks/useTranslation';
import { useRouter } from 'next/router';

const Footer: React.FC = () => {
const { t } = useTranslation();
const { basePath } = useRouter();

return (
<footer className={styles.footer}>
<div className={styles.footerContent}>
<div className={styles.logoSection}>
<Link href="/">
<Image
src="/images/logo.svg"
src={`${basePath}/images/logo.svg`}
alt="FastExcel"
width={136}
height={40}
Expand Down
4 changes: 4 additions & 0 deletions components/index-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import { Contributors } from "../contributors";
import { Testimonials } from "../testimonials";
import Footer from "../footer";
import { useTranslation } from "../../hooks/useTranslation";
import { useRouter } from 'next/router';
import Image from 'next/image';

const IndexPage: React.FC = () => {
const { t } = useTranslation();
const { basePath } = useRouter();

return (
<>
<div className={styles.container}>
Expand Down
4 changes: 2 additions & 2 deletions components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTranslation } from "../../hooks/useTranslation";

const Navbar = () => {
const router = useRouter();
const { locale = "zh-CN" } = router;
const { locale = "zh-CN", basePath } = router;
const { t } = useTranslation();

const isZhCN = locale === "zh-CN";
Expand All @@ -17,7 +17,7 @@ const Navbar = () => {
<div className={styles.navContent}>
<Link href="/" className={styles.logoContainer}>
<Image
src="/images/logo.svg"
src={`${basePath}/images/logo.svg`}
alt="FastExcel"
width={136}
height={40}
Expand Down
2 changes: 1 addition & 1 deletion components/testimonials/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Testimonials: React.FC = () => {
<div key={`${rowId}-${index}`} className={styles.testimonialCard}>
<div className={styles.testimonialHeader}>
<img
src={testimonial.avatar}
src={`/fastexcel${testimonial.avatar}`}
alt={testimonial.author}
className={styles.avatar}
loading="lazy" // 添加懒加载
Expand Down
16 changes: 14 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const withNextra = nextra({
});

export default withNextra({
basePath: "/fastexcel",
basePath: '/fastexcel',
assetPrefix: '/fastexcel',
i18n: {
locales: ["zh-CN", "zh-TW", "en-US", "ja-JP"],
defaultLocale: "zh-CN",
Expand All @@ -19,7 +20,18 @@ export default withNextra({
destination: "/en-US/:path*",
permanent: true,
},
{
source: "/",
destination: "/fastexcel/zh-CN/",
permanent: true,
basePath: false
},
{
source: "/fastexcel",
destination: "/fastexcel/zh-CN/",
permanent: true,
basePath: false
}
];
},

});
152 changes: 76 additions & 76 deletions public/sitemap-0.xml

Large diffs are not rendered by default.

0 comments on commit 55c38bb

Please sign in to comment.