mirror of
https://github.com/wah-su/wahs.wah.su.git
synced 2025-09-14 18:33:50 +05:00
add scripts to the head
This commit is contained in:
parent
5aba7e3b60
commit
8cb19f4ec8
3 changed files with 43 additions and 9 deletions
|
@ -7,6 +7,7 @@ export default function head(props: {
|
|||
environment: "prod" | "dev";
|
||||
preload?: string[];
|
||||
dns?: string[];
|
||||
script?: string[];
|
||||
}) {
|
||||
const mimetype = `image/${
|
||||
props.image.split(".")[props.image.split(".").length - 1]
|
||||
|
@ -26,14 +27,43 @@ export default function head(props: {
|
|||
<meta property="og:image:type" content={mimetype} />
|
||||
<meta property="og:image:alt" content="" />
|
||||
<meta property="og:logo" content={`${props.url}/static/logo-1x.png`} />
|
||||
<link href={props.environment == "dev" ? "/static/tailwind.css" : "/static/tailwind.min.css"} rel="stylesheet" />
|
||||
{props.preload ? props.preload.map((item) => <link key={`preload_${item}`} rel="preload" href={item} as="fetch" crossOrigin="anonymous"></link>) : ""}
|
||||
{props.dns ? props.dns.map((item) => <link key={`dns_${item}`} rel="dns-prefetch" href={item} />) : ""}
|
||||
{props.environment == "dev" ? (
|
||||
<script src="./static/dev/hotreload.js"></script>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<link
|
||||
href={
|
||||
props.environment == "dev"
|
||||
? "/static/tailwind.css"
|
||||
: "/static/tailwind.min.css"
|
||||
}
|
||||
rel="stylesheet"
|
||||
/>
|
||||
{props.preload
|
||||
? props.preload.map((item) =>
|
||||
item ? (
|
||||
<link
|
||||
key={`preload_${item}`}
|
||||
rel="preload"
|
||||
href={item}
|
||||
as="fetch"
|
||||
crossOrigin="anonymous"
|
||||
></link>
|
||||
) : (
|
||||
""
|
||||
)
|
||||
)
|
||||
: ""}
|
||||
{props.dns
|
||||
? props.dns.map((item) =>
|
||||
item ? (
|
||||
<link key={`dns_${item}`} rel="dns-prefetch" href={item} />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
)
|
||||
: ""}
|
||||
{props.script
|
||||
? props.script.map((item) =>
|
||||
item ? <script key={`script_${item}`} src={item}></script> : ""
|
||||
)
|
||||
: ""}
|
||||
</head>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue