web/src/layouts/Layout.astro

146 lines · 4135 bytes

  1---
  2import { ViewTransitions } from 'astro:transitions'
  3import NavBar from '@components/scafold/NavBar.astro';
  4import Footer from '@components/scafold/Footer.astro';
  5import config from '../site-config';
  6
  7interface Props {
  8	title?: string; // Page title
  9	description?: string; // Overide description tag
 10  keywords?: string; // Overide keywords tag
 11	hideNav?: boolean; // Don't show the navbar (just homepage)
 12	author?: string; // Author of the content
 13	customSchemaJson?: any; // Custom schema item
 14	breadcrumbs?: Array<{
 15		name: string;
 16		item: string;
 17	}>
 18}
 19
 20const {
 21	title = config.title,
 22	description = config.description,
 23	keywords = config.keywords,
 24	author = config.author,
 25	hideNav = false,
 26	breadcrumbs,
 27	customSchemaJson,
 28} = Astro.props;
 29
 30const makeBreadcrumbs = () => {
 31	if (!breadcrumbs) return null;
 32	return {
 33			"@context": "https://schema.org",
 34			"@type": "BreadcrumbList",
 35			"itemListElement": breadcrumbs.map((breadcrumb, index) => ({
 36				"@type": "ListItem",
 37				"position": index + 1,
 38				"name": breadcrumb.name,
 39				"item": `https://awesome-privacy.xyz/${breadcrumb.item}`
 40			}))
 41	}
 42}
 43
 44const makeSearchLd = () => {
 45	return {
 46		"@context": "https://schema.org",
 47		"@type": "WebSite",
 48		"url": "https://awesome-privacy.xyz/",
 49		"potentialAction": [{
 50			"@type": "SearchAction",
 51			"target": {
 52				"@type": "EntryPoint",
 53				"urlTemplate": "https://awesome-privacy.xyz/search?q={search_term_string}"
 54			},
 55			"query-input": "required name=search_term_string"
 56		}]
 57	}
 58};
 59
 60---
 61
 62<!doctype html>
 63<html lang="en" data-theme="dark">
 64	<head>
 65
 66		<ViewTransitions />
 67		
 68		<!-- Core info -->
 69		<title>{title}</title>
 70		<meta name="description" content={description}>
 71		<meta name="keywords" content={keywords}>
 72		<meta name="author" content={author}>
 73
 74		<!-- Page info, viewport, Astro credit -->
 75		<meta charset="UTF-8" />
 76		<meta name="viewport" content="width=device-width, initial-scale=1.0">
 77		<meta name="generator" content={Astro.generator} />
 78		<meta name="robots" content="index, follow">
 79
 80		<!-- Icons and colors -->
 81		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
 82		<link rel="icon" type="image/png" sizes="64x64" href="/favicon.png">
 83		<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
 84
 85		<!-- Social media meta tags (Open Graphh + Twitter) -->
 86		<meta property="og:site_name" content="Awesome Privacy">
 87		<meta property="og:type" content="website">
 88		<meta property="og:url" content="https://awesome-privacy.xyz">
 89		<meta property="og:title" content={title}>
 90		<meta property="og:description" content={description}>
 91		<meta property="og:image" content="https://awesome-privacy.xyz/banner.png">
 92		<meta name="twitter:card" content="summary">
 93		<meta name="twitter:url" content="https://awesome-privacy.xyz">
 94		<meta name="twitter:title" content={title}>
 95		<meta name="twitter:description" content={description}>
 96		<meta name="twitter:image" content="https://awesome-privacy.xyz/banner.png">
 97		<link rel="twitter:image" sizes="180x180" href="https://awesome-privacy.xyz/apple-touch-icon.png">
 98		<meta name="twitter:site" content="@Lissy_Sykes">
 99		<meta name="twitter:creator" content="@Lissy_Sykes">
100
101		<!-- Non-tracking hit counter -->
102		<script defer is:inline
103			type="text/partytown"
104			data-domain="awesome-privacy.xyz"
105			src="https://no-track.as93.net/js/script.js">
106		</script>
107
108		<!-- Schema.org markup for Google -->
109		{breadcrumbs && (
110			<script type="application/ld+json" set:html={JSON.stringify(makeBreadcrumbs())} />
111		)}
112		{customSchemaJson && (
113			<script type="application/ld+json" set:html={JSON.stringify(customSchemaJson)} />
114		)}
115		<script type="application/ld+json" set:html={JSON.stringify(makeSearchLd)} />
116	</head>
117	<body>
118		{!hideNav && <NavBar /> }
119		<slot />
120		<Footer />
121	</body>
122</html>
123
124<style is:global>
125	@import '../styles/values.css';
126	@import '../styles/typography.css';
127	</style>
128	
129
130<style is:global>
131
132	html {
133		::selection {
134			background: var(--accent);
135			color: var(--accent-fg);
136		}
137		scroll-behavior: smooth;
138	}
139	body {
140		margin: 0;
141		min-height: 100vh;
142		color: var(--foreground);
143		background: var(--background);
144	}
145	
146</style>