From deba0a244eedeb13b012ee80f1fbad45cc54ccb0 Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Mon, 2 Feb 2026 18:28:05 +0100 Subject: [PATCH] Ajout d'un lien canonique vers chaque page dans le head #70 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dynamique, donc pas sûr que les moteurs de recherche le voit. --- src/pages/tableau.py | 6 ++++++ src/utils.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/pages/tableau.py b/src/pages/tableau.py index 724f0b8..ab95c80 100644 --- a/src/pages/tableau.py +++ b/src/pages/tableau.py @@ -22,6 +22,7 @@ from dash import ( from figures import make_column_picker from src.figures import DataTable from src.utils import ( + add_canonical_link, columns, df, filter_table_data, @@ -525,3 +526,8 @@ def sync_sort_to_local_storage(sort_by): ) def reset_view(n_clicks): return "", [] + + +@callback(Input("tableau_url", "pathname")) +def cb_add_canonical_link(pathname): + add_canonical_link(pathname) diff --git a/src/utils.py b/src/utils.py index 57385fd..26411ce 100644 --- a/src/utils.py +++ b/src/utils.py @@ -5,6 +5,7 @@ import uuid from collections import OrderedDict from time import localtime, sleep +import dash import polars as pl import polars.selectors as cs from httpx import get, post @@ -721,6 +722,14 @@ def make_org_jsonld(org_id, org_type, org_name=None, type_org_id="SIRET") -> dic return jsonld +def add_canonical_link(pathname): + @dash.hooks.index() + def update_index(html_string): + url = f"https://{domain_name}{pathname}" + canonical_tag = f'' + return html_string.replace("", f"{canonical_tag}\n ") + + df: pl.DataFrame = get_decp_data() schema = df.collect_schema()