From 0cb1ce1f150a8361e6479843c9b0701701871baf Mon Sep 17 00:00:00 2001 From: "E.Gavrilov" Date: Mon, 26 Oct 2026 20:09:03 +0300 Subject: [PATCH] Preserve historical publication days across build timezones --- web/app/Catalog.jsx | 3 ++- web/lib/articles.js | 2 +- web/lib/dates.mjs | 5 +++++ web/package.json | 5 +++-- web/public/build-identity.json | 2 +- web/scripts/check-dates.mjs | 25 +++++++++++++++++++++++++ 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 web/lib/dates.mjs create mode 100644 web/scripts/check-dates.mjs diff --git a/web/app/Catalog.jsx b/web/app/Catalog.jsx index 9ae827d..79d9978 100644 --- a/web/app/Catalog.jsx +++ b/web/app/Catalog.jsx @@ -1,4 +1,5 @@ "use client"; import {useState,useEffect} from 'react'; import Link from 'next/link'; -export default function Catalog({articles}){const [q,setQ]=useState(''),[topic,setTopic]=useState('Все');const topics=['Все',...new Set(articles.flatMap(a=>a.categories))];const shown=articles.filter(a=>(topic==='Все'||a.categories.includes(topic))&&(a.title+' '+a.excerpt+' '+a.categories.join(' ')).toLocaleLowerCase('ru').includes(q.toLocaleLowerCase('ru')));return

ПОЛНЫЙ ИНДЕКС

Статьи и заметки

{articles.length} материалов
{topics.map(t=>)}

{shown.length?`Найдено материалов: ${shown.length}`:'По этому запросу ничего нет. Попробуйте другое слово или сбросьте тему.'}

{shown.map(a=>
{a.categories.join(' · ')}

{a.title}

{a.excerpt}

{a.readingMinutes} мин
)}
{!shown.length&&}
} +import {formatDate} from '../lib/dates.mjs'; +export default function Catalog({articles}){const [q,setQ]=useState(''),[topic,setTopic]=useState('Все');const topics=['Все',...new Set(articles.flatMap(a=>a.categories))];const shown=articles.filter(a=>(topic==='Все'||a.categories.includes(topic))&&(a.title+' '+a.excerpt+' '+a.categories.join(' ')).toLocaleLowerCase('ru').includes(q.toLocaleLowerCase('ru')));return

ПОЛНЫЙ ИНДЕКС

Статьи и заметки

{articles.length} материалов
{topics.map(t=>)}

{shown.length?`Найдено материалов: ${shown.length}`:'По этому запросу ничего нет. Попробуйте другое слово или сбросьте тему.'}

{shown.map(a=>
{a.categories.join(' · ')}

{a.title}

{a.excerpt}

{a.readingMinutes} мин
)}
{!shown.length&&}
} diff --git a/web/lib/articles.js b/web/lib/articles.js index 3b59d3a..b53ab73 100644 --- a/web/lib/articles.js +++ b/web/lib/articles.js @@ -1,6 +1,6 @@ import articles from '../data/articles.json'; export function getArticles() { return articles; } export function getArticleBySlug(slug) { return articles.find(a => a.slug === slug); } -export function formatDate(date) { return new Intl.DateTimeFormat('ru-RU', {day:'2-digit',month:'long',year:'numeric'}).format(new Date(date)); } +export {formatDate} from './dates.mjs'; export function getArticleSummaries(){return articles.map(({slug,title,date,excerpt,categories,readingMinutes})=>({slug,title,date,excerpt,categories,readingMinutes}));} diff --git a/web/lib/dates.mjs b/web/lib/dates.mjs new file mode 100644 index 0000000..6db1e02 --- /dev/null +++ b/web/lib/dates.mjs @@ -0,0 +1,5 @@ +// Archived publication timestamps are UTC; their UTC calendar days match the +// visible source dates and dated permalinks. Never use the build/browser timezone. +export function formatDate(date, {day = '2-digit', month = 'long'} = {}) { + return new Intl.DateTimeFormat('ru-RU', {day, month, year: 'numeric', timeZone: 'UTC'}).format(new Date(date)); +} diff --git a/web/package.json b/web/package.json index dbaf5e7..7e83df0 100644 --- a/web/package.json +++ b/web/package.json @@ -5,11 +5,12 @@ "scripts": { "dev": "next dev", "admin:posts": "node ../local-admin/posts-admin.mjs", - "build": "node scripts/prepare-publication.mjs && next build", + "build": "node scripts/check-dates.mjs && node scripts/prepare-publication.mjs && next build", "audit:articles": "node scripts/audit-quality-batch.mjs", "audit:draft": "node scripts/audit-editorial-draft.mjs", "start": "next start", - "check:publication": "node scripts/prepare-publication.mjs" + "check:publication": "node scripts/prepare-publication.mjs", + "check:dates": "node scripts/check-dates.mjs" }, "dependencies": { "next": "^16.0.0", diff --git a/web/public/build-identity.json b/web/public/build-identity.json index c3e0cdd..0ef49ac 100644 --- a/web/public/build-identity.json +++ b/web/public/build-identity.json @@ -1,4 +1,4 @@ { - "sourceHash": "656da6da3e89c1b5c48d320b192838f3e6e897b31d78a0a420fc99786d9ac31f", + "sourceHash": "f4aa72d3c1fed6b79fbf0cdc0ebc815313b48272d905369e8d0ae5c91771a6e5", "articles": 14 } diff --git a/web/scripts/check-dates.mjs b/web/scripts/check-dates.mjs new file mode 100644 index 0000000..a54b3d3 --- /dev/null +++ b/web/scripts/check-dates.mjs @@ -0,0 +1,25 @@ +import assert from 'node:assert/strict'; +import {execFileSync} from 'node:child_process'; +import {fileURLToPath} from 'node:url'; +import {formatDate} from '../lib/dates.mjs'; + +// Source