feat(rss): лента готова к Дзену — лимит 20, PNG-обложки covergen в палитре dedinit-dark
deploy-dedinit / Build & SFTP Deploy (push) Successful in 12m53s
wiki-sync / Publish docs/wiki to Gitea wiki (push) Successful in 21s

- tools/covergen из ветки covergen-tooling + флаг --palette auto|dedinit-dark (цвета theme-vars/hero.svg)
- scripts/gen-covers.mjs: SVG в static/covers (в git), PNG — артефакт сборки (gitignore), --png/--force/--only
- rss.xml: <enclosure> с covers/<slug>.png при fileExists, <language>ru</language>, описание канала по-русски
- hugo.toml: limit 5 → 20, enableRobotsTXT
- deploy.yml: nodejs + librsvg2-bin, шаг генерации обложек перед hugo
- docs: DZEN_RSS (итог), covergen (палитра, SVG/PNG, питфолл snap-chromium), вики reference-covers/reference-rss-dzen
- openspec change dzen-rss-compliance
This commit is contained in:
2026-11-14 14:07:41 +00:00
parent 6276d06ea2
commit 4cb6323e4c
224 changed files with 4019 additions and 22 deletions
+54
View File
@@ -0,0 +1,54 @@
'use strict';
const { paletteFor, paletteByName, hash } = require('./palette');
const { STYLES } = require('./styles');
const STYLE_NAMES = Object.keys(STYLES);
/**
* @param {{title:string, subtitle?:string, author?:string, tags?:string[], slug?:string,
* style?:string, width?:number, height?:number, background?:string}} input
* @returns {string} SVG-документ
*/
function render(input) {
const title = String(input.title ?? '').trim();
if (!title) throw new Error('title is required');
const seed = String(input.slug || title).toLowerCase();
const styleName = input.style && input.style !== 'auto'
? input.style
: STYLE_NAMES[hash(seed) % STYLE_NAMES.length];
const style = STYLES[styleName];
if (!style) {
throw new Error(`unknown style "${styleName}", available: ${STYLE_NAMES.join(', ')}`);
}
const width = Math.max(320, Math.min(4000, Number(input.width) || 1200));
const height = Math.max(320, Math.min(4000, Number(input.height) || 630));
const tags = Array.isArray(input.tags)
? input.tags.map((tag) => String(tag).trim()).filter(Boolean)
: String(input.tags ?? '').split(',').map((tag) => tag.trim()).filter(Boolean);
const body = style({
width,
height,
title,
subtitle: input.subtitle ?? '',
author: input.author ?? '',
tags,
palette: paletteByName(input.palette) ?? paletteFor(seed),
uid: (hash(seed) % 99991).toString(36),
});
return `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${escapeAttr(title)}">
${body}
</svg>
`;
}
function escapeAttr(value) {
return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
}
module.exports = { render, STYLE_NAMES };