web/src/layouts/Layout.astro

335 lines · 7490 bytes

  1---
  2import { ClientRouter } 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?: Record<string, unknown>; // 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			{
 51				'@type': 'SearchAction',
 52				target: {
 53					'@type': 'EntryPoint',
 54					urlTemplate:
 55						'https://awesome-privacy.xyz/search?q={search_term_string}',
 56				},
 57				'query-input': 'required name=search_term_string',
 58			},
 59		],
 60	};
 61};
 62---
 63
 64<!doctype html>
 65<html lang="en" data-theme="dark">
 66	<head>
 67		<ClientRouter />
 68
 69		<!-- Core info -->
 70		<title>{title}</title>
 71		<meta name="description" content={description} />
 72		<meta name="keywords" content={keywords} />
 73		<meta name="author" content={author} />
 74
 75		<!-- Page info, viewport, Astro credit -->
 76		<meta charset="UTF-8" />
 77		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
 78		<meta
 79			name="generator"
 80			content={`Built by an actual human, in Astro. ${Astro.generator}`}
 81		/>
 82		<meta name="robots" content="index, follow" />
 83		<link
 84			rel="canonical"
 85			href={`https://awesome-privacy.xyz${Astro.url.pathname}`}
 86		/>
 87		<link
 88			rel="alternate"
 89			type="application/rss+xml"
 90			title="Awesome Privacy — Changelog"
 91			href="/rss.xml"
 92		/>
 93
 94		<!-- Preload critical fonts -->
 95		<link
 96			rel="preload"
 97			as="font"
 98			href="/fonts/Rubik/Rubik-Regular.woff2"
 99			type="font/woff2"
100			crossorigin
101		/>
102		<link
103			rel="preload"
104			as="font"
105			href="/fonts/Lekton/Lekton-Bold.woff2"
106			type="font/woff2"
107			crossorigin
108		/>
109
110		<!-- Icons and colors -->
111		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
112		<link rel="icon" type="image/png" sizes="64x64" href="/favicon.png" />
113		<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
114
115		<!-- Social media meta tags (Open Graphh + Twitter) -->
116		<meta property="og:site_name" content="Awesome Privacy" />
117		<meta property="og:type" content="website" />
118		<meta
119			property="og:url"
120			content={`https://awesome-privacy.xyz${Astro.url.pathname}`}
121		/>
122		<meta property="og:title" content={title} />
123		<meta property="og:description" content={description} />
124		<meta
125			property="og:image"
126			content="https://awesome-privacy.xyz/banner.png"
127		/>
128		<meta name="twitter:card" content="summary_large_image" />
129		<meta name="twitter:url" content="https://awesome-privacy.xyz" />
130		<meta name="twitter:title" content={title} />
131		<meta name="twitter:description" content={description} />
132		<meta
133			name="twitter:image"
134			content="https://awesome-privacy.xyz/banner.png"
135		/>
136		<link
137			rel="twitter:image"
138			sizes="180x180"
139			href="https://awesome-privacy.xyz/apple-touch-icon.png"
140		/>
141		<meta name="twitter:site" content="@Lissy_Sykes" />
142		<meta name="twitter:creator" content="@Lissy_Sykes" />
143
144		<!-- Non-tracking hit counter -->
145		<script
146			defer
147			is:inline
148			type="text/partytown"
149			data-domain="awesome-privacy.xyz"
150			src="https://no-track.as93.net/js/script.js"></script>
151
152		<!-- Schema.org markup for Google -->
153		{
154			breadcrumbs && (
155				<script
156					is:inline
157					type="application/ld+json"
158					set:html={JSON.stringify(makeBreadcrumbs())}
159				/>
160			)
161		}
162		{
163			customSchemaJson && (
164				<script
165					is:inline
166					type="application/ld+json"
167					set:html={JSON.stringify(customSchemaJson)}
168				/>
169			)
170		}
171		<script
172			is:inline
173			type="application/ld+json"
174			set:html={JSON.stringify(makeSearchLd())}
175		/>
176	</head>
177	<body>
178		{!hideNav && <NavBar />}
179		<slot />
180		<Footer />
181	</body>
182</html>
183
184<style is:global>
185	@import '../styles/values.css';
186	@import '../styles/typography.css';
187</style>
188
189<style is:global lang="scss">
190	html {
191		::selection {
192			background: var(--accent);
193			color: var(--accent-fg);
194		}
195		scroll-behavior: smooth;
196	}
197	body {
198		margin: 0;
199		min-height: 100vh;
200		color: var(--foreground);
201		background: var(--background);
202	}
203
204	:focus-visible {
205		outline: 2px solid var(--accent);
206		outline-offset: 2px;
207	}
208
209	.pagination-navigation {
210		display: flex;
211		justify-content: space-between;
212		align-items: center;
213		padding: var(--space-md) 0;
214		.button {
215			min-width: 120px;
216			width: fit-content;
217			padding: var(--space-xs) var(--space-md);
218			text-align: right;
219			&:first-child {
220				text-align: left;
221			}
222			p {
223				margin: 0;
224				font-weight: normal;
225				font-size: var(--text-base);
226			}
227			span {
228				font-size: var(--text-sm);
229			}
230		}
231		.nothing {
232			width: 120px;
233		}
234		.go-to-category {
235			color: var(--foreground);
236			font-size: var(--text-sm);
237			opacity: var(--opacity-dim);
238			@media (max-width: 768px) {
239				display: none;
240			}
241		}
242	}
243
244	.breadcrumbs {
245		opacity: var(--opacity-dim);
246		font-size: var(--text-sm);
247		position: absolute;
248		right: var(--space-md);
249		top: var(--space-md);
250		a {
251			color: var(--foreground);
252			transition: var(--transition-fast);
253			&:hover {
254				color: var(--accent);
255			}
256		}
257		@media (max-width: 768px) {
258			display: none;
259		}
260	}
261
262	.small-button {
263		display: inline-block;
264		font-family: var(--font-subtitle);
265		font-size: var(--text-sm);
266		font-weight: bold;
267		text-decoration: none;
268		color: var(--accent-fg);
269		background: var(--accent);
270		border: var(--border-light);
271		box-shadow: var(--shadow-sm);
272		padding: var(--space-xs) var(--space-md);
273		transition: var(--transition-normal);
274		&:hover {
275			box-shadow: var(--shadow-sm-hover);
276		}
277	}
278
279	.accent-heading {
280		font-size: var(--text-3xl);
281		margin: calc(var(--space-lg) * -1) 0 var(--space-md)
282			calc(var(--space-lg) * -1);
283		box-shadow: var(--shadow-lg);
284		background: var(--accent);
285		color: var(--accent-fg);
286		width: fit-content;
287		padding: var(--space-xs) var(--space-sm);
288		@media (max-width: 768px) {
289			margin: calc(var(--space-lg) * -1) auto var(--space-lg) auto;
290		}
291	}
292
293	.further-info,
294	.notable-mentions,
295	.word-of-warning,
296	.submit-alternative {
297		h3 {
298			font-size: var(--text-lg);
299			margin: var(--space-md) 0;
300		}
301		p {
302			font-size: var(--text-sm);
303			opacity: var(--opacity-soft);
304			strong {
305				font-weight: 500;
306			}
307			a {
308				color: var(--foreground);
309				transition: var(--transition-fast);
310				&:hover {
311					color: var(--accent);
312				}
313			}
314		}
315		strong {
316			font-weight: 500;
317		}
318		h4 {
319			font-size: var(--text-md);
320			margin: var(--space-sm) 0 0 0;
321		}
322		ul {
323			list-style: circle;
324			padding-left: var(--space-md);
325			font-size: var(--text-sm);
326			opacity: var(--opacity-soft);
327			li {
328				margin-bottom: var(--space-xs);
329				p {
330					display: inline;
331				}
332			}
333		}
334	}
335</style>