Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const ANCHOR_TAG = "a";
const FRAMEWORK_LINK = "router-link"; // or "nuxt-link", "g-link"...
const getLinkTag = ({ href, blank, external }) => {
if (blank || external) {
return ANCHOR_TAG;
} else if (/^\/(?!\/).*$/.test(href)) { // regex101.com/r/LU1iFL/1
return FRAMEWORK_LINK;
} else {
return ANCHOR_TAG;
}
};
export { getLinkTag as default, ANCHOR_TAG, FRAMEWORK_LINK };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment