mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2024-12-25 22:39:41 +01:00
20 lines
712 B
TypeScript
20 lines
712 B
TypeScript
import "./src/assets/scss/main.scss";
|
|
import "./src/assets/scss/prism/github.scss";
|
|
import "./src/assets/scss/prism/prism-tomorrow.scss";
|
|
|
|
export const onRouteUpdate = ({ location }: { location: { pathname: string } }) => {
|
|
const elements = document.querySelectorAll("[data-url]");
|
|
const currentUrl = `https://www.rickvanlieshout.com${location.pathname ?? ""}`;
|
|
|
|
const setAttributeIfAvailable = (element: Element, elementIdentifier: string) => {
|
|
if (element.hasAttribute(elementIdentifier)) {
|
|
element.setAttribute(elementIdentifier, currentUrl);
|
|
}
|
|
};
|
|
|
|
elements.forEach((element) => {
|
|
setAttributeIfAvailable(element, "href");
|
|
setAttributeIfAvailable(element, "content");
|
|
});
|
|
};
|