Preloaded background if contains image

This commit is contained in:
Patrick Alvin Alcala 2025-09-04 13:09:52 +08:00
parent 88febbb241
commit 6fcfd2a36d

View file

@ -1,5 +1,7 @@
import './HTML.sass' import './HTML.sass'
import { type JSXElement, Show } from 'solid-js' import { type JSXElement, Show } from 'solid-js'
import background1 from '../../images/background.avif'
import background2 from '../../images/background.webp'
interface Props { interface Props {
title: string title: string
@ -7,6 +9,7 @@ interface Props {
description: string description: string
children: JSXElement children: JSXElement
font?: 'roboto' | 'inter' | 'montserrat' | 'open-sans' | 'public-sans' font?: 'roboto' | 'inter' | 'montserrat' | 'open-sans' | 'public-sans'
preloadBackground?: boolean
} }
export default (props: Props) => { export default (props: Props) => {
@ -23,7 +26,11 @@ export default (props: Props) => {
<meta property="og:description" content={props.description} /> <meta property="og:description" content={props.description} />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<link rel="icon" type="image/svg+xml" href="/favicon.png" /> <link rel="icon" type="image/svg+xml" href="/favicon.png" />
<link rel="preload" href={`https://cdn.jsdelivr.net/fontsource/fonts/${props.font}:vf@latest/latin-wght-normal.woff2`} crossorigin="anonymous" as="font" type="font/woff2" /> <link rel="preconnect" href="https://cdn.jsdelivr.net" />
<Show when={props.preloadBackground}>
<link rel="preload" href={background1.src} as="image" type="image/svg+xml" />
<link rel="preload" href={background2.src} as="image" type="image/svg+xml" />
</Show>
<title>{props.title}</title> <title>{props.title}</title>
</head> </head>