elk/pages/[...permalink].vue

26 lines
505 B
Vue
Raw Permalink Normal View History

2022-11-29 23:51:52 +03:00
<script setup lang="ts">
import { hasProtocol, parseURL } from 'ufo'
2022-11-29 23:51:52 +03:00
definePageMeta({
middleware: async (to) => {
const permalink = Array.isArray(to.params.permalink)
? to.params.permalink.join('/')
: to.params.permalink
2022-11-29 23:51:52 +03:00
if (hasProtocol(permalink)) {
const { host, pathname } = parseURL(permalink)
if (host)
return `/${host}${pathname}`
2022-11-29 23:51:52 +03:00
}
// We've reached a page that doesn't exist
return false
2022-11-29 23:51:52 +03:00
},
})
</script>
<template>
<div />
</template>