diff --git a/docs/api-site-config.md b/docs/api-site-config.md index 2164c0f526d9..17ede83f2078 100644 --- a/docs/api-site-config.md +++ b/docs/api-site-config.md @@ -98,6 +98,8 @@ customDocsPath: 'website-docs'; `editUrl` - URL for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document. +`enableUpdateTime` - An option to enable the docs showing last update time. Set to `true` to show a line at the bottom right corner of each doc page as `Last Updated: dd/mm/yyyy hh:MM:ss Z`. + `facebookAppId` - If you want Facebook Like/Share buttons in the footer and at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296). `facebookComments` - Set this to `true` if you want to enable Facebook comments at the bottom of your blog post. `facebookAppId` has to be also set. diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 0f28006f166b..d859e6b3532e 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -16,7 +16,8 @@ const DocsSidebar = require('./DocsSidebar.js'); const OnPageNav = require('./nav/OnPageNav.js'); const Site = require('./Site.js'); const translation = require('../server/translation.js'); -const {idx} = require('./utils.js'); +const docs = require('../server/docs.js'); +const {idx, getGitLastUpdated} = require('./utils.js'); // component used to generate whole webpage for docs, including sidebar/header/footer class DocsLayout extends React.Component { @@ -43,6 +44,12 @@ class DocsLayout extends React.Component { if (this.props.Doc) { DocComponent = this.props.Doc; } + let updateTime; + if (this.props.config.enableUpdateTime) { + const filepath = docs.getFilePath(metadata); + updateTime = getGitLastUpdated(filepath); + } + const title = idx(i18n, ['localized-strings', 'docs', id, 'title']) || defaultTitle; const hasOnPageNav = this.props.config.onPageNav === 'separate'; @@ -100,6 +107,13 @@ class DocsLayout extends React.Component { )} + {this.props.config.enableUpdateTime && + updateTime && ( +

+ Last updated: + {updateTime} +

+ )} {hasOnPageNav && (