Commit 92f2750a0d
Unsigned
Layout: unified · split
web/src/pages/all.astro added +192
| @@ -0,0 +1,192 @@ | ||
| 1 | --- | |
| 2 | ||
| 3 | ||
| 4 | import Layout from '@layouts/Layout.astro'; | |
| 5 | import Button from '@components/form/Button.astro'; | |
| 6 | import Main from '@components/scafold/MainCard.astro'; | |
| 7 | import ServiceList from '@components/things/ServiceList.astro'; | |
| 8 | import type { AwesomePrivacy, Section, Service, ShortService } from '../types/Service'; | |
| 9 | import { fetchData, slugify } from '@utils/fetch-data'; | |
| 10 | import { parseMarkdown } from '@utils/parse-markdown'; | |
| 11 | ||
| 12 | ||
| 13 | const categories = (await fetchData() as AwesomePrivacy).categories; | |
| 14 | ||
| 15 | --- | |
| 16 | ||
| 17 | <script> | |
| 18 | ||
| 19 | const toggleSidebar = () => { | |
| 20 | const mainContent = document.querySelector('#content'); | |
| 21 | mainContent && mainContent.classList.toggle('narrow'); | |
| 22 | const sidebar = document.querySelector('.sidebar'); | |
| 23 | sidebar && sidebar.classList.toggle('hidden'); | |
| 24 | const button = document.querySelector('#toggle-sidebar'); | |
| 25 | if (button) { | |
| 26 | button.textContent = (button.textContent === "Show Contents" ? "Hide Contents" : "Show Contents"); | |
| 27 | } | |
| 28 | }; | |
| 29 | ||
| 30 | const tgt = document.querySelector("#toggle-sidebar"); | |
| 31 | tgt && tgt.addEventListener("click", () => { | |
| 32 | toggleSidebar(); | |
| 33 | }); | |
| 34 | </script> | |
| 35 | ||
| 36 | <Layout title="Awesome Privacy"> | |
| 37 | <main> | |
| 38 | <div id="content"> | |
| 39 | <button id="toggle-sidebar">Show Contents</button> | |
| 40 | {categories.map((category) => ( | |
| 41 | <h2 id={`${slugify(category.name)}`}> | |
| 42 | <a href={`/${slugify(category.name)}`}>{category.name}</a> | |
| 43 | </h2> | |
| 44 | ||
| 45 | <article> | |
| 46 | {category.sections.map((section: Section) => ( | |
| 47 | <section class="card"> | |
| 48 | <h3 id={`${slugify(category.name)}-${slugify(section.name)}`}> | |
| 49 | <a href={`/${slugify(category.name)}/${slugify(section.name)}`}>{section.name}</a> | |
| 50 | </h3> | |
| 51 | <ServiceList title={section.name} services={section.services} subHeading={true} buttonLink={`/${slugify(category.name)}/${slugify(section.name)}`} /> | |
| 52 | </section> | |
| 53 | ))} | |
| 54 | </article> | |
| 55 | ||
| 56 | ))} | |
| 57 | </div> | |
| 58 | <div class="sidebar hidden"> | |
| 59 | <p class="sidebar-title">Contents</p> | |
| 60 | <ul> | |
| 61 | {categories.map((category) => ( | |
| 62 | <li class="top-level"> | |
| 63 | <a href={`#${slugify(category.name)}`}>{category.name}</a> | |
| 64 | </li> | |
| 65 | <li> | |
| 66 | <ul> | |
| 67 | {category.sections.map((section: Section) => ( | |
| 68 | <li> | |
| 69 | <a href={`#${slugify(category.name)}-${slugify(section.name)}`}>{section.name}</a> | |
| 70 | </li> | |
| 71 | ))} | |
| 72 | </ul> | |
| 73 | </li> | |
| 74 | ))} | |
| 75 | </ul> | |
| 76 | </div> | |
| 77 | </main> | |
| 78 | ||
| 79 | </Layout> | |
| 80 | ||
| 81 | <style lang="scss"> | |
| 82 | ||
| 83 | main { | |
| 84 | margin: 2rem auto; | |
| 85 | padding: 1rem; | |
| 86 | width: 1000px; | |
| 87 | max-width: calc(100% - 2rem); | |
| 88 | ||
| 89 | display: flex; | |
| 90 | justify-content: space-between; | |
| 91 | } | |
| 92 | ||
| 93 | .narrow { | |
| 94 | width: 70%; | |
| 95 | } | |
| 96 | ||
| 97 | .hidden { | |
| 98 | display: none; | |
| 99 | } | |
| 100 | ||
| 101 | #toggle-sidebar { | |
| 102 | // float: right; | |
| 103 | background: none; | |
| 104 | outline: none; | |
| 105 | border: none; | |
| 106 | cursor: pointer; | |
| 107 | &:hover { | |
| 108 | text-decoration: underline; | |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | .sidebar { | |
| 113 | width: 25%; | |
| 114 | height: 87vh; | |
| 115 | overflow: scroll; | |
| 116 | position: fixed; | |
| 117 | right: 1rem; | |
| 118 | border-radius: var(--curve-md); | |
| 119 | .sidebar-title { | |
| 120 | text-align: center; | |
| 121 | font-size: 1.6rem; | |
| 122 | margin: 0; | |
| 123 | background: var(--accent-3); | |
| 124 | color: var(--accent-fg); | |
| 125 | border: 2px solid var(--foreground); | |
| 126 | box-shadow: 6px 6px 0 var(--foreground); | |
| 127 | border-radius: var(--curve-sm); | |
| 128 | margin: 0 1rem; | |
| 129 | } | |
| 130 | ul { | |
| 131 | list-style: none; | |
| 132 | padding-left: 1.6rem; | |
| 133 | a { | |
| 134 | text-decoration: none; | |
| 135 | color: var(--foreground); | |
| 136 | opacity: 0.6; | |
| 137 | transition: all 0.18s ease-in-out; | |
| 138 | &:hover { | |
| 139 | color: var(--accent); | |
| 140 | opacity: 1; | |
| 141 | } | |
| 142 | } | |
| 143 | li ul { | |
| 144 | list-style: circle; | |
| 145 | } | |
| 146 | .top-level { | |
| 147 | font-weight: bold; | |
| 148 | margin-top: 0.5rem; | |
| 149 | &:hover a { | |
| 150 | color: var(--accent-3); | |
| 151 | } | |
| 152 | } | |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 156 | ||
| 157 | .card { | |
| 158 | margin: 2rem auto 5rem auto; | |
| 159 | padding: 0 2rem; | |
| 160 | border: 2px solid var(--foreground); | |
| 161 | box-shadow: 6px 6px 0 var(--foreground); | |
| 162 | background: var(--accent-fg); | |
| 163 | } | |
| 164 | ||
| 165 | h2 { | |
| 166 | margin: 0; | |
| 167 | font-size: 3rem; | |
| 168 | text-align: center; | |
| 169 | opacity: 0.6; | |
| 170 | a { | |
| 171 | color: var(--accent-3); | |
| 172 | text-decoration: none; | |
| 173 | } | |
| 174 | } | |
| 175 | ||
| 176 | h3 { | |
| 177 | font-size: 2rem; | |
| 178 | margin: -2rem 0 2rem -4rem; | |
| 179 | box-shadow: 6px 6px 0 var(--foreground); | |
| 180 | background: var(--accent); | |
| 181 | color: var(--accent-fg); | |
| 182 | width: fit-content; | |
| 183 | padding: 0.25rem 0.5rem; | |
| 184 | a { | |
| 185 | color: var(--accent-fg); | |
| 186 | font-family: "Lekton", sans-serif; | |
| 187 | text-decoration: none; | |
| 188 | } | |
| 189 | } | |
| 190 | ||
| 191 | ||
| 192 | </style> | |