diff --git a/frontend/src/lib/nav/Nav.svelte b/frontend/src/lib/nav/Nav.svelte
index 133d7a0..d53a25b 100644
--- a/frontend/src/lib/nav/Nav.svelte
+++ b/frontend/src/lib/nav/Nav.svelte
@@ -1,7 +1,7 @@
diff --git a/frontend/src/lib/router.ts b/frontend/src/lib/router.ts
index 1f7db14..0e42e88 100644
--- a/frontend/src/lib/router.ts
+++ b/frontend/src/lib/router.ts
@@ -8,13 +8,30 @@ export const routes = {
Dataset: "/dump/:dumpUrl/:portal/dataset/:id",
};
+export function generateDumpName(dumpUrl: string) {
+ const clean = decodeURIComponent(dumpUrl).replace(/\/+$/, "");
+ return clean.slice(clean.lastIndexOf("/") + 1);
+}
+
+const title = "Archivo de portales de datos de Argentina";
+const titles: { [key in ComponentType]: (params: Params) => string } = {
+ Home: () => title,
+ NotFound: () => title,
+ Dump: (params) => `${generateDumpName(params.dumpUrl)} - ${title}`,
+ Portal: (params) => `${params.portal} - ${title}`,
+ Dataset: (params) => `${params.id} - ${title}`,
+};
+
export type ComponentType = "NotFound" | keyof typeof routes;
type Route = {
component: ComponentType;
params?: Params;
};
-export const currentRoute = writable();
+export const currentRoute = writable({ component: "Home" });
+currentRoute.subscribe(
+ (route) => (document.title = titles[route.component](route.params!)),
+);
export const router = navaid(undefined, () =>
currentRoute.set({ component: "NotFound" }),