Skip to content

Commit 83d952a

Browse files
committed
Refactor skip link for improved accessibility and add main content ID for better navigation
1 parent fb42a4a commit 83d952a

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/components/Header.astro

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SITE_NAME } from "../consts";
33
import HeaderLink from "./HeaderLink.astro";
44
---
55

6-
<a href="#main-content" class="sr-only focus:not-sr-only">Skip to content</a>
6+
<a href="#main-content" class="skip-link">Skip to content</a>
77
<header>
88
<nav aria-label="Primary">
99
<h2><a href="/">{SITE_NAME}</a></h2>
@@ -68,4 +68,24 @@ import HeaderLink from "./HeaderLink.astro";
6868
display: none;
6969
}
7070
}
71+
.skip-link {
72+
position: absolute;
73+
top: 0;
74+
left: 0;
75+
z-index: 100;
76+
padding: 0.5em 1em;
77+
background: white;
78+
color: var(--black);
79+
text-decoration: none;
80+
font-size: 0.875em;
81+
clip-path: inset(50%);
82+
white-space: nowrap;
83+
overflow: hidden;
84+
}
85+
.skip-link:focus-visible {
86+
clip-path: none;
87+
overflow: visible;
88+
outline: 2px solid var(--accent);
89+
outline-offset: 2px;
90+
}
7191
</style>

src/pages/blog/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const posts = (await getCollection("blog")).sort((a, b) => b.data.pubDate.valueO
8686
</head>
8787
<body>
8888
<Header />
89-
<main>
89+
<main id="main-content">
9090
<section>
9191
<ul>
9292
{

0 commit comments

Comments
 (0)