Initial Roux Hugo site — fashion journal for roux.pivoine.art
100-post fashion journal generated from ~/projects/ginger content: - Hugo Extended static site with TailwindCSS v4 - WebP image pipeline (thumb/card/og/full sizes via Hugo image processing) - Full SEO: sitemap (501 URLs), OpenGraph with per-post images, Twitter cards - Async page transitions via View Transitions API - Deep-linked URLs: /posts/[slug]/, /categories/[cat]/, /tags/[tag]/, /issues/ - Lightbox with keyboard/swipe nav, thumbnail strip, inverted search index - Issues archive with quarterly release structure - Multi-stage Dockerfile (Tailwind → Hugo → nginx:alpine) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,341 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-paper: #f1ebe0;
|
||||
--color-paper-2: #e9e1d2;
|
||||
--color-ink: #16110d;
|
||||
--color-ink-2: #2a221c;
|
||||
--color-ink-soft: #5b4f44;
|
||||
--color-rule: #cbbfac;
|
||||
--color-rule-2: #ddd2bf;
|
||||
--color-roux: #8a3322;
|
||||
--color-roux-deep:#5c1f17;
|
||||
--color-cream: #f7f2e8;
|
||||
|
||||
--font-display: "Italiana", "Cormorant Garamond", serif;
|
||||
--font-serif: "Cormorant Garamond", "EB Garamond", "Times New Roman", serif;
|
||||
--font-sans: "Outfit", "Manrope", system-ui, sans-serif;
|
||||
--font-mono: "JetBrains Mono", ui-monospace, monospace;
|
||||
}
|
||||
|
||||
/* ── globals ── */
|
||||
:root {
|
||||
--paper: #f1ebe0;
|
||||
--paper-2: #e9e1d2;
|
||||
--ink: #16110d;
|
||||
--ink-2: #2a221c;
|
||||
--ink-soft: #5b4f44;
|
||||
--rule: #cbbfac;
|
||||
--rule-2: #ddd2bf;
|
||||
--roux: #8a3322;
|
||||
--roux-deep:#5c1f17;
|
||||
--cream: #f7f2e8;
|
||||
--serif: "Cormorant Garamond", "EB Garamond", serif;
|
||||
--display: "Italiana", "Cormorant Garamond", serif;
|
||||
--sans: "Outfit", "Manrope", system-ui, sans-serif;
|
||||
--mono: "JetBrains Mono", ui-monospace, monospace;
|
||||
--pad: clamp(20px, 4vw, 56px);
|
||||
--gap: clamp(18px, 2.6vw, 36px);
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font-family: var(--sans);
|
||||
font-feature-settings: "ss01", "cv11";
|
||||
font-size: 15px;
|
||||
line-height: 1.45;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
img { display: block; max-width: 100%; }
|
||||
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
|
||||
a { color: inherit; text-decoration: none; }
|
||||
::selection { background: var(--ink); color: var(--paper); }
|
||||
|
||||
/* ── paper grain overlay ── */
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed; inset: 0;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
opacity: .06;
|
||||
mix-blend-mode: multiply;
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
|
||||
}
|
||||
|
||||
/* ── masthead ── */
|
||||
.masthead {
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
backdrop-filter: blur(14px) saturate(1.05);
|
||||
background: color-mix(in oklab, var(--paper) 86%, transparent);
|
||||
border-bottom: 1px solid var(--rule);
|
||||
}
|
||||
.masthead__inner {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: clamp(12px, 2vw, 24px);
|
||||
padding: 14px var(--pad);
|
||||
}
|
||||
.masthead__left, .masthead__right {
|
||||
display: flex; align-items: center; gap: 18px;
|
||||
font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
|
||||
color: var(--ink-soft);
|
||||
min-width: 0;
|
||||
}
|
||||
.masthead__left > *, .masthead__right > * { white-space: nowrap; }
|
||||
.mh-link { position: relative; padding-bottom: 2px; transition: color .2s; }
|
||||
.mh-link::after {
|
||||
content: ""; position: absolute; left: 0; right: 0; bottom: 0;
|
||||
height: 1px; background: currentColor; transform: scaleX(.5); transform-origin: left;
|
||||
transition: transform .25s, background .2s;
|
||||
}
|
||||
.mh-link:hover { color: var(--ink); }
|
||||
.mh-link:hover::after { transform: scaleX(1); background: var(--roux); }
|
||||
.masthead__right { justify-content: flex-end; }
|
||||
.masthead__date { font-variant-numeric: tabular-nums; }
|
||||
.masthead__logo { display: block; line-height: 1; color: var(--ink); justify-self: center; }
|
||||
|
||||
.logo { display: grid; grid-template-columns: auto; justify-items: center; gap: 4px; text-align: center; }
|
||||
.logo__mark { width: 30px; height: 30px; display: block; }
|
||||
.logo__word { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: .045em; color: var(--ink); }
|
||||
.logo__tag { font: 500 8.5px/1 var(--sans); letter-spacing: .32em; text-transform: uppercase; color: var(--ink-soft); }
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.logo__mark { width: 22px; height: 22px; }
|
||||
.logo__word { font-size: 22px; }
|
||||
.logo__tag { font-size: 7.5px; letter-spacing: .28em; }
|
||||
}
|
||||
@media (max-width: 1100px) { .masthead__left .mh-issue, .masthead__right .mh-city { display: none; } }
|
||||
@media (max-width: 820px) { .masthead__left .mh-pub, .masthead__left .mh-sep, .masthead__right .mh-sep { display: none; } }
|
||||
@media (max-width: 620px) { .masthead__inner { padding: 12px var(--pad); } .masthead__left { font-size: 10px; gap: 10px; } .masthead__right { font-size: 10px; gap: 10px; } }
|
||||
@media (max-width: 460px) { .masthead__inner { grid-template-columns: 1fr; } .masthead__left, .masthead__right { display: none; } .masthead__logo { justify-self: center; } }
|
||||
|
||||
/* subhead: search bar */
|
||||
.subhead {
|
||||
display: flex; align-items: stretch;
|
||||
border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule);
|
||||
background: color-mix(in oklab, var(--paper) 95%, transparent);
|
||||
position: relative;
|
||||
}
|
||||
.subhead__search {
|
||||
flex: 1; display: flex; align-items: center; gap: 12px;
|
||||
padding: 10px var(--pad); border-right: 1px solid var(--rule-2); min-width: 0;
|
||||
}
|
||||
.subhead__search input {
|
||||
flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
|
||||
font: 400 16px/1 var(--serif); font-style: italic; color: var(--ink); letter-spacing: .005em; padding: 6px 0;
|
||||
}
|
||||
.subhead__search input::placeholder { color: var(--ink-soft); opacity: .9; }
|
||||
.subhead__kbd { flex: 0 0 auto; font: 500 10px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; border: 1px solid var(--rule); padding: 5px 7px; border-radius: 3px; color: var(--ink-soft); }
|
||||
.subhead__count { display: flex; align-items: center; padding: 0 var(--pad); font: 500 11px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.subhead__count b { color: var(--ink); font-weight: 600; margin-right: 4px; }
|
||||
@media (max-width: 720px) { .subhead__count { display: none; } .subhead__kbd { display: none; } .subhead__search input { font-size: 15px; } }
|
||||
|
||||
/* tabs */
|
||||
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 10px var(--pad); border-bottom: 1px solid var(--rule-2); background: var(--paper); scrollbar-width: none; }
|
||||
.tabs::-webkit-scrollbar { display: none; }
|
||||
.tabs button { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); border: 1px solid transparent; transition: color .2s, border-color .2s, background .2s; }
|
||||
.tabs button:hover { color: var(--ink); }
|
||||
.tabs button[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
|
||||
|
||||
/* ── hero strip ── */
|
||||
.hero {
|
||||
padding: clamp(40px, 8vw, 96px) var(--pad) clamp(28px, 5vw, 64px);
|
||||
display: grid; grid-template-columns: 1fr; gap: 18px;
|
||||
border-bottom: 1px solid var(--rule);
|
||||
}
|
||||
.hero__eyebrow { font: 500 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 12px; }
|
||||
.hero__eyebrow::before { content: ""; height: 1px; width: 36px; background: var(--ink-soft); }
|
||||
.hero__title { margin: 0; font: 400 clamp(48px, 9vw, 132px)/0.92 var(--display); letter-spacing: -0.01em; }
|
||||
.hero__title em { font-family: var(--serif); font-style: italic; font-weight: 300; color: var(--roux); }
|
||||
.hero__lede { max-width: 56ch; font: 400 clamp(16px, 1.4vw, 19px)/1.5 var(--serif); color: var(--ink-2); margin-top: 6px; }
|
||||
.hero__lede em { color: var(--roux); font-style: italic; }
|
||||
|
||||
/* ── photo grid ── */
|
||||
.grid {
|
||||
padding: clamp(20px, 3vw, 40px) var(--pad) 80px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
column-gap: var(--gap);
|
||||
row-gap: clamp(40px, 5vw, 72px);
|
||||
}
|
||||
@media (max-width: 1200px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||||
@media (max-width: 820px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
|
||||
|
||||
.grid[data-density="cozy"] { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 88px; }
|
||||
.grid[data-density="compact"] { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 56px; }
|
||||
@media (max-width: 1200px) { .grid[data-density="cozy"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid[data-density="compact"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
|
||||
@media (max-width: 820px) { .grid[data-density="cozy"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid[data-density="compact"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||||
@media (max-width: 520px) { .grid[data-density="cozy"] { grid-template-columns: 1fr; } .grid[data-density="compact"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
|
||||
/* card */
|
||||
.card { display: block; cursor: pointer; }
|
||||
.card__frame { position: relative; aspect-ratio: 2/3; overflow: hidden; background: var(--paper-2); border-radius: 1px; }
|
||||
.card__frame::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(22,17,13,.04); pointer-events: none; }
|
||||
.card__img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s cubic-bezier(.2,.7,.1,1), filter .6s; filter: saturate(.92) contrast(1.02); }
|
||||
.card:hover .card__img { transform: scale(1.025); }
|
||||
.card__num { position: absolute; top: 10px; left: 10px; font: 500 10px/1 var(--sans); letter-spacing: .18em; color: var(--paper); mix-blend-mode: difference; font-variant-numeric: tabular-nums; }
|
||||
.card__cat { position: absolute; top: 10px; right: 10px; font: 500 10px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--paper); mix-blend-mode: difference; }
|
||||
.card__meta { margin-top: 14px; display: grid; gap: 4px; }
|
||||
.card__title { font: 400 clamp(20px, 1.6vw, 26px)/1.1 var(--display); letter-spacing: 0; margin: 0; }
|
||||
.card__title em { font-family: var(--serif); font-style: italic; color: var(--roux); }
|
||||
.card__sub { font: 400 12px/1.4 var(--sans); letter-spacing: .04em; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; }
|
||||
.card__sub .dot { width: 3px; height: 3px; background: var(--ink-soft); border-radius: 50%; opacity: .5; }
|
||||
.card__desc { font: 400 13px/1.5 var(--serif); color: var(--ink-2); font-style: italic; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
|
||||
/* highlight matches */
|
||||
mark.hl { background: color-mix(in oklab, var(--roux) 22%, transparent); color: inherit; padding: 0 1px; border-radius: 1px; }
|
||||
|
||||
/* ── issues archive ── */
|
||||
.issues-grid {
|
||||
padding: clamp(20px, 3vw, 40px) var(--pad) 80px;
|
||||
display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
column-gap: clamp(24px, 3vw, 48px); row-gap: clamp(36px, 5vw, 64px);
|
||||
}
|
||||
@media (max-width: 820px) { .issues-grid { grid-template-columns: 1fr; } }
|
||||
|
||||
.issue-card {
|
||||
display: grid; grid-template-columns: 240px 1fr;
|
||||
gap: clamp(20px, 2.4vw, 36px); align-items: start;
|
||||
color: inherit;
|
||||
padding-bottom: clamp(28px, 3.5vw, 44px); border-bottom: 1px solid var(--rule-2);
|
||||
}
|
||||
@media (max-width: 560px) { .issue-card { grid-template-columns: 160px 1fr; } }
|
||||
.issue-card--forthcoming { color: var(--ink-soft); cursor: default; }
|
||||
|
||||
.issue-card__cover { aspect-ratio: 2/3; overflow: hidden; background: var(--paper-2); position: relative; }
|
||||
.issue-card__cover::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(22,17,13,.04); }
|
||||
.issue-card__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s cubic-bezier(.2,.7,.1,1); }
|
||||
.issue-card:not(.issue-card--forthcoming):hover .issue-card__cover img { transform: scale(1.025); }
|
||||
.issue-card__forth { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--ink-soft); font: 500 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; border: 1px dashed var(--rule); margin: 12px; }
|
||||
.issue-card__forth svg { opacity: .5; }
|
||||
.issue-card__meta { padding-top: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; min-width: 0; }
|
||||
.issue-card__num { font: 500 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
|
||||
.issue-card__title { margin: 0; font: 400 clamp(28px, 3vw, 44px)/1.0 var(--display); letter-spacing: -0.005em; }
|
||||
.issue-card__title em { font-family: var(--serif); font-style: italic; color: var(--roux); font-weight: 300; }
|
||||
.issue-card--forthcoming .issue-card__title { color: var(--ink-soft); }
|
||||
.issue-card__blurb { font: 400 14.5px/1.55 var(--serif); font-style: italic; color: var(--ink-2); margin: 0; max-width: 52ch; }
|
||||
.issue-card__foot { margin-top: 4px; display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; font: 500 10.5px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); width: 100%; }
|
||||
.issue-card__foot > span:first-child { flex: 1; min-width: 0; }
|
||||
.issue-card__cta { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--ink); padding-bottom: 2px; letter-spacing: .14em; }
|
||||
.issue-card__cta--muted { color: var(--ink-soft); border-bottom-color: var(--rule); }
|
||||
|
||||
/* ── empty state ── */
|
||||
.empty { grid-column: 1/-1; padding: 80px 0; text-align: center; color: var(--ink-soft); }
|
||||
.empty h3 { font: 400 28px/1.2 var(--display); color: var(--ink); margin: 0 0 8px; }
|
||||
.empty button { margin-top: 16px; border: 1px solid var(--ink); padding: 9px 18px; font: 500 11px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; }
|
||||
.empty button:hover { background: var(--ink); color: var(--paper); }
|
||||
|
||||
/* ── search popup ── */
|
||||
.searchpop { position: absolute; top: calc(100% - 1px); left: 0; right: 0; background: var(--paper); border: 1px solid var(--rule); border-top: 0; max-height: min(70vh, 620px); overflow: auto; display: none; z-index: 60; box-shadow: 0 24px 60px -30px rgba(22,17,13,.35); }
|
||||
.searchpop[data-open="true"] { display: block; }
|
||||
.searchpop__section { padding: 12px var(--pad); border-bottom: 1px solid var(--rule-2); }
|
||||
.searchpop__section:last-child { border-bottom: 0; }
|
||||
.searchpop__label { font: 500 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
|
||||
.searchpop__label small { font-family: var(--mono); letter-spacing: 0; font-size: 10px; }
|
||||
.searchpop__chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.searchpop__chip { padding: 5px 10px; border: 1px solid var(--rule); border-radius: 999px; font: 500 11px/1 var(--sans); letter-spacing: .06em; color: var(--ink-2); }
|
||||
.searchpop__chip:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
|
||||
.searchpop__chip b { color: var(--roux); font-weight: 600; }
|
||||
.searchpop__hits { display: grid; gap: 2px; }
|
||||
.searchpop__hit { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 8px 6px; border-radius: 3px; text-align: left; width: 100%; }
|
||||
.searchpop__hit:hover { background: var(--paper-2); }
|
||||
.searchpop__hit img { width: 44px; height: 66px; object-fit: cover; background: var(--paper-2); }
|
||||
.searchpop__hit .t { font: 400 18px/1.1 var(--display); }
|
||||
.searchpop__hit .s { font: 400 12px/1.3 var(--sans); color: var(--ink-soft); margin-top: 3px; }
|
||||
.searchpop__hit .n { font: 500 10px/1 var(--mono); color: var(--ink-soft); letter-spacing: .1em; }
|
||||
|
||||
/* ── lightbox ── */
|
||||
.lb {
|
||||
position: fixed; inset: 0; background: #0c0907; color: #ece7dd; z-index: 200;
|
||||
display: none; opacity: 0; transition: opacity .35s ease;
|
||||
}
|
||||
.lb[data-open="true"] { display: grid; opacity: 1; }
|
||||
.lb {
|
||||
grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr auto;
|
||||
grid-template-areas: "topbar topbar" "stage meta" "thumbs thumbs";
|
||||
}
|
||||
@media (max-width: 920px) {
|
||||
.lb { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto auto; grid-template-areas: "topbar" "stage" "meta" "thumbs"; }
|
||||
}
|
||||
.lb__topbar { grid-area: topbar; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 22px; border-bottom: 1px solid rgba(236,231,221,.08); }
|
||||
.lb__brand { display: flex; align-items: center; gap: 14px; font: 500 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: #c8c0b1; }
|
||||
.lb__brand svg { height: 18px; }
|
||||
.lb__index { font: 500 11px/1 var(--mono); letter-spacing: .14em; color: #c8c0b1; font-variant-numeric: tabular-nums; }
|
||||
.lb__index b { color: #ece7dd; }
|
||||
.lb__close { width: 36px; height: 36px; border: 1px solid rgba(236,231,221,.18); border-radius: 50%; display: grid; place-items: center; color: #ece7dd; }
|
||||
.lb__close:hover { background: rgba(236,231,221,.08); }
|
||||
.lb__stage { grid-area: stage; position: relative; overflow: hidden; display: grid; place-items: center; padding: 24px; min-height: 0; }
|
||||
.lb__track { position: absolute; inset: 0; display: flex; transition: transform .55s cubic-bezier(.4,.0,.2,1); will-change: transform; }
|
||||
.lb__slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; min-width: 0; }
|
||||
.lb__frame { position: relative; aspect-ratio: 2/3; height: 100%; max-width: 100%; background: #1a1411; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(236,231,221,.04); }
|
||||
.lb__img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
|
||||
.lb__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 56px; height: 56px; border-radius: 50%; background: rgba(236,231,221,.06); border: 1px solid rgba(236,231,221,.16); backdrop-filter: blur(8px); display: grid; place-items: center; color: #ece7dd; z-index: 5; transition: background .2s; }
|
||||
.lb__nav:hover { background: rgba(236,231,221,.14); }
|
||||
.lb__nav--prev { left: 18px; }
|
||||
.lb__nav--next { right: 18px; }
|
||||
.lb__meta { grid-area: meta; padding: 28px 28px 22px; border-left: 1px solid rgba(236,231,221,.08); display: flex; flex-direction: column; gap: 18px; overflow: auto; }
|
||||
@media (max-width: 920px) { .lb__meta { border-left: 0; border-top: 1px solid rgba(236,231,221,.08); padding: 18px 22px; max-height: 38vh; } }
|
||||
.lb__cat { font: 500 11px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--roux); }
|
||||
.lb__cat::after { content: ""; display: block; height: 1px; width: 30px; background: var(--roux); margin-top: 8px; }
|
||||
.lb__title { margin: 0; font: 400 clamp(32px, 3vw, 44px)/1 var(--display); letter-spacing: -0.005em; color: #f5f0e6; }
|
||||
.lb__title em { font-family: var(--serif); font-style: italic; color: #d99e8e; font-weight: 300; }
|
||||
.lb__desc { font: 400 16px/1.55 var(--serif); font-style: italic; color: #c8c0b1; }
|
||||
.lb__factgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; border-top: 1px solid rgba(236,231,221,.08); border-bottom: 1px solid rgba(236,231,221,.08); padding: 16px 0; }
|
||||
.lb__fact dt { font: 500 10px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: #9b9384; margin-bottom: 5px; }
|
||||
.lb__fact dd { margin: 0; font: 400 14px/1.3 var(--serif); color: #ece7dd; }
|
||||
.lb__tags { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.lb__tag { padding: 5px 10px; border: 1px solid rgba(236,231,221,.18); border-radius: 999px; font: 500 10px/1 var(--sans); letter-spacing: .1em; text-transform: lowercase; color: #ece7dd; }
|
||||
.lb__tag:hover { background: rgba(236,231,221,.08); }
|
||||
.lb__share { margin-top: auto; display: flex; gap: 8px; }
|
||||
.lb__sh { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 14px; border: 1px solid rgba(236,231,221,.2); font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #ece7dd; white-space: nowrap; transition: background .2s, color .2s, border-color .2s; }
|
||||
.lb__sh--primary { flex: 1; min-width: 0; }
|
||||
.lb__sh:not(.lb__sh--primary) { width: 44px; padding: 11px 0; flex: 0 0 auto; }
|
||||
.lb__sh:hover { background: #ece7dd; color: #0c0907; border-color: #ece7dd; }
|
||||
.lb__sh.is-ok { background: rgba(236,231,221,.08); color: #ece7dd; border-color: rgba(236,231,221,.32); }
|
||||
.lb__thumbs { grid-area: thumbs; display: flex; gap: 6px; padding: 12px 22px 16px; overflow-x: auto; border-top: 1px solid rgba(236,231,221,.08); scrollbar-width: thin; scrollbar-color: rgba(236,231,221,.16) transparent; }
|
||||
.lb__thumb { flex: 0 0 auto; width: 42px; aspect-ratio: 2/3; background: #1a1411; border: 1px solid transparent; opacity: .45; transition: opacity .2s, border-color .2s; position: relative; }
|
||||
.lb__thumb:hover { opacity: .8; }
|
||||
.lb__thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.lb__thumb[aria-current="true"] { opacity: 1; border-color: var(--roux); }
|
||||
.lb__thumb[aria-current="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 2px; background: var(--roux); }
|
||||
|
||||
/* ── footer ── */
|
||||
.foot { border-top: 1px solid var(--rule); padding: 36px var(--pad) 56px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; font: 400 12px/1.5 var(--sans); color: var(--ink-soft); }
|
||||
@media (max-width: 820px) { .foot { grid-template-columns: 1fr 1fr; } }
|
||||
.foot h4 { font: 500 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--ink); margin: 0 0 14px; }
|
||||
.foot a:hover { color: var(--ink); }
|
||||
.foot__roux { font: 400 clamp(60px, 8vw, 110px)/0.92 var(--display); color: var(--ink); margin: 0 0 14px; }
|
||||
.foot__roux em { font-family: var(--serif); font-style: italic; color: var(--roux); font-weight: 300; }
|
||||
|
||||
/* ── ribbon ── */
|
||||
.ribbon { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--ink); color: var(--paper); font: 500 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; padding: 10px var(--pad); display: flex; align-items: center; justify-content: space-between; gap: 24px; transform: translateY(0); transition: transform .4s; }
|
||||
.ribbon.hidden { transform: translateY(100%); }
|
||||
.ribbon a { color: var(--roux); font-weight: 600; }
|
||||
.ribbon button { color: var(--paper); opacity: .7; }
|
||||
.ribbon button:hover { opacity: 1; }
|
||||
|
||||
/* ── animations ── */
|
||||
@keyframes rouxIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
||||
.card { animation: rouxIn .6s cubic-bezier(.2,.7,.2,1) both; animation-delay: var(--d, 0ms); }
|
||||
.issue-card { opacity: 0; transform: translateY(8px); animation: rouxIn .65s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: var(--d, 0ms); }
|
||||
@supports (animation-timeline: view()) { .issue-card { opacity: 1; transform: none; animation: none; } }
|
||||
|
||||
/* ── view transitions ── */
|
||||
::view-transition-old(root) { animation: 150ms ease-out roux-fade-out; }
|
||||
::view-transition-new(root) { animation: 220ms ease-in roux-fade-in; }
|
||||
@keyframes roux-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
||||
@keyframes roux-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
||||
|
||||
/* ── scrollbar ── */
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 0; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
@@ -0,0 +1,452 @@
|
||||
/* ROUX — app.js */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// ── Data (injected by Hugo into a JSON script tag)
|
||||
let POSTS = [];
|
||||
try {
|
||||
const el = document.getElementById('roux-data');
|
||||
if (el) POSTS = JSON.parse(el.textContent) || [];
|
||||
} catch (e) { console.warn('roux-data parse failed', e); }
|
||||
|
||||
const STOP = new Set(['the','a','an','of','and','in','on','at','by','with','is','to','for','from','as','into','onto','its','it','that','this','but','or','be','not','no','one','two','three']);
|
||||
|
||||
// ── Helpers
|
||||
function esc(s) { return String(s).replace(/[&<>"]/g, c => ({'&':'&','<':'<','>':'>','"':'"'}[c])); }
|
||||
|
||||
function highlight(text, terms) {
|
||||
if (!terms.length) return esc(text);
|
||||
const re = new RegExp('(' + terms.map(t => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|') + ')', 'ig');
|
||||
return esc(text).replace(re, '<mark class="hl">$1</mark>');
|
||||
}
|
||||
|
||||
// ── Inverted search index
|
||||
const INDEX = (() => {
|
||||
const map = new Map();
|
||||
function add(token, idx, weight) {
|
||||
const t = token.toLowerCase();
|
||||
if (!t || t.length < 2 || STOP.has(t)) return;
|
||||
let b = map.get(t);
|
||||
if (!b) { b = new Map(); map.set(t, b); }
|
||||
b.set(idx, (b.get(idx) || 0) + weight);
|
||||
}
|
||||
function tok(s) { return (s || '').toLowerCase().split(/[^a-z0-9àâäéèêëîïôöùûüçœæñ]+/i).filter(Boolean); }
|
||||
|
||||
POSTS.forEach((p, i) => {
|
||||
tok(p.title).forEach(t => add(t, i, 6));
|
||||
(p.categories || []).forEach(c => tok(c).forEach(t => add(t, i, 4)));
|
||||
(p.tags || []).forEach(tag => tok(tag).forEach(t => add(t, i, 5)));
|
||||
tok(p.description).forEach(t => add(t, i, 1));
|
||||
tok(p.id).forEach(t => add(t, i, 8));
|
||||
});
|
||||
|
||||
return function search(q) {
|
||||
const tokens = tok(q);
|
||||
if (!tokens.length) return null;
|
||||
const perToken = tokens.map(tok => {
|
||||
const merged = new Map();
|
||||
for (const [term, b] of map) {
|
||||
if (term.startsWith(tok)) {
|
||||
const factor = term === tok ? 1.0 : tok.length / term.length;
|
||||
for (const [pi, w] of b) merged.set(pi, (merged.get(pi) || 0) + w * factor);
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
});
|
||||
const first = perToken[0];
|
||||
const scores = new Map();
|
||||
for (const [idx, w] of first) {
|
||||
let total = w, ok = true;
|
||||
for (let i = 1; i < perToken.length; i++) {
|
||||
const v = perToken[i].get(idx);
|
||||
if (!v) { ok = false; break; }
|
||||
total += v;
|
||||
}
|
||||
if (ok) scores.set(idx, total);
|
||||
}
|
||||
return Array.from(scores.entries())
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.map(([i]) => POSTS[i]);
|
||||
};
|
||||
})();
|
||||
|
||||
// ── Masthead date
|
||||
const mhDate = document.getElementById('mhDate');
|
||||
if (mhDate) {
|
||||
const d = new Date();
|
||||
mhDate.textContent = d.toLocaleDateString('en-GB', { day:'numeric', month:'long', year:'numeric' });
|
||||
}
|
||||
|
||||
// ── Count display
|
||||
const countEl = document.getElementById('count');
|
||||
function setCount(n) {
|
||||
if (!countEl) return;
|
||||
countEl.innerHTML = `<b>${String(n).padStart(3,'0')}</b> ${n === 1 ? 'post' : 'posts'}`;
|
||||
}
|
||||
setCount(POSTS.length);
|
||||
|
||||
// ── Tabs: sync active state with current URL
|
||||
function syncTabs() {
|
||||
const tabs = document.querySelectorAll('.tabs button[data-cat]');
|
||||
const path = location.pathname;
|
||||
tabs.forEach(btn => {
|
||||
const cat = btn.dataset.cat;
|
||||
const active = (cat === 'All' && (path === '/' || path === '/posts/' || path.startsWith('/posts')))
|
||||
|| (cat !== 'All' && path.toLowerCase().includes(cat.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '')));
|
||||
btn.setAttribute('aria-pressed', active ? 'true' : 'false');
|
||||
});
|
||||
}
|
||||
syncTabs();
|
||||
|
||||
// Tab click → navigate to category page
|
||||
document.addEventListener('click', e => {
|
||||
const btn = e.target.closest('.tabs button[data-cat]');
|
||||
if (!btn) return;
|
||||
const cat = btn.dataset.cat;
|
||||
if (cat === 'All') navigate('/');
|
||||
else navigate('/categories/' + cat.toLowerCase().replace(/[\s,]+/g, '-').replace(/[^a-z0-9-]/g, '') + '/');
|
||||
});
|
||||
|
||||
// ── Search popup
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const searchPop = document.getElementById('searchpop');
|
||||
|
||||
function allCats() {
|
||||
const s = new Set();
|
||||
POSTS.forEach(p => (p.categories || []).forEach(c => s.add(c)));
|
||||
return Array.from(s).slice(0, 8);
|
||||
}
|
||||
function allTags() {
|
||||
const freq = new Map();
|
||||
POSTS.forEach(p => (p.tags || []).forEach(t => freq.set(t, (freq.get(t)||0)+1)));
|
||||
return Array.from(freq.entries()).sort((a,b)=>b[1]-a[1]).slice(0,10).map(([t])=>t);
|
||||
}
|
||||
|
||||
function renderSearchPop(q) {
|
||||
if (!searchPop) return;
|
||||
if (!q) {
|
||||
const cats = allCats();
|
||||
const tags = allTags();
|
||||
searchPop.innerHTML = `
|
||||
<div class="searchpop__section">
|
||||
<div class="searchpop__label">Categories <small>${cats.length}</small></div>
|
||||
<div class="searchpop__chips">
|
||||
${cats.map(c => `<button class="searchpop__chip" data-jump="/categories/${encodeURIComponent(c.toLowerCase().replace(/[\s,]+/g,'-').replace(/[^a-z0-9-]/g,''))}/"> ${esc(c)}</button>`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
<div class="searchpop__section">
|
||||
<div class="searchpop__label">Popular tags <small>${tags.length}</small></div>
|
||||
<div class="searchpop__chips">
|
||||
${tags.map(t => `<button class="searchpop__chip" data-jump="/tags/${encodeURIComponent(t.toLowerCase().replace(/[\s,]+/g,'-').replace(/[^a-z0-9-]/g,''))}/"> # ${esc(t)}</button>`).join('')}
|
||||
</div>
|
||||
</div>`;
|
||||
searchPop.dataset.open = 'true';
|
||||
return;
|
||||
}
|
||||
const hits = INDEX(q) || [];
|
||||
const terms = q.toLowerCase().split(/\s+/).filter(t => t.length > 1);
|
||||
if (!hits.length) {
|
||||
searchPop.innerHTML = `<div class="searchpop__section"><p style="color:var(--ink-soft);font-size:13px;font-style:italic">No plates match — try <em>gothic</em>, <em>warrior</em>, or <em>neon</em>.</p></div>`;
|
||||
searchPop.dataset.open = 'true';
|
||||
return;
|
||||
}
|
||||
const shown = hits.slice(0, 6);
|
||||
searchPop.innerHTML = `
|
||||
<div class="searchpop__section">
|
||||
<div class="searchpop__label">Plates <small>${hits.length}</small></div>
|
||||
<div class="searchpop__hits">
|
||||
${shown.map(p => `
|
||||
<button class="searchpop__hit" data-jump="${esc(p.url)}">
|
||||
${p.thumb ? `<img src="${esc(p.thumb)}" alt="" loading="lazy" />` : '<div style="width:44px;height:66px;background:var(--paper-2)"></div>'}
|
||||
<div>
|
||||
<div class="t">${highlight(p.title, terms)}</div>
|
||||
<div class="s">${highlight((p.categories||[]).join(', '), terms)}</div>
|
||||
</div>
|
||||
<div class="n">${esc(p.id)}</div>
|
||||
</button>`).join('')}
|
||||
</div>
|
||||
</div>`;
|
||||
searchPop.dataset.open = 'true';
|
||||
}
|
||||
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', () => renderSearchPop(searchInput.value.trim()));
|
||||
searchInput.addEventListener('focus', () => renderSearchPop(searchInput.value.trim()));
|
||||
document.addEventListener('keydown', e => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'k') { e.preventDefault(); searchInput.focus(); renderSearchPop(''); }
|
||||
if (e.key === 'Escape') closeSearch();
|
||||
});
|
||||
}
|
||||
|
||||
if (searchPop) {
|
||||
searchPop.addEventListener('click', e => {
|
||||
const btn = e.target.closest('[data-jump]');
|
||||
if (btn) { closeSearch(); navigate(btn.dataset.jump); }
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', e => {
|
||||
if (searchPop && searchPop.dataset.open === 'true' && !e.target.closest('.subhead')) closeSearch();
|
||||
});
|
||||
|
||||
function closeSearch() {
|
||||
if (searchPop) { searchPop.dataset.open = 'false'; searchPop.innerHTML = ''; }
|
||||
if (searchInput) searchInput.blur();
|
||||
}
|
||||
|
||||
// ── Lightbox
|
||||
const lb = document.getElementById('lb');
|
||||
const lbTrack = document.getElementById('lbTrack');
|
||||
const lbMeta = document.getElementById('lbMeta');
|
||||
const lbThumbs = document.getElementById('lbThumbs');
|
||||
const lbIndex = document.getElementById('lbIndex');
|
||||
|
||||
let lbList = []; // current scoped post list
|
||||
let lbIdx = -1; // index into lbList
|
||||
let lbBuilt = false;
|
||||
|
||||
function lbOpen(slug, scopedList) {
|
||||
lbList = scopedList || POSTS;
|
||||
const idx = lbList.findIndex(p => p.slug === slug);
|
||||
if (idx === -1) return;
|
||||
lbIdx = idx;
|
||||
if (!lbBuilt) buildLbSlides();
|
||||
lb.dataset.open = 'true';
|
||||
document.body.style.overflow = 'hidden';
|
||||
goToSlide(lbIdx, false);
|
||||
lbBuildMeta(lbList[lbIdx]);
|
||||
lbBuildThumbs();
|
||||
}
|
||||
|
||||
function lbClose() {
|
||||
if (!lb) return;
|
||||
lb.dataset.open = 'false';
|
||||
document.body.style.overflow = '';
|
||||
// pop back to gallery if we're on a single-post URL
|
||||
if (window.__ROUX_OPEN_SLUG) {
|
||||
navigate('/');
|
||||
}
|
||||
}
|
||||
|
||||
function buildLbSlides() {
|
||||
if (!lbTrack) return;
|
||||
lbTrack.innerHTML = lbList.map((p, i) => {
|
||||
const imgSrc = p.card || p.thumb || '';
|
||||
return `<div class="lb__slide" data-i="${i}">
|
||||
<div class="lb__frame">
|
||||
<img class="lb__img" src="${esc(imgSrc)}" alt="${esc(p.title)}" loading="lazy" />
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
lbBuilt = true;
|
||||
// Preload neighbors
|
||||
preloadNeighbors(lbIdx);
|
||||
}
|
||||
|
||||
function goToSlide(idx, smooth = true) {
|
||||
if (!lbTrack) return;
|
||||
lbIdx = Math.max(0, Math.min(idx, lbList.length - 1));
|
||||
lbTrack.style.transition = smooth ? '' : 'none';
|
||||
lbTrack.style.transform = `translateX(-${lbIdx * 100}%)`;
|
||||
if (!smooth) lbTrack.getBoundingClientRect(); // force reflow
|
||||
if (lbIndex) {
|
||||
lbIndex.innerHTML = `<b>${String(lbIdx + 1).padStart(3,'0')}</b> / ${lbList.length}`;
|
||||
}
|
||||
lbBuildMeta(lbList[lbIdx]);
|
||||
syncThumbs();
|
||||
preloadNeighbors(lbIdx);
|
||||
}
|
||||
|
||||
function preloadNeighbors(idx) {
|
||||
if (!lbTrack) return;
|
||||
[-1, 0, 1, 2].forEach(d => {
|
||||
const ni = idx + d;
|
||||
if (ni < 0 || ni >= lbList.length) return;
|
||||
const slide = lbTrack.querySelector(`.lb__slide[data-i="${ni}"]`);
|
||||
if (!slide) return;
|
||||
const img = slide.querySelector('img');
|
||||
if (img && !img.src) img.src = lbList[ni].card || lbList[ni].thumb || '';
|
||||
});
|
||||
}
|
||||
|
||||
function lbBuildMeta(p) {
|
||||
if (!lbMeta || !p) return;
|
||||
const cats = (p.categories || []).join(', ');
|
||||
const tags = (p.tags || []).slice(0, 8);
|
||||
lbMeta.innerHTML = `
|
||||
<div class="lb__cat">${esc(cats)}</div>
|
||||
<h2 class="lb__title">${esc(p.title)}</h2>
|
||||
<p class="lb__desc">${esc(p.description)}</p>
|
||||
<dl class="lb__factgrid">
|
||||
<div class="lb__fact"><dt>Plate</dt><dd>№ ${esc(p.id)}</dd></div>
|
||||
<div class="lb__fact"><dt>Category</dt><dd>${esc((p.categories||['—'])[0])}</dd></div>
|
||||
</dl>
|
||||
<div class="lb__tags">${tags.map(t => `<span class="lb__tag">${esc(t)}</span>`).join('')}</div>
|
||||
<div class="lb__share">
|
||||
<button class="lb__sh lb__sh--primary" id="lbCopy" data-url="${esc(p.url)}">
|
||||
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 1 0-7.07-7.07l-1 1"/><path d="M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 1 0 7.07 7.07l1-1"/></svg>
|
||||
<span class="lb__sh-l">Copy link</span>
|
||||
</button>
|
||||
</div>`;
|
||||
|
||||
document.getElementById('lbCopy')?.addEventListener('click', function () {
|
||||
const url = new URL(this.dataset.url, location.origin).href;
|
||||
navigator.clipboard.writeText(url).then(() => {
|
||||
this.classList.add('is-ok');
|
||||
this.querySelector('.lb__sh-l').textContent = 'Copied!';
|
||||
setTimeout(() => { this.classList.remove('is-ok'); this.querySelector('.lb__sh-l').textContent = 'Copy link'; }, 2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function lbBuildThumbs() {
|
||||
if (!lbThumbs) return;
|
||||
lbThumbs.innerHTML = lbList.map((p, i) =>
|
||||
`<button class="lb__thumb" data-i="${i}" aria-current="${i === lbIdx}" aria-label="${esc(p.title)}">
|
||||
<img src="${esc(p.thumb || p.card || '')}" alt="" loading="lazy" />
|
||||
</button>`
|
||||
).join('');
|
||||
lbThumbs.addEventListener('click', e => {
|
||||
const btn = e.target.closest('.lb__thumb');
|
||||
if (btn) goToSlide(parseInt(btn.dataset.i));
|
||||
});
|
||||
}
|
||||
|
||||
function syncThumbs() {
|
||||
if (!lbThumbs) return;
|
||||
lbThumbs.querySelectorAll('.lb__thumb').forEach((b, i) => {
|
||||
b.setAttribute('aria-current', i === lbIdx ? 'true' : 'false');
|
||||
});
|
||||
const active = lbThumbs.querySelector('.lb__thumb[aria-current="true"]');
|
||||
if (active) active.scrollIntoView({ inline: 'center', behavior: 'smooth' });
|
||||
}
|
||||
|
||||
// Lightbox controls
|
||||
if (lb) {
|
||||
lb.addEventListener('click', e => {
|
||||
const act = e.target.closest('[data-act]')?.dataset.act;
|
||||
if (act === 'close') lbClose();
|
||||
else if (act === 'prev') goToSlide(lbIdx - 1);
|
||||
else if (act === 'next') goToSlide(lbIdx + 1);
|
||||
});
|
||||
document.addEventListener('keydown', e => {
|
||||
if (lb.dataset.open !== 'true') return;
|
||||
if (e.key === 'Escape') { lbClose(); }
|
||||
if (e.key === 'ArrowLeft') { e.preventDefault(); goToSlide(lbIdx - 1); }
|
||||
if (e.key === 'ArrowRight') { e.preventDefault(); goToSlide(lbIdx + 1); }
|
||||
});
|
||||
|
||||
// Touch swipe
|
||||
let touchX = null;
|
||||
lb.addEventListener('touchstart', e => { touchX = e.touches[0].clientX; }, { passive: true });
|
||||
lb.addEventListener('touchend', e => {
|
||||
if (touchX === null) return;
|
||||
const dx = e.changedTouches[0].clientX - touchX;
|
||||
if (Math.abs(dx) > 50) { dx < 0 ? goToSlide(lbIdx + 1) : goToSlide(lbIdx - 1); }
|
||||
touchX = null;
|
||||
});
|
||||
}
|
||||
|
||||
// ── Card clicks → open lightbox (no full page navigation for same-origin)
|
||||
document.addEventListener('click', e => {
|
||||
const card = e.target.closest('.card[data-slug]');
|
||||
if (!card) return;
|
||||
e.preventDefault();
|
||||
const slug = card.dataset.slug;
|
||||
const visibleSlugs = Array.from(document.querySelectorAll('.card[data-slug]')).map(c => c.dataset.slug);
|
||||
const scopedList = POSTS.filter(p => visibleSlugs.includes(p.slug));
|
||||
// Update URL without page reload
|
||||
history.pushState({ slug }, '', card.href);
|
||||
lbOpen(slug, scopedList.length ? scopedList : POSTS);
|
||||
});
|
||||
|
||||
// Handle browser back/forward
|
||||
window.addEventListener('popstate', e => {
|
||||
if (lb && lb.dataset.open === 'true') {
|
||||
if (!e.state?.slug) { lb.dataset.open = 'false'; document.body.style.overflow = ''; }
|
||||
}
|
||||
});
|
||||
|
||||
// ── Ribbon
|
||||
const ribbon = document.getElementById('ribbon');
|
||||
const ribbonClose = document.getElementById('ribbonClose');
|
||||
if (ribbonClose && ribbon) {
|
||||
if (sessionStorage.getItem('ribbon-closed')) ribbon.classList.add('hidden');
|
||||
ribbonClose.addEventListener('click', () => {
|
||||
ribbon.classList.add('hidden');
|
||||
sessionStorage.setItem('ribbon-closed', '1');
|
||||
});
|
||||
}
|
||||
|
||||
// ── Async page transitions (View Transitions API)
|
||||
function isSameOrigin(url) {
|
||||
try { return new URL(url).origin === location.origin; } catch { return false; }
|
||||
}
|
||||
|
||||
async function navigate(url) {
|
||||
if (!isSameOrigin(url)) { location.href = url; return; }
|
||||
|
||||
if (!document.startViewTransition) {
|
||||
location.href = url;
|
||||
return;
|
||||
}
|
||||
|
||||
document.startViewTransition(async () => {
|
||||
const res = await fetch(url, { headers: { 'X-Requested-With': 'fetch' } });
|
||||
const text = await res.text();
|
||||
const doc = new DOMParser().parseFromString(text, 'text/html');
|
||||
|
||||
const newContent = doc.getElementById('content');
|
||||
const newData = doc.getElementById('roux-data');
|
||||
const oldContent = document.getElementById('content');
|
||||
|
||||
if (newContent && oldContent) {
|
||||
oldContent.replaceWith(newContent);
|
||||
}
|
||||
if (newData) {
|
||||
try {
|
||||
POSTS = JSON.parse(newData.textContent) || [];
|
||||
lbBuilt = false; // force rebuild on next open
|
||||
} catch {}
|
||||
}
|
||||
|
||||
document.title = doc.title;
|
||||
history.pushState({}, '', url);
|
||||
|
||||
// Re-init page state
|
||||
setCount(POSTS.length);
|
||||
syncTabs();
|
||||
|
||||
// If new page has a slug to open
|
||||
const script = doc.querySelector('script[data-open-slug]');
|
||||
const openSlug = window.__ROUX_OPEN_SLUG = doc.querySelector('[data-open-slug]')?.dataset.openSlug || null;
|
||||
if (openSlug) {
|
||||
const visibleSlugs = Array.from(document.querySelectorAll('.card[data-slug]')).map(c => c.dataset.slug);
|
||||
const scoped = POSTS.filter(p => visibleSlugs.includes(p.slug));
|
||||
lbOpen(openSlug, scoped.length ? scoped : POSTS);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Intercept link clicks for async transitions
|
||||
document.addEventListener('click', e => {
|
||||
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
||||
const a = e.target.closest('a[href]');
|
||||
if (!a || a.target || a.hasAttribute('download')) return;
|
||||
if (!isSameOrigin(a.href)) return;
|
||||
// Skip lightbox card clicks (handled above)
|
||||
if (a.closest('.card[data-slug]')) return;
|
||||
// Skip anchor links
|
||||
if (a.href.includes('#')) return;
|
||||
e.preventDefault();
|
||||
navigate(a.href);
|
||||
});
|
||||
|
||||
// ── On single-post pages: auto-open lightbox
|
||||
if (window.__ROUX_OPEN_SLUG && POSTS.length) {
|
||||
const visibleSlugs = Array.from(document.querySelectorAll('.card[data-slug]')).map(c => c.dataset.slug);
|
||||
const scoped = POSTS.filter(p => visibleSlugs.includes(p.slug));
|
||||
lbOpen(window.__ROUX_OPEN_SLUG, scoped.length ? scoped : POSTS);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user