diff --git a/assets/js/custom.js b/assets/js/custom.js index a0e5eca4..f5371815 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -92,6 +92,22 @@ }); } + // Reduced-motion quick toggle (header ✦ button) + var mqBtn = document.getElementById('neo-motion-quick'); + var mqState = localStorage.getItem('neo-motion-state'); + function mqApply(on) { + document.documentElement.setAttribute('data-reduce-motion', on ? 'false' : 'true'); + if (mqBtn) mqBtn.style.opacity = on ? '' : '.5'; + localStorage.setItem('neo-motion-state', on ? 'on' : 'off'); + } + if (mqBtn) { + if (mqState === 'off') mqApply(false); + mqBtn.addEventListener('click', function () { + var cur = document.documentElement.getAttribute('data-reduce-motion') === 'true'; + mqApply(!cur); + }); + } + // Quick light/dark toggle var tog = document.getElementById('neo-theme-toggle'); if (tog){ diff --git a/content/favorites/_index.md b/content/favorites/_index.md new file mode 100644 index 00000000..51368d20 --- /dev/null +++ b/content/favorites/_index.md @@ -0,0 +1,10 @@ +--- +title: "Избранное" +description: "Сохранённые карточки (лайки). Хранится локально в браузере." +layout: "favorites-hub" +--- + +Здесь собраны репозитории, гисты и awesome-списки, которые вы отметили лайком (♥) на сайте. Вся информация хранится локально в вашем браузере и не отправляется на сервер. + +- Нажмите ♥ на любой карточке, чтобы добавить её сюда. +- Нажмите ♥ ещё раз, чтобы убрать. diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 00000000..f36f0494 --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,16 @@ +{{/* Image render hook: lazy-load + CLS guard. + Local Hugo image resources get intrinsic width/height (no layout shift). + Remote images get loading="lazy" decoding="async". */}} +{{- $src := .Destination -}} +{{- $alt := .Text -}} +{{- $isRemote := or (strings.HasPrefix $src "http://") (strings.HasPrefix $src "https://") -}} +{{- if and (not $isRemote) (not (strings.HasPrefix $src "/")) -}} + {{- $img := $.Page.Resources.Get $src -}} + {{- if $img -}} +{{ $alt | safeHTMLAttr }} +{{- else -}} +{{ $alt | safeHTMLAttr }} +{{- end -}} +{{- else -}} +{{ $alt | safeHTMLAttr }} +{{- end -}} diff --git a/layouts/awesome/list.html b/layouts/awesome/list.html index 72c9f0ef..3da34b7e 100644 --- a/layouts/awesome/list.html +++ b/layouts/awesome/list.html @@ -27,7 +27,7 @@

{{ .name }}

{{ range .repos }} {{ $repo := . }} {{ $p := $.Site.GetPage (printf "/awesome/%s/%s" $repo.group $repo.name) }} -
+
diff --git a/layouts/favorites/list.html b/layouts/favorites/list.html new file mode 100644 index 00000000..d4f1810b --- /dev/null +++ b/layouts/favorites/list.html @@ -0,0 +1,49 @@ +{{/* Favorites hub — Neo design system (standalone). Client-rendered from localStorage. + Title/type/href come from our own like-meta store; textContent is used to avoid HTML injection. */}} + + +{{ partial "neo-head.html" . }} + +{{ partial "neo-header.html" . }} +
+
+

{{ .Title }}

+ {{ .Content }} +
+

Пока пусто. Нажмите ♥ на любой карточке, чтобы добавить её в избранное.

+
+
+{{ partial "neo-footer.html" . }} + + + diff --git a/layouts/gists/list.html b/layouts/gists/list.html index e371e922..62d52273 100644 --- a/layouts/gists/list.html +++ b/layouts/gists/list.html @@ -12,7 +12,7 @@

{{ .Title }}

{{ .Content }}
{{ range .RegularPages.ByTitle }} - + diff --git a/layouts/partials/neo-card-features.html b/layouts/partials/neo-card-features.html index 9e25ceea..488e588e 100644 --- a/layouts/partials/neo-card-features.html +++ b/layouts/partials/neo-card-features.html @@ -25,13 +25,26 @@ if (num) num.textContent = String(b + (liked ? 1 : 0)); } + var META_STORE = "neo-fav-meta"; + try { var meta = JSON.parse(localStorage.getItem(META_STORE) || "{}"); } catch (e) { var meta = {}; } + function saveMeta() { try { localStorage.setItem(META_STORE, JSON.stringify(meta)); } catch (e) {} } + function toggle(btn) { var key = btn.getAttribute("data-like-key") || ""; likes[key] = !likes[key]; save(); + if (likes[key]) { + var card = btn.closest("[data-type]"); + meta[key] = { + title: (card && card.getAttribute("data-title")) || document.title, + type: (card && card.getAttribute("data-type")) || "post", + href: (card && card.getAttribute("href")) || location.pathname + }; + } else { delete meta[key]; } + saveMeta(); render(btn); btn.classList.remove("pop", "spark"); - void btn.offsetWidth; // restart animation + void btn.offsetWidth; btn.classList.add("pop", "spark"); } diff --git a/layouts/partials/neo-header.html b/layouts/partials/neo-header.html index 3e03dd64..d3cad0f0 100644 --- a/layouts/partials/neo-header.html +++ b/layouts/partials/neo-header.html @@ -25,11 +25,13 @@ Теги sitemap Ленты + Избранное
+