Skip to content

Commit 750304d

Browse files
feat(pages): serve landing site at custom-domain root with clean URLs (#407)
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
1 parent 5208128 commit 750304d

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

pages/public/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open-codereview.ai

pages/src/components/HeroSection.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useCallback, useState, useEffect } from 'react';
22
import ReactDOM from 'react-dom';
3+
import { Link } from 'react-router-dom';
34
import { useTranslation } from '../i18n';
45
import { useResponsive } from '../hooks/useResponsive';
56
import ColorBends from './ColorBends';
@@ -313,8 +314,8 @@ const HeroSection: React.FC = () => {
313314
>
314315
{t('hero.quickStart')}
315316
</a>
316-
<a
317-
href="#/docs"
317+
<Link
318+
to="/docs"
318319
style={{
319320
height: 32,
320321
display: 'flex',
@@ -330,7 +331,7 @@ const HeroSection: React.FC = () => {
330331
}}
331332
>
332333
{t('hero.learnMore')}
333-
</a>
334+
</Link>
334335
</div>
335336

336337
{/* Terminal */}

pages/src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
3-
import { HashRouter } from 'react-router-dom';
3+
import { BrowserRouter } from 'react-router-dom';
44
import App from './App';
55
import { LanguageProvider } from './i18n';
66
import './styles/index.css';
@@ -16,9 +16,9 @@ const root = ReactDOM.createRoot(rootElement);
1616
root.render(
1717
<React.StrictMode>
1818
<LanguageProvider>
19-
<HashRouter>
19+
<BrowserRouter>
2020
<App />
21-
</HashRouter>
21+
</BrowserRouter>
2222
</LanguageProvider>
2323
</React.StrictMode>
2424
);

pages/webpack.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
output: {
99
path: path.resolve(__dirname, 'dist'),
1010
filename: 'bundle.js',
11-
publicPath: process.env.NODE_ENV === 'production' ? '/open-code-review/' : '/'
11+
publicPath: '/'
1212
},
1313
module: {
1414
rules: [
@@ -65,6 +65,13 @@ module.exports = {
6565
template: './index.html',
6666
inject: 'body'
6767
}),
68+
// SPA fallback: serve the app shell for deep links / refreshes on client-side
69+
// routes (BrowserRouter). GitHub Pages returns this for unknown paths.
70+
new HtmlWebpackPlugin({
71+
template: './index.html',
72+
inject: 'body',
73+
filename: '404.html'
74+
}),
6875
new CopyPlugin({
6976
patterns: [
7077
{ from: 'public', to: '.', noErrorOnMissing: true }

0 commit comments

Comments
 (0)