diff --git a/client/src/hooks/use-title.ts b/client/src/hooks/use-title.ts new file mode 100644 index 0000000..9577c7f --- /dev/null +++ b/client/src/hooks/use-title.ts @@ -0,0 +1,7 @@ +import { useEffect } from "react" + +export const useTitle = (title: string) => { + useEffect(() => { + window.document.title = `⏱️ | ${title}` + }, [title]) +} \ No newline at end of file diff --git a/client/src/routes/home/index.tsx b/client/src/routes/home/index.tsx index 225956f..a8a9901 100644 --- a/client/src/routes/home/index.tsx +++ b/client/src/routes/home/index.tsx @@ -1,12 +1,15 @@ -import React, { FunctionComponent, MouseEvent, useCallback, useState } from "react"; +import React, { FunctionComponent, MouseEvent, useCallback, useEffect, useState } from "react"; import style from "./style.module.css"; import { useHistory } from 'react-router'; import { base58UUID } from '../../util/uuid'; import { useStoredProjectList } from "../../hooks/use-stored-project-list"; import { formatDate } from "../../util/date"; import { Direction, useSort } from "../../hooks/useSort"; +import { useTitle } from "../../hooks/use-title"; const Home: FunctionComponent = () => { + useTitle('Accueil') + const [projects] = useStoredProjectList() const [sortingKey, setSortingKey] = useState('updatedAt') const [sortingDirection, setSortingDirection] = useState(Direction.DESC) @@ -33,7 +36,6 @@ const Home: FunctionComponent = () => { } setSortingDirection(sortingDirection => -sortingDirection) - }, [sortingKey, sortingDirection]) return ( diff --git a/client/src/routes/notfound/index.tsx b/client/src/routes/notfound/index.tsx index 8f81406..996baad 100644 --- a/client/src/routes/notfound/index.tsx +++ b/client/src/routes/notfound/index.tsx @@ -1,15 +1,18 @@ import React, { FunctionComponent } from "react"; import { Link } from 'react-router-dom'; import style from "./style.module.css"; +import { useTitle } from "../../hooks/use-title"; const NotFound: FunctionComponent = () => { - return ( -
-

Error 404

-

That page doesn't exist.

-

Back to Home

-
- ); + useTitle("Page non trouvée") + + return ( +
+

Erreur 404

+

Cette page n'existe pas

+

Retour à la page d'accueil

+
+ ); }; export default NotFound; \ No newline at end of file diff --git a/client/src/routes/project/index.tsx b/client/src/routes/project/index.tsx index 9b2ee01..77f5c7e 100644 --- a/client/src/routes/project/index.tsx +++ b/client/src/routes/project/index.tsx @@ -11,13 +11,14 @@ import ParamsTab from "./params-tab"; import ExportTab from "./export-tab"; import { useServerSync } from "../../hooks/use-server-sync"; import { RouteChildrenProps, RouteProps, useParams } from "react-router"; +import { useTitle } from "../../hooks/use-title"; export interface ProjectProps { projectId: string } const Project: FunctionComponent = () => { - const { projectId } = useParams(); + const { projectId } = useParams<{ projectId: string }>(); const projectStorageKey = getProjectStorageKey(projectId); const [ storedProject, storeProject ] = useLocalStorage(projectStorageKey, newProject(projectId)); const [ project, dispatch ] = useProjectReducer(storedProject); @@ -34,6 +35,8 @@ const Project: FunctionComponent = () => { useEffect(()=> { storeProject(project); }, [project]); + + useTitle(project.label ? project.label : "Projet sans nom") return (
diff --git a/client/webpack.config.js b/client/webpack.config.js index 0d0950b..98e2bba 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -63,7 +63,7 @@ module.exports = { plugins: [ new ForkTsCheckerWebpackPlugin(), new HtmlWebpackPlugin({ - title: 'Guesstimate', + title: '⏱️ Guesstimate', scriptLoading: 'defer', template: path.join(__dirname, 'src/index.html') @@ -87,7 +87,7 @@ module.exports = { function getCurrentVersion() { let version try { - version = exec("git describe --abbrev=0 2>/dev/null") + version = exec("git describe --always 2>/dev/null") } catch(err) {} return version ? version : "0.0.0"; }