Skip to content

Commit 5ad0c2c

Browse files
feat(blog): add BackButton component to blog header
1 parent 87f3aaf commit 5ad0c2c

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

app/components/BackButton.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
const router = useRouter()
3+
const canGoBack = useCanGoBack()
4+
5+
withDefaults(
6+
defineProps<{
7+
class?: string
8+
}>(),
9+
{
10+
class: '',
11+
},
12+
)
13+
</script>
14+
15+
<template>
16+
<button
17+
v-if="canGoBack"
18+
type="button"
19+
:class="[
20+
'inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0',
21+
$props.class,
22+
]"
23+
@click="router.back()"
24+
>
25+
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
26+
<span class="sr-only sm:not-sr-only">{{ $t('nav.back') }}</span>
27+
</button>
28+
</template>

app/pages/blog/index.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ useSeoMeta({
2121
<main class="container w-full flex-1 py-12 sm:py-16 overflow-x-hidden">
2222
<article class="max-w-2xl mx-auto">
2323
<header class="mb-12">
24-
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
25-
{{ $t('blog.heading') }}
26-
</h1>
24+
<div class="flex items-baseline justify-between gap-4 mb-4">
25+
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
26+
{{ $t('blog.heading') }}
27+
</h1>
28+
<BackButton />
29+
</div>
2730
<p class="text-fg-muted text-lg">
2831
{{ $t('tagline') }}
2932
</p>

0 commit comments

Comments
 (0)