---
import BrandLogo from './BrandLogo.astro';
import PalettePicker from './PalettePicker.astro';
import Icon from './Icon.astro';
import { url } from '../lib/url';
const MAIN_SITE = 'https://daemon-sec.xyz';
// This site's source, on the read-only Git mirror (browse, or `git clone`).
const SOURCE = 'https://git.daemon-sec.xyz/daemon-sec-cheatsheet/';
/**
* The masthead, in the main site's grammar (daemon-sec.xyz `Masthead`): a
* shared brand logo on the left, numbered mono nav in the centre, and the action
* cluster on the right. Each nav entry owns a hue and its index wears it, so
* the bar reads as the colour legend the rest of the site keys back to.
*
* The nav entries and the search / theme / mobile wiring are the cheat-sheet
* site's own — `[data-search-open]`, `[data-theme-toggle]` and
* `[data-mobile-nav-toggle]` are bound in scripts/app.ts and SearchModal.
*/
const NAV = [
{ n: '01', label: 'Vault', href: url(''), acc: 'love', exact: true },
// Every sheet in one filterable index; also lit on the sheets themselves.
{ n: '02', label: 'Sheets', href: url('sheets'), acc: 'foam' },
{ n: '03', label: 'Payloads', href: url('payloads'), acc: 'iris' },
{ n: '04', label: 'Internal', href: url('internal'), acc: 'pine' },
{ n: '05', label: 'HackTricks', href: url('hacktricks'), acc: 'gold' },
{ n: '06', label: 'Tags', href: url('tags'), acc: 'foam' },
{ n: '07', label: 'Credits', href: url('credits'), acc: 'rose' },
];
/* Trailing slashes are `ignore`d by the build, so both spellings of a path
reach here and an exact match would leave the bar saying nowhere. */
const here = Astro.url.pathname.replace(/\/+$/, '') || '/';
const isActive = (href: string, exact?: boolean) => {
const target = href.replace(/\/+$/, '') || '/';
return exact ? here === target : here === target || here.startsWith(target + '/');
};
---
<header class="mast site-header">
<div class="archive mast__row">
<a class="mast__brand dmn-brand-link" href={url('')} aria-label="DAEMON//SEC — home">
<BrandLogo />
</a>
<nav class="mast__nav" aria-label="Sections">
{NAV.map((item) => (
<a
class="mast__navitem"
href={item.href}
style={`--acc: var(--${item.acc});`}
aria-current={isActive(item.href, item.exact) ? 'page' : undefined}
>
<span class="n">{item.n}</span><span class="lbl">{item.label}</span>
<span class="rule" aria-hidden="true"></span>
</a>
))}
</nav>
<div class="mast__actions">
<span class="mast__status" aria-hidden="true">
<span class="dmn-dot" style="--dot: var(--love);"><i class="dmn-anim-pulse"></i><u class="dmn-anim-ring"></u></span>
<span>Offline · Pagefind</span>
</span>
<button class="mast__icon report-index-trigger" data-report-index-open type="button" aria-label="Unlock ordered tool index" title="☧ Unlock tool order" aria-haspopup="dialog" aria-controls="report-index-dialog"><span aria-hidden="true">☧</span></button>
<button class="mast__icon" data-search-open type="button" aria-label="Search the vault">
<Icon name="search" /><kbd>/</kbd>
</button>
<button class="mast__icon mast__mode" data-theme-toggle type="button" aria-label="Dark mode">
<span class="icon-sun"><Icon name="sun" /></span>
<span class="icon-moon"><Icon name="moon" /></span>
</button>
<PalettePicker />
<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>
<a class="mast__icon" href={MAIN_SITE} rel="noopener" aria-label="Back to DÆMON — main site"><Icon name="external" /></a>
<button
class="mast__burger"
data-mobile-nav-toggle
type="button"
aria-label="Open navigation"
aria-controls="mobile-primary-nav"
aria-expanded="false"
>
<i></i><i></i><i></i>
</button>
</div>
</div>
<nav id="mobile-primary-nav" class="mast__mobile" data-mobile-nav aria-label="Primary mobile" hidden>
{NAV.map((item) => (
<a
href={item.href}
style={`--acc: var(--${item.acc});`}
aria-current={isActive(item.href, item.exact) ? 'page' : undefined}
>
<span class="n">{item.n}</span>{item.label}
<span class="arrow" aria-hidden="true">→</span>
</a>
))}
<a href={MAIN_SITE} rel="noopener">
<span class="n" style="--acc: var(--foam);">↗</span>Main site
<span class="arrow" aria-hidden="true" style="--acc: var(--foam);">↗</span>
</a>
<a href={SOURCE} target="_blank" rel="noopener">
<span class="n" style="--acc: var(--gold);">↗</span>Source
<span class="arrow" aria-hidden="true" style="--acc: var(--gold);">↗</span>
</a>
</nav>
</header>