Commit 826dde6c84

826dde6c84a5038e25dffda3475500252c882953

parent: daa641eb2b

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-28 17:22 UTC

UX improvments, fix search, display links, improve layout, semantic search results, global site theme switching, and more

Layout: unified · split

web/src/components/scafold/MainCard.astro +1 −1
@@ -8,7 +8,7 @@
8 main { 8 main {
9 margin: 2rem auto; 9 margin: 2rem auto;
10 padding: 1rem; 10 padding: 1rem;
11 width: 1000px; 11 width: 1200px;
12 max-width: calc(100% - 5rem); 12 max-width: calc(100% - 5rem);
13 border: 2px solid var(--box-outline); 13 border: 2px solid var(--box-outline);
14 box-shadow: 6px 6px 0 var(--box-outline); 14 box-shadow: 6px 6px 0 var(--box-outline);
web/src/components/scafold/NavBar.astro +8 −1
@@ -1,5 +1,6 @@
1--- 1---
2import FontAwesome from "@components/form/FontAwesome.svelte" 2import FontAwesome from "@components/form/FontAwesome.svelte"
3import ThemeSwitcher from "@components/form/ThemeSwitcher.svelte"
3 4
4--- 5---
5 6
@@ -13,6 +14,9 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
13 <a href="/search">Search</a> 14 <a href="/search">Search</a>
14 <a href="/about">About</a> 15 <a href="/about">About</a>
15 <a href="https://github.com/lissy93/awesome-privacy">GitHub</a> 16 <a href="https://github.com/lissy93/awesome-privacy">GitHub</a>
17 <div class="theme-switcher">
18 <ThemeSwitcher client:load />
19 </div>
16 </nav> 20 </nav>
17</div> 21</div>
18 22
@@ -62,7 +66,6 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
62 font-family: "Lekton", sans-serif; 66 font-family: "Lekton", sans-serif;
63 font-weight: bold; 67 font-weight: bold;
64 color: var(--foreground); 68 color: var(--foreground);
65 border-left: 2px solid var(--accent-3);
66 transition: background 0.3s, transform 0.3s, box-shadow 0.3s; 69 transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
67 transition-timing-function: ease-in-out; 70 transition-timing-function: ease-in-out;
68 &:hover { 71 &:hover {
@@ -85,6 +88,10 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
85 } 88 }
86 } 89 }
87 } 90 }
91 .theme-switcher {
92 transform: scale(0.7);
93 margin: 0.2rem auto;
94 }
88 } 95 }
89 .homepage, nav { 96 .homepage, nav {
90 @media(max-width: 768px) { 97 @media(max-width: 768px) {
web/src/components/things/PrivacyPolicyDetails.astro +13 −1
@@ -20,6 +20,18 @@ const getIconName = (clasification: string) => {
20 return ''; 20 return '';
21} 21}
22 22
23// If two or more objects in privacyPolicy.points have the same title, remove the duplicates
24const removeDuplicates = () => {
25 const seen = new Set();
26 return priv.points = priv.points.filter((point) => {
27 if (seen.has(point.title)) {
28 return false;
29 }
30 seen.add(point.title);
31 return true;
32 });
33}
34
23--- 35---
24 36
25{priv && ( 37{priv && (
@@ -29,7 +41,7 @@ const getIconName = (clasification: string) => {
29 <div class="left"> 41 <div class="left">
30 <h4>Privacy Policy Summary</h4> 42 <h4>Privacy Policy Summary</h4>
31 <ul class="no-point"> 43 <ul class="no-point">
32 {priv.points.map((point) => ( 44 {removeDuplicates().map((point) => (
33 <li class={`clasification ${point.case.classification}`}> 45 <li class={`clasification ${point.case.classification}`}>
34 <FontAwesome iconName={getIconName(point.case.classification)} /> 46 <FontAwesome iconName={getIconName(point.case.classification)} />
35 {point.title} 47 {point.title}
web/src/components/things/RedditDetailedInfo.astro +36 −28
@@ -11,35 +11,35 @@ interface Props {
11 11
12const { redditData } = Astro.props; 12const { redditData } = Astro.props;
13 13
14
15--- 14---
16 15
17<div class="reddit-info-wrapper"> 16<div class="reddit-info-wrapper">
18 <h3>Reddit</h3> 17 <div class="left">
19 18 <h3>Reddit</h3>
20 <p class="website-title"> 19 <p class="website-title">
21 <img src={redditData.info.icon} width="16" /> 20 <img src={redditData.info.icon} width="16" />
22 {redditData.info.title || redditData.info.name} 21 {redditData.info.title || redditData.info.name}
23 </p> 22 </p>
24 <p class="website-description">{redditData.info.description}</p> 23 <p class="website-description">{redditData.info.description}</p>
25 {redditData.info.banner && (<img class="banner" width="300" src={redditData.info.banner} alt="Banner" />)} 24 {redditData.info.banner && (<img class="banner" width="300" src={redditData.info.banner} alt="Banner" />)}
26 <ul class="list-table"> 25 <ul class="list-table">
27 {redditData.info.dateCreated && ( 26 {redditData.info.dateCreated && (
28 <li> 27 <li>
29 <span class="lbl">Created at</span> 28 <span class="lbl">Created at</span>
30 <span class="val">{timestampToDate(redditData.info.dateCreated * 1000)}</span> 29 <span class="val">{timestampToDate(redditData.info.dateCreated * 1000)}</span>
31 </li> 30 </li>
32 )} 31 )}
33 <li> 32 <li>
34 <span class="lbl">Members</span> 33 <span class="lbl">Members</span>
35 <span class="val">{redditData.info.subscribers}</span> 34 <span class="val">{redditData.info.subscribers}</span>
36 </li> 35 </li>
37 <li> 36 <li>
38 <span class="lbl">Join</span> 37 <span class="lbl">Join</span>
39 <span class="val"><a href={`https://reddit.com/${redditData.info.name}`}>{redditData.info.name}</a></span> 38 <span class="val"><a href={`https://reddit.com/${redditData.info.name}`}>{redditData.info.name}</a></span>
40 </li> 39 </li>
41 </ul> 40 </ul>
42 41 </div>
42 <div class="right">
43 <h4>Posts</h4> 43 <h4>Posts</h4>
44 <ul class="posts"> 44 <ul class="posts">
45 {redditData.posts.map((post) => ( 45 {redditData.posts.map((post) => (
@@ -49,14 +49,22 @@ const { redditData } = Astro.props;
49 </li> 49 </li>
50 ))} 50 ))}
51 </ul> 51 </ul>
52 </div>
52</div> 53</div>
53 54
54 55
55<style lang="scss"> 56<style lang="scss">
56.reddit-info-wrapper { 57.reddit-info-wrapper {
57 display: flex; 58 display: flex;
58 flex-direction: column; 59 flex-wrap: wrap;
59 max-width: 500px; 60 justify-content: space-between;
61 gap: 1rem;
62 .left, .right {
63 width: calc(50% - 1rem);
64 @media screen and (max-width: 768px){
65 width: 100%;
66 }
67 }
60} 68}
61 69
62.banner { 70.banner {
web/src/components/things/Search.svelte +1 −1
@@ -168,7 +168,7 @@
168 transform: translateY(-0.5rem); 168 transform: translateY(-0.5rem);
169 max-height: 500px; 169 max-height: 500px;
170 overflow-y: scroll; 170 overflow-y: scroll;
171 171 background: var(--background-form);
172 li.result-row { 172 li.result-row {
173 padding: 0.5rem 1rem; 173 padding: 0.5rem 1rem;
174 margin: 0.5rem 0; 174 margin: 0.5rem 0;
web/src/layouts/Layout.astro +54 −4
@@ -9,6 +9,11 @@ interface Props {
9 keywords?: string; // Overide keywords tag 9 keywords?: string; // Overide keywords tag
10 hideNav?: boolean; // Don't show the navbar (just homepage) 10 hideNav?: boolean; // Don't show the navbar (just homepage)
11 author?: string; // Author of the content 11 author?: string; // Author of the content
12 customSchemaJson?: any; // Custom schema item
13 breadcrumbs?: Array<{
14 name: string;
15 item: string;
16 }>
12} 17}
13 18
14const { 19const {
@@ -16,9 +21,41 @@ const {
16 description='Your guide to finding privacy-respecting alternatives to popular software and services.', 21 description='Your guide to finding privacy-respecting alternatives to popular software and services.',
17 keywords='security, privacy, awesome privacy, data collection, free software, open source, privacy tools, privacy respecting software', 22 keywords='security, privacy, awesome privacy, data collection, free software, open source, privacy tools, privacy respecting software',
18 hideNav=false, 23 hideNav=false,
19 author='Alicia Sykes' 24 author='Alicia Sykes',
25 breadcrumbs,
26 customSchemaJson,
20} = Astro.props; 27} = Astro.props;
21 28
29const makeBreadcrumbs = () => {
30 if (!breadcrumbs) return null;
31 return {
32 "@context": "https://schema.org",
33 "@type": "BreadcrumbList",
34 "itemListElement": breadcrumbs.map((breadcrumb, index) => ({
35 "@type": "ListItem",
36 "position": index + 1,
37 "name": breadcrumb.name,
38 "item": `https://awesome-privacy.xyz/${breadcrumb.item}`
39 }))
40 }
41}
42
43const makeSearchLd = () => {
44 return {
45 "@context": "https://schema.org",
46 "@type": "WebSite",
47 "url": "https://awesome-privacy.xyz/",
48 "potentialAction": [{
49 "@type": "SearchAction",
50 "target": {
51 "@type": "EntryPoint",
52 "urlTemplate": "https://awesome-privacy.xyz/search?q={search_term_string}"
53 },
54 "query-input": "required name=search_term_string"
55 }]
56 }
57};
58
22--- 59---
23 60
24<!doctype html> 61<!doctype html>
@@ -36,8 +73,8 @@ const {
36 <!-- Page info, viewport, Astro credit --> 73 <!-- Page info, viewport, Astro credit -->
37 <meta charset="UTF-8" /> 74 <meta charset="UTF-8" />
38 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 75 <meta name="viewport" content="width=device-width, initial-scale=1.0">
39 <meta name="viewport" content="width=device-width" />
40 <meta name="generator" content={Astro.generator} /> 76 <meta name="generator" content={Astro.generator} />
77 <meta name="robots" content="index, follow">
41 78
42 <!-- Icons and colors --> 79 <!-- Icons and colors -->
43 <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> 80 <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
@@ -45,16 +82,20 @@ const {
45 <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> 82 <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
46 83
47 <!-- Social media meta tags (Open Graphh + Twitter) --> 84 <!-- Social media meta tags (Open Graphh + Twitter) -->
85 <meta property="og:site_name" content="Awesome Privacy">
48 <meta property="og:type" content="website"> 86 <meta property="og:type" content="website">
49 <meta property="og:url" content="https://awesome-privacy.xyz"> 87 <meta property="og:url" content="https://awesome-privacy.xyz">
50 <meta property="og:title" content={title}> 88 <meta property="og:title" content={title}>
51 <meta property="og:description" content={description}> 89 <meta property="og:description" content={description}>
52 <meta property="og:image" content="/banner.png"> 90 <meta property="og:image" content="https://awesome-privacy.xyz/banner.png">
53 <meta name="twitter:card" content="summary_large_image"> 91 <meta name="twitter:card" content="summary_large_image">
54 <meta name="twitter:url" content="https://awesome-privacy.xyz"> 92 <meta name="twitter:url" content="https://awesome-privacy.xyz">
55 <meta name="twitter:title" content={title}> 93 <meta name="twitter:title" content={title}>
56 <meta name="twitter:description" content={description}> 94 <meta name="twitter:description" content={description}>
57 <meta name="twitter:image" content="/banner.png"> 95 <meta name="twitter:image" content="https://awesome-privacy.xyz/banner.png">
96 <meta name="twitter:site" content="@Lissy_Sykes">
97 <meta name="twitter:creator" content="@Lissy_Sykes">
98
58 99
59 <!-- Non-tracking hit counter --> 100 <!-- Non-tracking hit counter -->
60 <script defer is:inline 101 <script defer is:inline
@@ -62,6 +103,15 @@ const {
62 data-domain="awesome-privacy.xyz" 103 data-domain="awesome-privacy.xyz"
63 src="https://no-track.as93.net/js/script.js"> 104 src="https://no-track.as93.net/js/script.js">
64 </script> 105 </script>
106
107 <!-- Schema.org markup for Google -->
108 {breadcrumbs && (
109 <script type="application/ld+json" set:html={JSON.stringify(makeBreadcrumbs())} />
110 )}
111 {customSchemaJson && (
112 <script type="application/ld+json" set:html={JSON.stringify(customSchemaJson)} />
113 )}
114 <script type="application/ld+json" set:html={JSON.stringify(makeSearchLd)} />
65 </head> 115 </head>
66 <body> 116 <body>
67 {!hideNav && <NavBar /> } 117 {!hideNav && <NavBar /> }
web/src/pages/[...listing].astro +26 −3
@@ -47,6 +47,7 @@ const {
47 androidApp, 47 androidApp,
48 icon, 48 icon,
49 followWith, 49 followWith,
50 links,
50 securityAudited, 51 securityAudited,
51 openSource, 52 openSource,
52 acceptsCrypto, 53 acceptsCrypto,
@@ -84,6 +85,15 @@ const makePageTitle = () => {
84 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`; 85 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
85}; 86};
86 87
88const makeBreadcrumbs = () => {
89 return [
90 { name: 'Home', item: '/' },
91 { name: categoryName, item: slugify(categoryName) },
92 { name: parentSection.name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}` },
93 { name: name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}` },
94 ];
95};
96
87/** 97/**
88 * Make a string page intro, for the description tag 98 * Make a string page intro, for the description tag
89 */ 99 */
@@ -171,7 +181,12 @@ const getApiEndpoint = () => {
171 181
172--- 182---
173 183
174<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} > 184<Layout
185 title={makePageTitle()}
186 keywords={makeKeyWordTag()}
187 description={makeDescriptionTag()}
188 breadcrumbs={makeBreadcrumbs()}
189>
175 <main> 190 <main>
176 <section> 191 <section>
177 <div class="service-head"> 192 <div class="service-head">
@@ -259,6 +274,14 @@ const getApiEndpoint = () => {
259 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a> 274 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a>
260 </li> 275 </li>
261 )} 276 )}
277 { links && links.length > 0 && (
278 links.map((link) => (
279 <li>
280 <b>{link.title}</b>
281 <a href={link.url}>{link.url}</a>
282 </li>
283 ))
284 )}
262 </ul> 285 </ul>
263 </div> 286 </div>
264 </div> 287 </div>
@@ -420,7 +443,7 @@ const getApiEndpoint = () => {
420main { 443main {
421 margin: 2rem auto; 444 margin: 2rem auto;
422 padding: 1rem; 445 padding: 1rem;
423 width: 1000px; 446 width: 1200px;
424 max-width: calc(100% - 5rem); 447 max-width: calc(100% - 5rem);
425 position: relative; 448 position: relative;
426 @media(max-width: 768px) { 449 @media(max-width: 768px) {
@@ -539,7 +562,7 @@ h4 {
539 b { 562 b {
540 font-size: 1rem; 563 font-size: 1rem;
541 font-weight: 400; 564 font-weight: 400;
542 min-width: 85px; 565 min-width: 100px;
543 display: inline-block; 566 display: inline-block;
544 @media(max-width: 768px) { 567 @media(max-width: 768px) {
545 width: auto; 568 width: auto;
web/src/pages/[...section].astro +62 −1
@@ -54,6 +54,14 @@ const makePageTitle = () => {
54 return `${title} | Awesome Privacy`; 54 return `${title} | Awesome Privacy`;
55}; 55};
56 56
57const makeBreadcrumbs = () => {
58 return [
59 { name: 'Home', item: '/' },
60 { name: categoryName, item: slugify(categoryName) },
61 { name: title, item: `${slugify(categoryName)}/${slugify(title)}` },
62 ];
63};
64
57/** 65/**
58 * Make a string page intro, for the description tag 66 * Make a string page intro, for the description tag
59 */ 67 */
@@ -72,6 +80,27 @@ const makeDescriptionTag = () => {
72 return description; 80 return description;
73}; 81};
74 82
83const makeCarasolData = () => {
84 return {
85 "@context": "https://schema.org",
86 "@type": "ItemList",
87 "itemListElement": [
88 services.map((service, index) => ({
89 "@type": "ListItem",
90 "position": index + 1,
91 "url": `https://awesomeprivacy.com/${slugify(categoryName)}/${slugify(title)}/${slugify(service.name)}`,
92 "item": {
93 "@type": "Service",
94 "name": service.name,
95 "description": service.description,
96 "image": service.icon,
97 "url": `https://awesomeprivacy.com/${slugify(categoryName)}/${slugify(title)}/${slugify(service.name)}`
98 }
99 })),
100 ]
101 }
102};
103
75export async function getStaticPaths() { 104export async function getStaticPaths() {
76 const pages = await fetchData().then((data) => { 105 const pages = await fetchData().then((data) => {
77 const results: Array<Props> = []; 106 const results: Array<Props> = [];
@@ -110,9 +139,23 @@ const { previous, next } = makePaginationLinks();
110 139
111--- 140---
112 141
113<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} > 142<Layout
143 title={makePageTitle()}
144 keywords={makeKeyWordTag()}
145 description={makeDescriptionTag()}
146 breadcrumbs={makeBreadcrumbs()}
147 customSchemaJson={makeCarasolData()}
148>
114 <Main> 149 <Main>
115 150
151 <div class="breadcrumbs">
152 <span>
153 <a href="/">Awesome Privacy</a>
154 ➔ <a href={`/${slugify(categoryName)}`}>{categoryName}</a>
155 ➔ <a href={`/${slugify(categoryName)}/${slugify(title)}`}>{title}</a>
156 </span>
157 </div>
158
116 <h2>{title}</h2> 159 <h2>{title}</h2>
117 160
118 {intro && ( 161 {intro && (
@@ -311,5 +354,23 @@ h2 {
311 opacity: 0.7; 354 opacity: 0.7;
312} 355}
313 356
357.breadcrumbs {
358 opacity: 0.5;
359 font-size: 0.8rem;
360 position: absolute;
361 right: 1rem;
362 top: 1rem;
363 a {
364 color: var(--foreground);
365 transition: all 0.15s ease-in-out;
366
367 &:hover {
368 color: var(--accent);
369 }
370 }
371 @media(max-width: 768px) {
372 display: none;
373 }
374}
314 375
315</style> 376</style>
web/src/pages/[category].astro +55 −1
@@ -37,6 +37,33 @@ export async function getStaticPaths() {
37 }); 37 });
38} 38}
39 39
40const makeCarasolData = () => {
41 return {
42 "@context": "https://schema.org",
43 "@type": "ItemList",
44 "itemListElement": [
45 sections.map((section, index) => ({
46 "@type": "ListItem",
47 "position": index + 1,
48 "url": `https://awesomeprivacy.com/${slugify(title)}/${slugify(section.name)}`,
49 "item": {
50 "@type": "Service",
51 "name": section.name,
52 "url": `https://awesomeprivacy.com/${slugify(title)}/${slugify(section.name)}`,
53 }
54 })),
55 ]
56 }
57};
58
59const makeBreadcrumbs = () => {
60 return [
61 { name: 'Home', item: '/' },
62 { name: title, item: slugify(title) },
63 ];
64};
65
66
40const makePaginationLinks = () => { 67const makePaginationLinks = () => {
41 const index = categories.findIndex(category => category.name === title); 68 const index = categories.findIndex(category => category.name === title);
42 const previousCategory = index > 0 ? categories[index - 1].name : null; 69 const previousCategory = index > 0 ? categories[index - 1].name : null;
@@ -48,8 +75,14 @@ const { previous, next } = makePaginationLinks();
48 75
49--- 76---
50 77
51<Layout title={`${title} | Awesome Privacy`}> 78<Layout title={`${title} | Awesome Privacy`} breadcrumbs={makeBreadcrumbs()} customSchemaJson={makeCarasolData()}>
52 <Main> 79 <Main>
80 <div class="breadcrumbs">
81 <span>
82 <a href="/">Awesome Privacy</a>
83 ➔ <a href={`/${slugify(title)}`}>{title}</a>
84 </span>
85 </div>
53 <SectionList title={title} sections={sections} bigTitle={true} /> 86 <SectionList title={title} sections={sections} bigTitle={true} />
54 <a href={`/all#${slugify(title)}`}>Browse All</a> 87 <a href={`/all#${slugify(title)}`}>Browse All</a>
55 <div class="pagination-navigation"> 88 <div class="pagination-navigation">
@@ -100,4 +133,25 @@ const { previous, next } = makePaginationLinks();
100 opacity: 0.5; 133 opacity: 0.5;
101 } 134 }
102} 135}
136
137
138.breadcrumbs {
139 opacity: 0.5;
140 font-size: 0.8rem;
141 position: absolute;
142 right: 1rem;
143 top: 1rem;
144 a {
145 color: var(--foreground);
146 transition: all 0.15s ease-in-out;
147
148 &:hover {
149 color: var(--accent);
150 }
151 }
152 @media(max-width: 768px) {
153 display: none;
154 }
155}
156
103</style> 157</style>
web/src/pages/about.astro −4
@@ -402,10 +402,6 @@ h3 {
402 } 402 }
403 403
404 } 404 }
405 :global(ul li:hover strong) {
406 transition: color 0.2s ease-in-out;
407 color: var(--accent-3);
408 }
409 :global(h3) { 405 :global(h3) {
410 font-size: 1.6rem; 406 font-size: 1.6rem;
411 margin-bottom: 0; 407 margin-bottom: 0;
web/src/pages/browse.astro +45 −57
@@ -36,78 +36,66 @@ const categories: Category[] = (await fetchData())?.categories;
36</Layout> 36</Layout>
37 37
38<script> 38<script>
39// Time for some good ol' fashioned vanilla JS... 39 // Time for some good ol' fashioned vanilla JS...
40// I reccomend you not to look at this code for too long, it's not pretty. 40 // I reccomend you not to look at this code for too long, it's not pretty.
41const filterInput = document.querySelector('input'); 41 document.addEventListener('DOMContentLoaded', function() {
42const categories = document.querySelectorAll<HTMLElement>('.category'); 42 const searchInput = document.getElementById('searchInput');
43const pressEnterMsg = document.getElementById('press-enter-msg') as HTMLElement | null; 43 const categories = document.querySelectorAll('.category');
44const noResults = document.querySelector('.no-results') as HTMLElement | null; 44 const pressEnterMsg = document.getElementById('press-enter-msg');
45 45 const noResults = document.querySelector('.no-results');
46if (!pressEnterMsg || !noResults) { 46
47 throw new Error('No pressEnterMsg or noResults'); 47 if (!pressEnterMsg || !noResults || !searchInput) {
48}; 48 console.error('Essential element missing!');
49 49 return;
50filterInput?.addEventListener('input', (e) => {
51 let resultsCount = 0;
52 const filter = (e.target as HTMLInputElement).value.toLowerCase();
53 if (filter.length > 0) {
54 pressEnterMsg.style.visibility = 'visible';
55 } else {
56 pressEnterMsg.style.visibility = 'hidden';
57 }
58 categories.forEach((category) => {
59 const titleElement = category.querySelector('.category-title');
60 const title = titleElement ? titleElement.textContent?.toLowerCase() : '';
61 const sections = category.querySelectorAll<HTMLElement>('.section');
62 let count = 0;
63 sections.forEach((section) => {
64 const sectionTitle = section.textContent?.toLowerCase();
65 if (sectionTitle?.includes(filter)) {
66 section.style.display = 'block';
67 count++;
68 resultsCount++;
69 } else {
70 section.style.display = 'none';
71 }
72 });
73 if (title && title.includes(filter)) {
74 category.style.display = 'inline-flex';
75 resultsCount++;
76 } else if (count === 0) {
77 category.style.display = 'none';
78 } 50 }
79 });
80 noResults.style.display = resultsCount === 0 ? 'block' : 'none';
81});
82 51
83if (typeof window !== 'undefined') { 52 searchInput.addEventListener('input', (e) => {
84 document.addEventListener('DOMContentLoaded', function() { 53 let resultsCount = 0;
85 const searchInput = document.getElementById('searchInput') as HTMLInputElement | null; 54 const filter = e.target.value.trim().toLowerCase();
86 if (searchInput === null) return; 55 pressEnterMsg.style.visibility = filter ? 'visible' : 'hidden';
87 searchInput.addEventListener('keydown', function(event) { 56
57 categories.forEach((category) => {
58 const titleElement = category.querySelector('.category-title');
59 const title = titleElement ? titleElement.textContent?.toLowerCase() : '';
60 const sections = category.querySelectorAll('.section');
61 let sectionCount = 0;
62
63 sections.forEach((section) => {
64 const sectionTitle = section.textContent?.toLowerCase();
65 if (sectionTitle?.includes(filter)) {
66 section.style.display = 'block';
67 sectionCount++;
68 } else {
69 section.style.display = 'none';
70 }
71 });
72
73 category.style.display = title.includes(filter) || sectionCount > 0 ? 'inline-flex' : 'none';
74 resultsCount += title.includes(filter) ? 1 : sectionCount;
75 });
76
77 noResults.style.display = resultsCount === 0 ? 'block' : 'none';
78 });
79
80 searchInput.addEventListener('keydown', (event) => {
88 if (event.key === 'Enter') { 81 if (event.key === 'Enter') {
89 event.preventDefault(); 82 event.preventDefault();
90 const searchTerm = encodeURIComponent(searchInput.value); 83 window.location.href = `/search/${encodeURIComponent(searchInput.value.trim())}`;
91 window.location.href = `/search/${searchTerm}`;
92 } 84 }
93 if (event.key === 'Escape') { 85 if (event.key === 'Escape') {
94 searchInput.value = ''; 86 searchInput.value = '';
95 searchInput.blur(); 87 searchInput.blur();
96 pressEnterMsg.style.visibility = 'hidden'; 88 pressEnterMsg.style.visibility = 'hidden';
97 categories.forEach((category) => { 89 // Reset display styles
98 category.style.display = 'inline-flex'; 90 categories.forEach(category => category.style.display = 'inline-flex');
99 const sections = category.querySelectorAll<HTMLElement>('.section'); 91 document.querySelectorAll('.section').forEach(section => section.style.display = 'block');
100 sections.forEach((section) => {
101 section.style.display = 'block';
102 });
103 });
104 } 92 }
105 }); 93 });
106 }); 94 });
107}
108</script> 95</script>
109 96
110 97
98
111<style lang="scss"> 99<style lang="scss">
112 100
113.head-wrap { 101.head-wrap {
web/src/styles/values.css +1
@@ -47,6 +47,7 @@
47 --background: #feecff; 47 --background: #feecff;
48 --bg-gradient-comp-1: #feecff; 48 --bg-gradient-comp-1: #feecff;
49 --bg-gradient-comp-2: #e1e4fb; 49 --bg-gradient-comp-2: #e1e4fb;
50 --background-form: #fff;
50 } 51 }
51} 52}
52 53
web/src/types/Service.ts +4
@@ -12,6 +12,10 @@ export interface Service {
12 url: string; 12 url: string;
13 github?: string; 13 github?: string;
14 icon?: string; 14 icon?: string;
15 links?: Array<{
16 title: string;
17 url: string;
18 }>;
15 followWith?: string; 19 followWith?: string;
16 securityAudited?: boolean; 20 securityAudited?: boolean;
17 openSource?: boolean; 21 openSource?: boolean;
web/src/utils/fetch-data.ts +2 −2
@@ -13,5 +13,5 @@ export const fetchData = async (): Promise<AwesomePrivacy> => {
13} 13}
14 14
15export const slugify = (title: string) => { 15export const slugify = (title: string) => {
16 return (title || '').toLowerCase().replace(/\s/g, '-'); 16 return (title || '').toLowerCase().replace(/\s/g, '-').replace(/\+|&/g, 'and');
17}; 17};