[READ-ONLY] a fast, modern browser for the npm registry
at main 65 lines 1.6 kB view raw
1<script setup lang="ts"> 2import type { NuxtError } from '#app' 3 4const props = defineProps<{ 5 error: NuxtError 6}>() 7 8const status = computed(() => props.error.statusCode || 500) 9const statusText = computed(() => { 10 if (props.error.statusMessage) return props.error.statusMessage 11 switch (status.value) { 12 case 401: 13 return 'Unauthorized' 14 case 404: 15 return 'Page not found' 16 case 500: 17 return 'Internal server error' 18 case 503: 19 return 'Service unavailable' 20 default: 21 return 'Something went wrong' 22 } 23}) 24 25function handleError() { 26 clearError({ redirect: '/' }) 27} 28 29useHead({ 30 title: `${status.value} - ${statusText.value}`, 31}) 32</script> 33 34<template> 35 <div class="min-h-screen flex flex-col bg-bg text-fg"> 36 <AppHeader /> 37 38 <main class="flex-1 container flex flex-col items-center justify-center py-20 text-center"> 39 <p class="font-mono text-8xl sm:text-9xl font-medium text-fg-subtle mb-4"> 40 {{ status }} 41 </p> 42 43 <h1 class="font-mono text-2xl sm:text-3xl font-medium mb-4"> 44 {{ statusText }} 45 </h1> 46 47 <p 48 v-if="error.message && error.message !== statusText" 49 class="text-fg-muted text-base max-w-md mb-8" 50 > 51 {{ error.message }} 52 </p> 53 54 <button 55 type="button" 56 class="font-mono text-sm px-6 py-3 bg-fg text-bg rounded-lg transition-all duration-200 hover:bg-fg/90 active:scale-95" 57 @click="handleError" 58 > 59 {{ $t('common.go_back_home') }} 60 </button> 61 </main> 62 63 <AppFooter /> 64 </div> 65</template>