Skip to content

Commit

Permalink
améliorer l'indexation des moteurs de recherche #79
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Dec 16, 2024
1 parent 635bce3 commit a91bba0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
8 changes: 4 additions & 4 deletions client/src/pages/atlas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useQuery } from "@tanstack/react-query";
import {
Button,
Breadcrumb,
Container,
Row,
Col,
Container, Row, Col,
Link,
} from "@dataesr/dsfr-plus";

Expand All @@ -21,8 +19,10 @@ import { Search } from "./components/main/tabs/search/index.tsx";
import YearsModalButton from "./components/main/header/years-modal-button.tsx";
import { AtlasSideMenu } from "./side-menu-layout/index.tsx";
import { GetLevelBadgeFromId } from "./utils/badges.tsx";
import { getLevelFromGeoId } from "./utils/index.tsx";

import "./styles.scss";

import { DEFAULT_CURRENT_YEAR } from "../../constants.tsx";

export default function AtlasHeader() {
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function AtlasHeader() {
{geoId && <Link>{geoLabel}</Link>}
</Breadcrumb>

{!geoId ? <Search /> : <AtlasSideMenu title={geoLabelFull} />}
{!geoId ? <Search /> : <AtlasSideMenu geoLabel={geoLabel} level={getLevelFromGeoId({geoId}) } title={geoLabelFull} />}
</Container>
);
}
17 changes: 13 additions & 4 deletions client/src/pages/atlas/side-menu-layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { ReactNode, useEffect } from "react";
import { Container, Row, Col, Link, SideMenu, Title } from "@dataesr/dsfr-plus";
import { Outlet, useLocation, useSearchParams } from "react-router-dom";
import "./styles.scss";
import { ReactNode } from "react";
import Source from "../components/source";

export function AtlasSideMenu({ title }: { title: ReactNode }) {
import "./styles.scss";
import { DEFAULT_CURRENT_YEAR } from "../../../constants";

export function AtlasSideMenu({ geoLabel, level, title }:
{ geoLabel: string, level: string, title: ReactNode }) {
const { pathname } = useLocation();
const [searchParams] = useSearchParams();
const currentYear = searchParams.get("annee_universitaire") || DEFAULT_CURRENT_YEAR;

useEffect(() => {
document.title = `${geoLabel} (${level}) - Atlas des effectifs étudiant-e-s ${currentYear}`;
}, [geoLabel, level, currentYear]);

if (!pathname) return null;
const filtersParams = searchParams.toString();

const filtersParams = searchParams.toString();
const is = (str: string): boolean => pathname?.startsWith(str);

return (
<Container>
<Row>
Expand Down
21 changes: 21 additions & 0 deletions client/src/pages/atlas/utils/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function getLevelFromGeoId({ geoId }: { geoId: string }) {
let levelLabel = "Commune";
if (geoId.startsWith("R")) {
levelLabel = "Région";
}
if (geoId.startsWith("D")) {
levelLabel = "Département";
}
if (geoId.startsWith("A")) {
levelLabel = "Académie";
}
if (geoId.startsWith("U")) {
levelLabel = "Unité urbaine";
}
if (geoId.startsWith("P")) {
levelLabel = "Pays";
}
return (
levelLabel
);
}

0 comments on commit a91bba0

Please sign in to comment.