From 49d48cd13bc47b726cb38042652d11ba7a60b8f1 Mon Sep 17 00:00:00 2001 From: kite Date: Mon, 20 Jul 2026 15:30:03 +0800 Subject: [PATCH] feat(pages): serve landing site at custom-domain root with clean URLs Migrate the landing site from the GitHub Pages subpath /open-code-review/ to the root of the open-codereview.ai custom domain and drop the /#/ from URLs: - webpack publicPath -> '/' so assets load at the domain root - switch HashRouter -> BrowserRouter for clean paths (e.g. /docs) - fix HeroSection '#/docs' anchor to a router Link - add public/CNAME (open-codereview.ai) for the GitHub Pages custom domain - emit 404.html (copy of index.html) as SPA deep-link fallback --- pages/public/CNAME | 1 + pages/src/components/HeroSection.tsx | 7 ++++--- pages/src/index.tsx | 6 +++--- pages/webpack.config.js | 9 ++++++++- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 pages/public/CNAME diff --git a/pages/public/CNAME b/pages/public/CNAME new file mode 100644 index 00000000..e72d26a1 --- /dev/null +++ b/pages/public/CNAME @@ -0,0 +1 @@ +open-codereview.ai diff --git a/pages/src/components/HeroSection.tsx b/pages/src/components/HeroSection.tsx index 32f895b2..0af00952 100644 --- a/pages/src/components/HeroSection.tsx +++ b/pages/src/components/HeroSection.tsx @@ -1,5 +1,6 @@ import React, { useCallback, useState, useEffect } from 'react'; import ReactDOM from 'react-dom'; +import { Link } from 'react-router-dom'; import { useTranslation } from '../i18n'; import { useResponsive } from '../hooks/useResponsive'; import ColorBends from './ColorBends'; @@ -313,8 +314,8 @@ const HeroSection: React.FC = () => { > {t('hero.quickStart')} - { }} > {t('hero.learnMore')} - + {/* Terminal */} diff --git a/pages/src/index.tsx b/pages/src/index.tsx index 70557bcc..a9e25baf 100644 --- a/pages/src/index.tsx +++ b/pages/src/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; -import { HashRouter } from 'react-router-dom'; +import { BrowserRouter } from 'react-router-dom'; import App from './App'; import { LanguageProvider } from './i18n'; import './styles/index.css'; @@ -16,9 +16,9 @@ const root = ReactDOM.createRoot(rootElement); root.render( - + - + ); diff --git a/pages/webpack.config.js b/pages/webpack.config.js index 55e8b9f9..1aea6b54 100644 --- a/pages/webpack.config.js +++ b/pages/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', - publicPath: process.env.NODE_ENV === 'production' ? '/open-code-review/' : '/' + publicPath: '/' }, module: { rules: [ @@ -65,6 +65,13 @@ module.exports = { template: './index.html', inject: 'body' }), + // SPA fallback: serve the app shell for deep links / refreshes on client-side + // routes (BrowserRouter). GitHub Pages returns this for unknown paths. + new HtmlWebpackPlugin({ + template: './index.html', + inject: 'body', + filename: '404.html' + }), new CopyPlugin({ patterns: [ { from: 'public', to: '.', noErrorOnMissing: true }