Preserve historical publication days across build timezones
Build and deploy / deploy (push) Successful in 5m24s
Build and deploy / deploy (push) Successful in 5m24s
This commit is contained in:
1 parent
2d5a687fda
commit
0cb1ce1f15
6 files changed
+37
-5
No files matched your search
+1
-1
@@ -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}));}
|
||||
@@ -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));
|
||||
}
|
||||
Reference in new issue
Block a user