feat: 'updated_option' config

- post.updated will be null if not set in front-matter
- https://github.com/hexojs/hexo/pull/4278
This commit is contained in:
MDLeom 2020-06-23 05:27:55 +01:00
parent 0752e3382c
commit d0ac052b59
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
31 changed files with 34 additions and 35 deletions

View File

@ -9,7 +9,7 @@
- Installed [hexo-nofollow](https://github.com/curbengh/hexo-nofollow) for SEO purpose to prevent search engines from following external links.
- Installed [hexo-yam](https://github.com/curbengh/hexo-yam) to pre-compress static assets (html, css, js and svg).
- [copy-button.js](/scripts/copy-button.js) - A [filter](https://hexo.io/api/filter) plugin to add a copy button to each code block.
- [feed](/scripts/feed) - A generator plugin to generate [an RSS feed](https://en.wikipedia.org/wiki/Web_feed). Modified from [hexo-generator-feed](https://github.com/hexojs/hexo-generator-feed) to use `post.lastUpdated` instead of `post.updated`.
- [feed](/scripts/feed) - A generator plugin to generate [an RSS feed](https://en.wikipedia.org/wiki/Web_feed). Modified from [hexo-generator-feed](https://github.com/hexojs/hexo-generator-feed) to use `post.updated` instead of `post.updated`.
- [heading-link.js](/scripts/heading-link.js) - A filter plugin to add a link button next to each heading.
- [image.js](/scripts/image.js) - A [tag](https://hexo.io/api/tag) plugin to easily embed images in a post with responsive image support.
- [link.js](/scripts/link.js) - A [helper](https://hexo.io/api/helper) plugin to add a link. Modified from [link_to.js](https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/link_to.js) to remove title attribute and 'external' option.
@ -25,6 +25,7 @@ The following are the major changes I made compared to the upstream.
- Removed unused packages, [hexo-generator-category](https://github.com/hexojs/hexo-generator-category) and [hexo-renderer-stylus](https://github.com/hexojs/hexo-renderer-stylus) from the [default packages](https://github.com/hexojs/hexo-starter/blob/571320ba41a83e065d7560e050eb3fa63ad74a57/package.json#L9-L17).
- Replaced the bundled Landscape theme with Typing theme.
- Add `lastUpdated` to the front-matter to manually set updated time of a post, instead of using `post.updated`.
* This is no longer necessary, thanks to [`updated_option`](https://github.com/hexojs/hexo/pull/4278) feature.
### [Chameleon theme](/themes/chameleon)
Chameleon is a fork of [Typing](https://github.com/geekplux/hexo-theme-typing) theme, rewrote from scratch with the following changes/features:

View File

@ -63,6 +63,7 @@ tag_map:
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
updated_option: empty
# Pagination
## Set per_page to 0 to disable pagination

View File

@ -2,7 +2,7 @@
title: Firefox, Cross-Origin and AliExpress
excerpt: AliExpress login doesn't show up on Firefox when there is a strict cross-origin policy.
date: 2019-02-28
lastUpdated: 2019-04-29
updated: 2019-04-29
tags:
- firefox
---

View File

@ -2,7 +2,7 @@
title: "Setup Caddy as a reverse proxy on NixOS (Part 1: Installation)"
excerpt: "Part 1: Installing NixOS"
date: 2020-02-23
lastUpdated: 2020-04-22
updated: 2020-04-22
tags:
- server
- linux

View File

@ -2,7 +2,7 @@
title: "Setup Caddy as a reverse proxy on NixOS (Part 2: Hardening)"
excerpt: "Part 2: Securing NixOS"
date: 2020-03-04
lastUpdated: 2020-04-22
updated: 2020-04-22
tags:
- server
- linux

View File

@ -2,7 +2,7 @@
title: "Setup Caddy as a reverse proxy on NixOS (Part 3: Caddy)"
excerpt: "Part 3: Configure Caddy"
date: 2020-03-14
lastUpdated: 2020-04-08
updated: 2020-04-08
tags:
- server
- linux

View File

@ -2,7 +2,7 @@
title: Upgrading Caddy reverse proxy from v1 to v2 syntax
excerpt: route, strip_prefix, rewrite
date: 2020-05-23
lastUpdated: 2020-06-21
updated: 2020-06-21
tags:
- server
- caddy

View File

@ -2,7 +2,7 @@
title: Edit multiple questions on LimeSurvey
excerpt: List Questions view allows you to edit multiple questions at the same time.
date: 2018-10-18
lastUpdated: 2018-10-26
updated: 2018-10-26
tags:
- stats
- limesurvey

View File

@ -2,7 +2,7 @@
title: Access Facebook/Instagram/Whatsapp/Google in China
excerpt: Data roaming, commercial VPN provider to rolling your own VPN.
date: 2018-12-31
lastUpdated: 2019-10-23
updated: 2019-10-23
tags:
- censorship
---

View File

@ -2,7 +2,7 @@
title: Firefox Multi-Account Containers
excerpt: Separate website cookies in a single session
date: 2019-08-12
lastUpdated: 2019-08-27
updated: 2019-08-27
tags:
- firefox
- privacy

View File

@ -2,7 +2,7 @@
title: How to run more than one Firefox instance
excerpt: Using Firefox profiles, you can use more than two instances.
date: 2019-04-07
lastUpdated: 2019-08-09
updated: 2019-08-09
tags:
- firefox
- privacy

View File

@ -2,7 +2,7 @@
title: Using Git and Git+SSH in GitLab CI
excerpt: Guides and potential pitfalls
date: 2019-10-03
lastUpdated: 2020-04-18
updated: 2020-04-18
tags:
- gitlab
---

View File

@ -2,7 +2,7 @@
title: GNU vs BusyBox Unix tools
excerpt: Alpine uses BusyBox while Ubuntu uses GNU tools, and they behave differently.
date: 2018-10-13
lastUpdated: 2018-10-31
updated: 2018-10-31
tags:
- linux
- alpine

View File

@ -2,7 +2,7 @@
title: How to create a Hexo blog on GitLab Pages
excerpt: Create a website/blog using Hexo on GitLab Pages for free using this detailed guide.
date: 2018-09-21
lastUpdated: 2018-11-10
updated: 2018-11-10
tags:
- hexo
- gitlab

View File

@ -2,7 +2,7 @@
title: How to remove Windows 10 default apps
excerpt: How to get rid of these bloatware.
date: 2018-09-26
lastUpdated: 2019-03-01
updated: 2019-03-01
tags:
- windows
---

View File

@ -2,7 +2,7 @@
title: "How to make your website available over I2P Eepsite on NixOS"
excerpt: "A guide on I2P Eepsite on NixOS"
date: 2020-03-21
lastUpdated: 2020-04-22
updated: 2020-04-22
tags:
- server
- linux

View File

@ -2,7 +2,7 @@
title: Make Hexo blog smaller
excerpt: Static site serves html, css, javascript and images. These files can be compressed to reduce bandwidth and speed up the website.
date: 2018-09-28
lastUpdated: 2018-10-06
updated: 2018-10-06
tags:
- hexo
---

View File

@ -2,7 +2,7 @@
title: microG, a replacement for the proprietary Google Play Services
excerpt: The core of the Android OS is open source, but much of the core apps, libraries and APIs are proprietary.
date: 2019-01-12
lastUpdated: 2019-04-30
updated: 2019-04-30
tags:
- android
---

View File

@ -2,7 +2,7 @@
title: Recommended open-source Android apps
excerpt: Apps I'm currently using and recommend to everyone.
date: 2019-01-07
lastUpdated: 2020-04-15
updated: 2020-04-15
tags:
- android
---

View File

@ -2,7 +2,7 @@
title: Secure node modules with Snyk
excerpt: The package dependency on Node can cause security issue. Here's how to use Snyk to mitigate it.
date: 2018-10-01
lastUpdated: 2019-06-11
updated: 2019-06-11
tags:
- node
- snyk

View File

@ -2,7 +2,7 @@
title: Snyk failed to patch in Alpine docker
excerpt: Synk depends on GNU version of patch utility.
date: 2018-10-31
lastUpdated: 2019-03-09
updated: 2019-03-09
tags:
- snyk
- linux

View File

@ -2,7 +2,7 @@
title: Change spellcheck language in Ghostwriter
excerpt: It supports Hunspell dictionaries for spellcheck of other languages.
date: 2018-10-14
lastUpdated: 2019-06-06
updated: 2019-06-06
tags:
- markdown
---

View File

@ -2,7 +2,7 @@
title: "How to make your website available over Tor hidden service on NixOS"
excerpt: "A guide on Tor hidden service on NixOS"
date: 2020-03-16
lastUpdated: 2020-04-22
updated: 2020-04-22
tags:
- server
- linux

View File

@ -2,7 +2,7 @@
title: About
layout: page
date: 2019-09-20
lastUpdated: 2020-02-19
updated: 2020-02-19
---
## Projects

View File

@ -17,7 +17,7 @@
</div>
<footer class="article-footer">
<ul class="article-meta">
<% if (post.lastUpdated) { %>
<% if (post.updated) { %>
<li>
<span class="label"><%= __('date_updated') %>:</span>
<%- partial('post/updated-date') %>

View File

@ -1,3 +1,3 @@
<%/* User-specified updated date */%>
<%/* default post.updated is (almost) always is the time 'hexo generate' is executed */%>
<time class="dt-updated" datetime="<%= date(post.lastUpdated, 'YYYY-MM-DD[T00:00:00.000Z]') %>" itemprop="dateModified"><%= date(post.lastUpdated, 'D MMM YYYY') %></time>
<time class="dt-updated" datetime="<%= date(post.updated, 'YYYY-MM-DD[T00:00:00.000Z]') %>" itemprop="dateModified"><%= date(post.updated, 'D MMM YYYY') %></time>

View File

@ -6,7 +6,7 @@
<link href="{{ feed_url | uriencode }}" rel="self"/>
{% if config.feed.hub %}<link href="{{ config.feed.hub | uriencode }}" rel="hub"/>{% endif %}
<link href="{{ url | uriencode }}"/>
<updated>{{ posts.first().updated.toISOString() }}</updated>
<updated>{% if posts.first().updated %}{{ posts.first().updated | date }}{% else %}{{ posts.first().date | date }}{% endif %}</updated>
<id>{{ url | uriencode }}</id>
{% if config.author %}
<author>
@ -21,7 +21,7 @@
<link href="{{ post.permalink }}"/>
<id>{{ post.permalink }}</id>
<published>{{ post.date.toISOString() }}</published>
<updated>{% if post.lastUpdated %}{{ post.lastUpdated | date }}{% else %}{{ post.date | date }}{% endif %}</updated>
<updated>{% if post.updated %}{{ post.updated | date }}{% else %}{{ post.date | date }}{% endif %}</updated>
{% if config.feed.content and post.content %}
<content type="html"><![CDATA[{{ post.content | noControlChars | safe }}]]></content>
{% endif %}

View File

@ -4,7 +4,7 @@
/*
* Modified from the hexo version,
* https://github.com/hexojs/hexo-generator-feed
* to use post.lastUpdated and remove timezone
* to remove timezone
*/
const { extname } = require('path')

View File

@ -38,7 +38,7 @@ function openGraphHelper () {
const screenshot = '/screenshot/' + prettyUrls(this.path, config.pretty_urls)
const siteName = config.title || ''
const published = page.date || ''
const updated = page.lastUpdated || ''
const updated = page.updated || ''
const language = config.language.replace('-', '_')
let result = ''

View File

@ -3,8 +3,8 @@
{% for post in posts %}
<url>
<loc>{{ post.permalink }}</loc>
{% if post.lastUpdated() %}
<lastmod>{{ post.lastUpdated() }}</lastmod>
{% if post.updated %}
<lastmod>{{ post.updated }}</lastmod>
{% elif post.date %}
<lastmod>{{ post.date }}</lastmod>
{% endif %}

View File

@ -33,10 +33,7 @@ module.exports = function (locals) {
.map((post) => ({
...post,
date: moment(post.date).format('YYYY-MM-DD[T00:00:00.000Z]'),
lastUpdated: () => {
if (post.lastUpdated) return moment(post.lastUpdated).format('YYYY-MM-DD[T00:00:00.000Z]')
else return false
}
updated: post.updated ? moment(post.updated).format('YYYY-MM-DD[T00:00:00.000Z]') : false
}))
// configuration dictionary