Skip to content

Commit 565b499

Browse files
committed
refactor: Abstract duplicate skip link and favicon code
1 parent 59f8067 commit 565b499

4 files changed

Lines changed: 22 additions & 48 deletions

File tree

app/app.vue

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<div class="page">
3-
<a href="#maincontent" class="sr-only sr-only--focusable skip-link">Skip to main content</a>
43
<Navigation />
54
<main id="maincontent">
65
<NuxtLayout />
@@ -12,16 +11,6 @@
1211
<script lang="ts" setup>
1312
import Navigation from './components/Navigation.vue';
1413
import SiteFooter from './components/SiteFooter.vue';
15-
16-
useHead({
17-
htmlAttrs: {
18-
lang: 'en-GB'
19-
},
20-
link: [
21-
{ rel: 'shortcut icon', type: 'image/x-icon', href: '/favicon.ico' },
22-
{ rel: 'icon', type: 'image/png', href: '/icon.png' }
23-
],
24-
})
2514
</script>
2615

2716
<style lang="scss" scoped>
@@ -39,18 +28,4 @@ useHead({
3928
}
4029
}
4130
}
42-
43-
.skip-link {
44-
display: block;
45-
position: fixed !important;
46-
top: 1rem;
47-
left: 1rem;
48-
z-index: 9999;
49-
padding: 0.5rem 1rem !important;
50-
background-color: var(--color-fg1);
51-
color: var(--color-accent);
52-
border-radius: 0.25rem;
53-
font-weight: 700;
54-
text-decoration: none;
55-
}
5631
</style>

app/components/Navigation.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<template>
2+
<a href="#maincontent" class="sr-only sr-only--focusable skip-link">Skip to main content</a>
23
<nav
34
class="nav"
45
:class="{ 'nav--sticky': !navIsAtTop || isMobileNavOpen }"
@@ -321,6 +322,19 @@ function toggleMobileNav (open: boolean): void {
321322
</script>
322323

323324
<style lang="scss" scoped>
325+
.skip-link.sr-only {
326+
position: fixed !important;
327+
top: 1rem;
328+
left: 1rem;
329+
z-index: 9999;
330+
padding: 0.5rem 1rem !important;
331+
background-color: var(--color-fg1);
332+
color: var(--color-accent);
333+
border-radius: 0.25rem;
334+
font-weight: 700;
335+
text-decoration: none;
336+
}
337+
324338
$navBreak: $responsive-large-tablet;
325339
$navHeight: 4rem;
326340

app/error.vue

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<div class="page">
3-
<a href="#maincontent" class="sr-only sr-only--focusable skip-link">Skip to main content</a>
43
<Navigation />
54
<main id="maincontent">
65
<div class="container container--thinner error-page">
@@ -27,14 +26,7 @@ defineProps<{
2726
}>();
2827
2928
useHead({
30-
title: '404 — Page Not Found | Jack Domleo',
31-
htmlAttrs: {
32-
lang: 'en-GB'
33-
},
34-
link: [
35-
{ rel: 'shortcut icon', type: 'image/x-icon', href: '/favicon.ico' },
36-
{ rel: 'icon', type: 'image/png', href: '/icon.png' }
37-
],
29+
title: 'Page Not Found',
3830
});
3931
4032
function handleGoHome() {
@@ -58,20 +50,6 @@ function handleGoHome() {
5850
}
5951
}
6052
61-
.skip-link {
62-
display: block;
63-
position: fixed !important;
64-
top: 1rem;
65-
left: 1rem;
66-
z-index: 9999;
67-
padding: 0.5rem 1rem !important;
68-
background-color: var(--color-fg1);
69-
color: var(--color-accent);
70-
border-radius: 0.25rem;
71-
font-weight: 700;
72-
text-decoration: none;
73-
}
74-
7553
.error-page {
7654
display: flex;
7755
flex-direction: column;

nuxt.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ export default defineNuxtConfig({
1010
ssr: true,
1111
app: {
1212
head: {
13+
htmlAttrs: {
14+
lang: 'en-GB'
15+
},
16+
link: [
17+
{ rel: 'shortcut icon', type: 'image/x-icon', href: '/favicon.ico' },
18+
{ rel: 'icon', type: 'image/png', href: '/icon.png' }
19+
],
1320
meta: [
1421
{
1522
// Content-Security-Policy restricts which resources the browser is allowed to load. GitHub Pages does not support custom response headers, so this must be set as a <meta http-equiv> tag instead. Note: frame-ancestors is ignored by browsers when set via a meta tag (it only works as a response header), but all other directives are honoured. Key directives:

0 commit comments

Comments
 (0)