Nuxt V3 Content Markdown Open In New Tab (target blank)

Overwrite content ProseA.vue

Create components/content/ProseA.vue

<script setup>const props = defineProps({  href: {    type: String,    default: ''  },  blank: {    type: Boolean,    default: false  }})function isHttpUrl(string) {  let url;  try {    url = new URL(string);  } catch (_) {    return false;  }  return url.protocol === "http:" || url.protocol === "https:";}const isExternal = isHttpUrl(props.href)let bindProps = {   to: props.href}if (isExternal || props.blank) {  bindProps.target = '_blank'}</script><template>  <NuxtLink v-bind="bindProps">    <slot />  </NuxtLink></template>

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.