web/src/pages/sitemap.astro
230 lines · 6407 bytes
1---
2
3
4import Layout from '@layouts/Layout.astro';
5import type { AwesomePrivacy } from '../types/Service';
6import { fetchData, slugify } from '@utils/fetch-data';
7
8const categories = (await fetchData() as AwesomePrivacy)?.categories || [];
9
10---
11
12<Layout title="All Links | Awesome Privacy">
13 <main>
14 <h2>Sitemap</h2>
15 <p>
16 Below is a full listing of all pages on this site.<br>
17 <small>As reflected in our <a href="/sitemap-index.xml">sitemap.xml</a></small>
18 </p>
19 <span class="search-controlls">
20 <input id="searchInput" type="search" placeholder="Start typing to filter..." />
21 <p id="press-enter-msg" class="press-enter">Press enter for deep search</p>
22 </span>
23 <ul>
24 <li>
25 <a href="/">Home</a>
26 </li>
27 <li>
28 <a href="/edit">Edit</a>
29 </li>
30 <li>
31 <a href="/api">API</a>
32 </li>
33 <li>
34 <a href="/search">Search</a>
35 </li>
36 <li>
37 <a href="/browse">Categories</a>
38 <ul>
39 {categories.map((category) => (
40 <li>
41 <a href={`/${slugify(category.name)}`}>{category.name}</a>
42 <ul>
43 {category.sections.map((section) => (
44 <li>
45 <a href={`/${slugify(category.name)}/${slugify(section.name)}`}>{section.name}</a>
46 <ul>
47 {(section.services || []).map((service) => (
48 <li title={service.description || ''}>
49 <a href={`/${slugify(category.name)}/${slugify(section.name)}/${slugify(service.name)}`}>
50 {service.name}
51 </a>
52 </li>
53 ))}
54 </ul>
55 </li>
56 ))}
57 </ul>
58 </li>
59 ))}
60 </ul>
61 </li>
62 <li>
63 <a href="/all">View Summary of All</a>
64 </li>
65 <li>
66 <a href="/about">About</a>
67 <ul>
68 <li><a href="/about#objective">Objective</a></li>
69 <li><a href="/about#criteria">Listing Criteria</a></li>
70 <li><a href="/about#contributing">Contributing</a></li>
71 <li>
72 <a href="/about#acknowledgements">Acknowledgements</a>
73 <ul>
74 <li><a href="/about#contributors">Contributors</a></li>
75 <li><a href="/about#sponsors">Sponsors</a></li>
76 </ul>
77 </li>
78 <li><a href="/about#author">Author</a></li>
79 <li><a href="/about#license">License</a></li>
80 </ul>
81 </li>
82 <li>
83 <a href="/map">Sitemap</a>
84 </li>
85 </ul>
86 </main>
87
88</Layout>
89
90<script>
91 document.addEventListener('DOMContentLoaded', () => {
92 // Select elements for events (search field, each result, and message str)
93 const filterInput = document.querySelector<HTMLInputElement>('input');
94 const pages = document.querySelectorAll<HTMLElement>('li');
95 const pressEnterMsg = document.getElementById('press-enter-msg');
96 if (!pressEnterMsg) throw new Error('pressEnterMsg element not found');
97
98 // Instant search/filter functionality
99 filterInput?.addEventListener('input', (e: Event) => {
100 const filter = (e.target as HTMLInputElement).value.toLowerCase();
101 pressEnterMsg.style.visibility = filter.length > 0 ? 'visible' : 'hidden';
102 Array.from(pages).reduce((count, page) => {
103 const match = page.textContent?.toLowerCase().includes(filter) || false;
104 page.style.display = match ? 'block' : 'none';
105 return count + (match ? 1 : 0);
106 }, 0);
107 });
108 // Handle keypress events, so Esc clears search, and Entr runs deep search
109 document.addEventListener('keydown', (event: KeyboardEvent) => {
110 if (!filterInput) return;
111 switch (event.key) {
112 case 'Enter':
113 event.preventDefault();
114 const searchTerm = encodeURIComponent(filterInput.value);
115 window.location.href = `/search/${searchTerm}`;
116 break;
117 case 'Escape':
118 filterInput.value = '';
119 filterInput.blur();
120 pressEnterMsg.style.visibility = 'hidden';
121 pages.forEach(page => page.style.display = 'block');
122 break;
123 }
124 });
125 });
126</script>
127
128<style lang="scss">
129
130main {
131 padding: 1rem;
132 width: 1000px;
133 max-width: calc(100% - 5rem);
134 margin: 4rem auto 5rem auto;
135 padding: 0 2rem;
136 border: 2px solid var(--foreground);
137 box-shadow: 6px 6px 0 var(--foreground);
138 background: var(--accent-fg);
139 position: relative;
140 p {
141 font-size: 1.3rem;
142 margin: 0;
143 small {
144 font-size: 0.8rem;
145 opacity: 0.5;
146 transition: all 0.2s ease-in-out;
147 &:hover { opacity: 0.8; }
148 }
149 }
150 ul {
151 padding-left: 1.2rem;
152 list-style: none;
153 border-left: 3px solid #5f53f482;
154 border-radius: 4px;;
155 li {
156 font-weight: 600;
157 ul li {
158 font-weight: 500;
159 ul li {
160 font-weight: 400;
161 ul li {
162 font-weight: 300;
163 }
164 }
165 }
166 &::before {
167 content: "━ ";
168 color: #5f53f482;
169 margin-left: -1.2rem;
170 }
171 a {
172 transition: all ease-in-out 0.2s;
173 text-decoration: none;
174 &:hover {
175 text-decoration: underline;
176 }
177 }
178 }
179 }
180}
181
182h2 {
183 margin: 0;
184 gap: 1rem;
185 font-size: 2rem;
186 margin: -2rem 0 2rem -4rem;
187 box-shadow: 6px 6px 0 var(--foreground);
188 background: var(--accent);
189 color: var(--accent-fg);
190 width: fit-content;
191 padding: 0.25rem 0.5rem;
192 @media (max-width: 768px) {
193 margin: -2rem auto 1rem auto;
194 }
195}
196
197.search-controlls {
198 float: right;
199 top: 1rem;
200 right: 1rem;
201 position: absolute;
202 @media (max-width: 768px) {
203 position: relative;
204 float: none;
205 top: 0;
206 right: 0;
207 }
208 .press-enter {
209 margin: 0.5rem 0 0 0;
210 opacity: 0.5;
211 visibility: hidden;
212 font-size: 1rem;
213 }
214 input {
215 padding: 0.25rem;
216 border: 2px solid var(--foreground);
217 border-radius: var(--curve-sm);
218 font-size: 1rem;
219 box-shadow: 3px 3px 0 var(--foreground);
220 color: var(--accent-3);
221 &:focus {
222 outline: none;
223 box-shadow: 4px 4px 0 var(--foreground);
224 }
225 }
226}
227
228
229
230</style>