Update links and colors

This commit is contained in:
Cassidy Williams
2023-11-08 10:06:19 -06:00
parent 466c198e82
commit fb86147f6a
3 changed files with 23 additions and 10 deletions

View File

@@ -7,7 +7,7 @@
function setRandomLinkColor() {
Array.from(document.getElementsByTagName("a")).forEach((e) => {
e.style.color = getRandomColor();
e.style.textDecorationColor = getRandomColor();
});
}

View File

@@ -2,7 +2,11 @@
export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {}
const { href, class: className, ...props } = Astro.props as Props;
const isActive = href === Astro.url.pathname;
let isActive = href === Astro.url.pathname;
if (Astro.url.pathname.startsWith("/post/")) {
isActive = true;
}
---
<a href={href} class:list={[className, { active: isActive }]} {...props}>
@@ -16,5 +20,7 @@ const isActive = href === Astro.url.pathname;
a.active {
font-weight: bolder;
text-decoration: underline;
text-decoration-thickness: 0.3ex;
text-underline-offset: 0.3ex;
}
</style>