Skip to content

Commit

Permalink
refactor: remove site config option prefer_datetime_locale
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Oct 18, 2022
1 parent f904e8c commit 6852ceb
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 23 deletions.
2 changes: 0 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ baseurl: ''
# otherwise, the layout language will use the default value of 'en'.
lang: en

# Additional parameters for datetime localization, optional. › https://github.com/iamkun/dayjs/tree/dev/src/locale
prefer_datetime_locale:

# Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone
timezone: Asia/Shanghai
Expand Down
5 changes: 0 additions & 5 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Allow having a localized datetime different from the appearance language -->
{% if site.prefer_datetime_locale %}
<meta name="prefer-datetime-locale" content="{{ site.prefer_datetime_locale }}">
{% endif %}

{% if page.layout == 'home' or page.layout == 'post' %}

{% if site.google_analytics.pv.proxy_endpoint %}
Expand Down
6 changes: 1 addition & 5 deletions _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
or page.layout == 'category'
or page.layout == 'tag' %}

{% if site.prefer_datetime_locale %}
{% assign locale = site.prefer_datetime_locale | downcase %}
{% else %}
{% assign locale = site.lang | split: '-' | first %}
{% endif %}
{% assign locale = site.lang | split: '-' | first %}

{% assign _urls = site.data.assets[origin].dayjs.js.common
| append: ',' | append: site.data.assets[origin].dayjs.js.locale
Expand Down
4 changes: 1 addition & 3 deletions _javascript/utils/locale-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

/* 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 locale = $('html').attr('lang').substr(0, 2)
const attrTimestamp = 'data-ts';
const attrDateFormat = 'data-df';

Expand Down
3 changes: 2 additions & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
{% endif %}
{% endcapture %}

<html lang="{{ site.lang }}"{{ prefer_mode }}>
<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ site.alt_lang | default: site.lang }}"{{ prefer_mode }}>

{% include head.html %}

Expand Down
2 changes: 1 addition & 1 deletion assets/js/dist/categories.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/dist/commons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6852ceb

Please sign in to comment.