mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 05:41:31 +00:00
perf: avoid the layout shift for post datetime
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* A tool for locale datetime
|
||||
*/
|
||||
|
||||
const LocaleHelper = (function () {
|
||||
const $preferLocale = $('meta[name="prefer-datetime-locale"]');
|
||||
const locale = $preferLocale.length > 0 ?
|
||||
$preferLocale.attr('content').toLowerCase() : $('html').attr('lang').substr(0, 2);
|
||||
const attrTimestamp = 'data-ts';
|
||||
const attrDateFormat = 'data-df';
|
||||
|
||||
return {
|
||||
locale: () => locale,
|
||||
attrTimestamp: () => attrTimestamp,
|
||||
attrDateFormat: () => attrDateFormat,
|
||||
getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp
|
||||
getDateFormat: ($elem) => $elem.attr(attrDateFormat)
|
||||
};
|
||||
}());
|
||||
Reference in New Issue
Block a user