|
1 | 1 | --- |
2 | 2 | import '../styles/globals.css' |
| 3 | +import { ClientRouter } from 'astro:transitions' |
| 4 | +import { formatTitle } from '@explainer/config' |
| 5 | +import { siteConfig } from '../config' |
3 | 6 |
|
4 | 7 | interface Props { |
5 | 8 | title: string |
6 | 9 | description?: string |
| 10 | + thumbnail?: string |
7 | 11 | } |
8 | 12 |
|
9 | | -const { title, description } = Astro.props |
| 13 | +const { title, description, thumbnail } = Astro.props |
| 14 | +const thumbnailUrl = thumbnail ?? siteConfig.thumbnail |
10 | 15 | --- |
11 | 16 |
|
12 | 17 | <!doctype html> |
13 | 18 | <html lang="en"> |
14 | 19 | <head> |
15 | 20 | <meta charset="UTF-8" /> |
16 | 21 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
17 | | - <meta name="description" content={description} /> |
18 | | - <title>{title}</title> |
| 22 | + <link rel="icon" type="image/svg+xml" href={siteConfig.favicon} /> |
| 23 | + <meta name="description" content={description ?? siteConfig.description} /> |
| 24 | + <meta property="og:title" content={title} /> |
| 25 | + <meta property="og:description" content={description ?? siteConfig.description} /> |
| 26 | + {thumbnailUrl && <meta property="og:image" content={thumbnailUrl} />} |
| 27 | + <meta property="og:type" content={siteConfig.ogType} /> |
| 28 | + <meta name="twitter:card" content={siteConfig.twitterCard} /> |
| 29 | + <meta name="twitter:title" content={title} /> |
| 30 | + <meta name="twitter:description" content={description ?? siteConfig.description} /> |
| 31 | + {thumbnailUrl && <meta name="twitter:image" content={thumbnailUrl} />} |
| 32 | + <title>{formatTitle(siteConfig, title)}</title> |
| 33 | + <ClientRouter /> |
| 34 | + <script is:inline> |
| 35 | + (function () { |
| 36 | + var match = document.cookie.match(/(?:^|; )theme=([^;]*)/) |
| 37 | + var theme = match ? match[1] : 'system' |
| 38 | + var isDark = theme === 'dark' || (theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches) |
| 39 | + document.documentElement.classList.toggle('dark', isDark) |
| 40 | + })() |
| 41 | + </script> |
| 42 | + <script is:inline> |
| 43 | + document.addEventListener('astro:after-swap', function () { |
| 44 | + var match = document.cookie.match(/(?:^|; )theme=([^;]*)/) |
| 45 | + var theme = match ? match[1] : 'system' |
| 46 | + var isDark = theme === 'dark' || (theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches) |
| 47 | + document.documentElement.classList.toggle('dark', isDark) |
| 48 | + }) |
| 49 | + </script> |
19 | 50 | </head> |
20 | | - <body class="min-h-screen antialiased"> |
| 51 | + <body class="min-h-screen antialiased flex flex-col"> |
21 | 52 | <slot /> |
22 | 53 | </body> |
23 | 54 | </html> |
0 commit comments