Skip to content

Commit

Permalink
chore: format layout code
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh990918 committed Jul 4, 2023
1 parent 358da65 commit 2334cbc
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ const { title } = Astro.props;
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180" />
<link rel="mask-icon" href="/logo.svg" color="#FFFFFF" />
<meta name="theme-color" content="#101010" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<meta name="description" content="Get answers from AI, elegantly." />
{import.meta.env.HEAD_SCRIPTS && <Fragment set:html={import.meta.env.HEAD_SCRIPTS} />}
{
import.meta.env.HEAD_SCRIPTS && (
<Fragment set:html={import.meta.env.HEAD_SCRIPTS} />
)
}
{pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
{import.meta.env.PROD && pwaInfo?.registerSW && <Fragment set:html={pwaInfo.registerSW.scriptTag} />}
{
import.meta.env.PROD && pwaInfo?.registerSW && (
<Fragment set:html={pwaInfo.registerSW.scriptTag} />
)
}
</head>
<body class="bg-base fg-base">
<slot />
Expand All @@ -31,8 +42,11 @@ const { title } = Astro.props;

<script>
(function() {
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
const prefersDark
= window.matchMedia
&& window.matchMedia('(prefers-color-scheme: dark)').matches
const setting = localStorage.getItem('theme') || 'auto'
if (setting === 'dark' || (prefersDark && setting !== 'light')) document.documentElement.classList.toggle('dark', true)
if (setting === 'dark' || (prefersDark && setting !== 'light'))
document.documentElement.classList.toggle('dark', true)
})()
</script>

0 comments on commit 2334cbc

Please sign in to comment.