@tanstack/vue-router
Version:
Modern and scalable routing for Vue applications
36 lines (35 loc) • 1.19 kB
JavaScript
import { useHydrated } from "./ClientOnly.js";
import { Asset } from "./Asset.js";
import { useTags } from "./headContentUtils.js";
import { DEV_STYLES_ATTR } from "@tanstack/router-core";
import * as Vue from "vue";
//#region src/HeadContent.dev.tsx
/**
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
* It should be rendered in the `<head>` of your document.
*
* This is the development version that filters out dev styles after hydration.
*/
var HeadContent = Vue.defineComponent({
name: "HeadContent",
props: { assetCrossOrigin: {
type: [String, Object],
default: void 0
} },
setup(props) {
const tags = useTags(props.assetCrossOrigin);
const hydrated = useHydrated();
Vue.onMounted(() => {
document.querySelectorAll(`link[${DEV_STYLES_ATTR}]`).forEach((el) => el.remove());
});
return () => {
return (hydrated.value ? tags().filter((tag) => tag.tag !== "link" || tag.attrs?.[DEV_STYLES_ATTR] !== true) : tags()).map((tag) => Vue.h(Asset, {
...tag,
key: `tsr-meta-${JSON.stringify(tag)}`
}));
};
}
});
//#endregion
export { HeadContent };
//# sourceMappingURL=HeadContent.dev.js.map