@tanstack/solid-router
Version:
Modern and scalable routing for Solid applications
1 lines • 2.18 kB
Source Map (JSON)
{"version":3,"file":"HeadContent.cjs","names":["For","Portal","isServer","Asset","useRouter","useTags","AssetCrossOriginConfig","HeadContentProps","assetCrossOrigin","HeadContent","props","tags","router","content","_$createComponent","each","children","tag","t","attrs","mount","document","head"],"sources":["../../src/HeadContent.tsx"],"sourcesContent":["import { For } from 'solid-js'\nimport { Portal, isServer } from '@solidjs/web'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\nimport type { AssetCrossOriginConfig } from '@tanstack/router-core'\n\nexport interface HeadContentProps {\n assetCrossOrigin?: AssetCrossOriginConfig\n}\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`\n * to ensure it's part of the reactive tree and updates correctly during client-side navigation.\n * The component uses portals internally to render content into the `<head>` element.\n */\nexport function HeadContent(props: HeadContentProps) {\n const tags = useTags(props.assetCrossOrigin)\n const router = useRouter()\n\n const content = () => (\n <For each={tags()}>\n {(tag) => {\n const t = tag() as any\n return <Asset tag={t.tag} attrs={t.attrs} children={t.children} />\n }}\n </For>\n )\n\n return (isServer ?? router.isServer) ? (\n content()\n ) : (\n <Portal mount={document.head}>{content()}</Portal>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAgBS,YAAYC,OAAyB;CACnD,MAAMC,OAAON,yBAAAA,QAAQK,MAAMF,iBAAiB;CAC5C,MAAMI,SAASR,kBAAAA,WAAW;CAE1B,MAAMS,iBAAAA,GAAAA,aAAAA,iBACHb,SAAAA,KAAG;EAAA,IAACe,OAAI;AAAA,UAAEJ,MAAM;;EAAAK,WACbC,QAAQ;GACR,MAAMC,IAAID,KAAK;AACf,WAAA,GAAA,aAAA,iBAAQd,cAAAA,OAAK;IAAA,IAACc,MAAG;AAAA,YAAEC,EAAED;;IAAG,IAAEE,QAAK;AAAA,YAAED,EAAEC;;IAAK,IAAEH,WAAQ;AAAA,YAAEE,EAAEF;;IAAQ,CAAA;;EAC/D,CAEJ;AAED,QAAQd,aAAAA,YAAYU,OAAOV,WACzBW,SAAS,IAAA,GAAA,aAAA,iBAERZ,aAAAA,QAAM;EAAA,IAACmB,QAAK;AAAA,UAAEC,SAASC;;EAAI,IAAAN,WAAA;AAAA,UAAGH,SAAS;;EAAA,CACzC"}