Skip to content

Commit 84ac8c8

Browse files
committed
feat(web): adopt browser history mode
1 parent 8cd1eb3 commit 84ac8c8

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# building frontend
2-
FROM node:22-slim as frontend
2+
FROM node:22-slim AS frontend
33
WORKDIR /app/frontend
44

55
COPY web/package.json web/yarn.lock ./
@@ -40,8 +40,8 @@ FROM python:3.12-slim
4040
ENV MAX_UPLOAD_SIZE=100M
4141

4242
# set up the system
43-
RUN apt update && \
44-
apt install --yes nginx dumb-init libmagic1 gettext && \
43+
RUN apt-get update && \
44+
apt-get install --yes nginx dumb-init libmagic1 gettext && \
4545
rm -rf /var/lib/apt/lists/*
4646

4747
RUN mkdir -p /var/docat/doc

docat/docat/nginx/default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ server {
2323
}
2424

2525
location / {
26-
try_files $uri $uri/ =404;
26+
try_files $uri $uri/ /index.html =404;
2727
}
2828
}

web/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createHashRouter, RouterProvider } from 'react-router-dom'
1+
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
22
import { ConfigDataProvider } from './data-providers/ConfigDataProvider'
33
import { MessageBannerProvider } from './data-providers/MessageBannerProvider'
44
import { ProjectDataProvider } from './data-providers/ProjectDataProvider'
@@ -14,7 +14,7 @@ import NotFound from './pages/NotFound'
1414
import Upload from './pages/Upload'
1515

1616
function App(): JSX.Element {
17-
const router = createHashRouter([
17+
const router = createBrowserRouter([
1818
{
1919
path: '/',
2020
errorElement: <NotFound />,

web/src/pages/Docs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default function Docs(): JSX.Element {
103103
hash: string,
104104
hideUi: boolean
105105
): string => {
106-
return `#/${project}/${version}/${encodeURIComponent(page)}${hash}${hideUi ? '?hide-ui=true' : ''}`
106+
return `/${project}/${version}/${encodeURIComponent(page)}${hash}${hideUi ? '?hide-ui=true' : ''}`
107107
}
108108

109109
const updateUrl = (newVersion: string, hideUi: boolean): void => {

web/src/pages/Home.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useEffect, useState } from 'react';
22

33
import { Delete, ErrorOutline, FileUpload, KeyboardArrowDown, Lock } from '@mui/icons-material';
4-
import { useLocation } from 'react-router';
54
import { useProjects } from '../data-providers/ProjectDataProvider';
65
import { useSearch } from '../data-providers/SearchProvider';
76
import { type Project } from '../models/ProjectsResponse';
@@ -22,25 +21,12 @@ import styles from './../style/pages/Home.module.css';
2221
export default function Home(): JSX.Element {
2322
const { loadingFailed } = useProjects()
2423
const { stats, loadingFailed: statsLoadingFailed } = useStats()
25-
const { filteredProjects: projects, query, setQuery } = useSearch()
24+
const { filteredProjects: projects, query } = useSearch()
2625
const [showAll, setShowAll] = useState(false);
2726
const [favoriteProjects, setFavoriteProjects] = useState<Project[]>([])
2827

29-
const location = useLocation()
30-
3128
document.title = 'Home | docat'
3229

33-
// insert # into the url if it's missing
34-
useEffect(() => {
35-
const nonHostPart = window.location.href.replace(window.location.origin, '')
36-
37-
if (nonHostPart.startsWith('#') || nonHostPart.startsWith('/#')) {
38-
return
39-
}
40-
41-
window.location.replace(`/#${nonHostPart}`)
42-
}, [location, setQuery, projects])
43-
4430
const updateFavorites = (): void => {
4531
if (projects == null) return
4632

0 commit comments

Comments
 (0)