web/src/layouts/Layout.astro
171 lines · 4319 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?: 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 <ViewTransitions />
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 name="generator" content={Astro.generator} />
79 <meta name="robots" content="index, follow" />
80
81 <!-- Icons and colors -->
82 <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
83 <link rel="icon" type="image/png" sizes="64x64" href="/favicon.png" />
84 <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
85
86 <!-- Social media meta tags (Open Graphh + Twitter) -->
87 <meta property="og:site_name" content="Awesome Privacy" />
88 <meta property="og:type" content="website" />
89 <meta property="og:url" content="https://awesome-privacy.xyz" />
90 <meta property="og:title" content={title} />
91 <meta property="og:description" content={description} />
92 <meta
93 property="og:image"
94 content="https://awesome-privacy.xyz/banner.png"
95 />
96 <meta name="twitter:card" content="summary" />
97 <meta name="twitter:url" content="https://awesome-privacy.xyz" />
98 <meta name="twitter:title" content={title} />
99 <meta name="twitter:description" content={description} />
100 <meta
101 name="twitter:image"
102 content="https://awesome-privacy.xyz/banner.png"
103 />
104 <link
105 rel="twitter:image"
106 sizes="180x180"
107 href="https://awesome-privacy.xyz/apple-touch-icon.png"
108 />
109 <meta name="twitter:site" content="@Lissy_Sykes" />
110 <meta name="twitter:creator" content="@Lissy_Sykes" />
111
112 <!-- Non-tracking hit counter -->
113 <script
114 defer
115 is:inline
116 type="text/partytown"
117 data-domain="awesome-privacy.xyz"
118 src="https://no-track.as93.net/js/script.js"></script>
119
120 <!-- Schema.org markup for Google -->
121 {
122 breadcrumbs && (
123 <script
124 is:inline
125 type="application/ld+json"
126 set:html={JSON.stringify(makeBreadcrumbs())}
127 />
128 )
129 }
130 {
131 customSchemaJson && (
132 <script
133 is:inline
134 type="application/ld+json"
135 set:html={JSON.stringify(customSchemaJson)}
136 />
137 )
138 }
139 <script
140 is:inline
141 type="application/ld+json"
142 set:html={JSON.stringify(makeSearchLd)}
143 />
144 </head>
145 <body>
146 {!hideNav && <NavBar />}
147 <slot />
148 <Footer />
149 </body>
150</html>
151
152<style is:global>
153 @import '../styles/values.css';
154 @import '../styles/typography.css';
155</style>
156
157<style is:global>
158 html {
159 ::selection {
160 background: var(--accent);
161 color: var(--accent-fg);
162 }
163 scroll-behavior: smooth;
164 }
165 body {
166 margin: 0;
167 min-height: 100vh;
168 color: var(--foreground);
169 background: var(--background);
170 }
171</style>