Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/schema/common/article.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
"default": true,
"nullable": true
},
"update_time": {
"type": ["boolean", "string"],
"description": "Whether to show updated time. For \"auto\", shows article update time only when page.updated is set and it is different from page.date",
"default": true,
"enum": [true, false, "auto"],
"nullable": true
},
"licenses": {
"$ref": "/misc/poly_links.json",
"description": "Article licensing block",
Expand Down
5 changes: 4 additions & 1 deletion layout/common/article.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports = class extends Component {
const indexLaunguage = config.language || 'en';
const language = page.lang || page.language || config.language || 'en';
const cover = page.cover ? url_for(page.cover) : null;
const updateTime = article && article.update_time !== undefined ? article.update_time : true;
const isUpdated = page.updated && !moment(page.date).isSame(moment(page.updated));
const shouldShowUpdated = page.updated && ((updateTime === 'auto' && isUpdated) || updateTime === true);

return <Fragment>
{/* Main content */}
Expand All @@ -47,7 +50,7 @@ module.exports = class extends Component {
__html: _p('article.created_at', `<time dateTime="${date_xml(page.date)}" title="${new Date(page.date).toLocaleString()}">${date(page.date)}</time>`)
}}></span>}
{/* Last Update Date */}
{page.updated && <span class="level-item" dangerouslySetInnerHTML={{
{shouldShowUpdated && <span class="level-item" dangerouslySetInnerHTML={{
__html: _p('article.updated_at', `<time dateTime="${date_xml(page.updated)}" title="${new Date(page.updated).toLocaleString()}">${date(page.updated)}</time>`)
}}></span>}
{/* author */}
Expand Down