Header.astro (4907B)
1 --- 2 import Icon from './Icon.astro'; 3 import { url } from '../lib/url'; 4 5 const MAIN_SITE = 'https://daemon-sec.xyz'; 6 // This site's source, on the read-only Git mirror (browse, or `git clone`). 7 const SOURCE = 'https://git.daemon-sec.xyz/daemon-sec-cheatsheet/'; 8 9 /** 10 * The masthead, in the main site's grammar (daemon-sec.xyz `Masthead`): a 11 * wordmark chip on the left, numbered mono nav in the centre, and the action 12 * cluster on the right. Each nav entry owns a hue and its index wears it, so 13 * the bar reads as the colour legend the rest of the site keys back to. 14 * 15 * The nav entries and the search / theme / mobile wiring are the cheat-sheet 16 * site's own — `[data-search-open]`, `[data-theme-toggle]` and 17 * `[data-mobile-nav-toggle]` are bound in scripts/app.ts and SearchModal. 18 */ 19 const NAV = [ 20 { n: '01', label: 'Vault', href: url(''), acc: 'love', exact: true }, 21 { n: '02', label: 'Payloads', href: url('payloads'), acc: 'iris' }, 22 { n: '03', label: 'Internal', href: url('internal'), acc: 'pine' }, 23 { n: '04', label: 'HackTricks', href: url('hacktricks'), acc: 'gold' }, 24 { n: '05', label: 'Tags', href: url('tags'), acc: 'foam' }, 25 { n: '06', label: 'Credits', href: url('credits'), acc: 'rose' }, 26 ]; 27 28 /* Trailing slashes are `ignore`d by the build, so both spellings of a path 29 reach here and an exact match would leave the bar saying nowhere. */ 30 const here = Astro.url.pathname.replace(/\/+$/, '') || '/'; 31 const isActive = (href: string, exact?: boolean) => { 32 const target = href.replace(/\/+$/, '') || '/'; 33 return exact ? here === target : here === target || here.startsWith(target + '/'); 34 }; 35 36 /* The Orthodox cross, drawn rather than typed — none of the site's faces 37 carry U+2626, so it would fall back per-character. Ported from the main 38 site's OrthodoxCross. */ 39 const CROSS = `<line x1="9" y1="1.3" x2="9" y2="22.7"/><line x1="6.1" y1="6.2" x2="11.9" y2="6.2"/><line x1="1.3" y1="10.7" x2="16.7" y2="10.7"/><line x1="3.7" y1="15.9" x2="14.3" y2="18.7"/>`; 40 --- 41 <header class="mast site-header"> 42 <div class="archive mast__row"> 43 <a class="mast__brand" href={url('')} aria-label="DÆMON//SEC — home"> 44 <span class="mast__chip">DΛΣMӨП<svg viewBox="0 0 18 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="butt" aria-hidden="true" set:html={CROSS} /></span> 45 </a> 46 47 <nav class="mast__nav" aria-label="Sections"> 48 {NAV.map((item) => ( 49 <a 50 class="mast__navitem" 51 href={item.href} 52 style={`--acc: var(--${item.acc});`} 53 aria-current={isActive(item.href, item.exact) ? 'page' : undefined} 54 > 55 <span class="n">{item.n}</span><span class="lbl">{item.label}</span> 56 <span class="rule" aria-hidden="true"></span> 57 </a> 58 ))} 59 </nav> 60 61 <div class="mast__actions"> 62 <span class="mast__status" aria-hidden="true"> 63 <span class="dmn-dot" style="--dot: var(--love);"><i class="dmn-anim-pulse"></i><u class="dmn-anim-ring"></u></span> 64 <span>Offline · Pagefind</span> 65 </span> 66 <button class="mast__icon" data-search-open type="button" aria-label="Search the vault"> 67 <Icon name="search" /><kbd>/</kbd> 68 </button> 69 <button class="mast__icon mast__mode" data-theme-toggle type="button" aria-label="Dark mode"> 70 <span class="icon-sun"><Icon name="sun" /></span> 71 <span class="icon-moon"><Icon name="moon" /></span> 72 </button> 73 <a class="mast__icon" href={SOURCE} target="_blank" rel="noopener" aria-label="Source code on git.daemon-sec.xyz" title="Source · git.daemon-sec.xyz"><Icon name="branch" /></a> 74 <a class="mast__icon" href={MAIN_SITE} rel="noopener" aria-label="Back to DÆMON — main site"><Icon name="external" /></a> 75 <button 76 class="mast__burger" 77 data-mobile-nav-toggle 78 type="button" 79 aria-label="Open navigation" 80 aria-controls="mobile-primary-nav" 81 aria-expanded="false" 82 > 83 <i></i><i></i><i></i> 84 </button> 85 </div> 86 </div> 87 88 <nav id="mobile-primary-nav" class="mast__mobile" data-mobile-nav aria-label="Primary mobile" hidden> 89 {NAV.map((item) => ( 90 <a 91 href={item.href} 92 style={`--acc: var(--${item.acc});`} 93 aria-current={isActive(item.href, item.exact) ? 'page' : undefined} 94 > 95 <span class="n">{item.n}</span>{item.label} 96 <span class="arrow" aria-hidden="true">→</span> 97 </a> 98 ))} 99 <a href={MAIN_SITE} rel="noopener"> 100 <span class="n" style="--acc: var(--foam);">↗</span>Main site 101 <span class="arrow" aria-hidden="true" style="--acc: var(--foam);">↗</span> 102 </a> 103 <a href={SOURCE} target="_blank" rel="noopener"> 104 <span class="n" style="--acc: var(--gold);">↗</span>Source 105 <span class="arrow" aria-hidden="true" style="--acc: var(--gold);">↗</span> 106 </a> 107 </nav> 108 </header>