Skip to content

Commit

Permalink
made hash title script optional
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienR1 committed Jan 30, 2025
1 parent 6701cca commit 3e5f685
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/web/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ const title = "Trampoline Intercité" + (label ? ` | ${label}` : "");
}
</style>

{
Object.keys(labels).length > 1 &&
<script is:inline define:vars={{ labels }}>
addEventListener("hashchange", function () {
const path = window.location.pathname + window.location.hash;
if (labels[path]) {
document.title = document.title.replace(/\| .*/, `| ${labels[path]}`);
}
});
</script>
}

<script>
// NOTE: When the header is loaded or resized, update the body's min-height.
document.addEventListener("DOMContentLoaded", function () {
Expand All @@ -103,12 +115,3 @@ const title = "Trampoline Intercité" + (label ? ` | ${label}` : "");
}
});
</script>

<script is:inline define:vars={{ labels }}>
addEventListener("hashchange", function () {
const path = window.location.pathname + window.location.hash;
if (labels[path]) {
document.title = document.title.replace(/\| .*/, `| ${labels[path]}`);
}
});
</script>

0 comments on commit 3e5f685

Please sign in to comment.