mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 20:46:58 +02:00
feat: add last contributor to each document (#980)
* add contributor list to each document * handle case where there is no github repo * Move to v1 * Revert "handle case where there is no github repo" This reverts commita76a887901
. * Revert "add contributor list to each document" This reverts commitc0cc79f995
. * Add last updated by field * -Include enableUpdateBy in the config - Rename css class to be more general * Fix lint * Refactor : - s/getGitlastupdated/getGitLastUpdatedTime - refactor part in getGitLastUpdated[Time|By] that overlaps - remove getAuthorInformation * -Modify the display logic -Refactor the utils, combine lastupdatedtime and lastupdatedby -Replace the test * Modify docs based on the display change * Update docs for url and baseurl For more clarity and to make relationship more clear * Update support for Web App Manifest (#1046) * misc: update nits * misc: update nits
This commit is contained in:
parent
4a7e1ea189
commit
8cf9afe4ac
7 changed files with 158 additions and 62 deletions
|
@ -17,7 +17,7 @@ const OnPageNav = require('./nav/OnPageNav.js');
|
|||
const Site = require('./Site.js');
|
||||
const translation = require('../server/translation.js');
|
||||
const docs = require('../server/docs.js');
|
||||
const {idx, getGitLastUpdated} = require('./utils.js');
|
||||
const {idx, getGitLastUpdatedTime, getGitLastUpdatedBy} = require('./utils.js');
|
||||
|
||||
// component used to generate whole webpage for docs, including sidebar/header/footer
|
||||
class DocsLayout extends React.Component {
|
||||
|
@ -45,16 +45,19 @@ class DocsLayout extends React.Component {
|
|||
if (this.props.Doc) {
|
||||
DocComponent = this.props.Doc;
|
||||
}
|
||||
const filepath = docs.getFilePath(metadata);
|
||||
|
||||
let updateTime;
|
||||
if (this.props.config.enableUpdateTime) {
|
||||
const filepath = docs.getFilePath(metadata);
|
||||
updateTime = getGitLastUpdated(filepath);
|
||||
}
|
||||
const updateTime = this.props.config.enableUpdateTime
|
||||
? getGitLastUpdatedTime(filepath)
|
||||
: null;
|
||||
const updateAuthor = this.props.config.enableUpdateBy
|
||||
? getGitLastUpdatedBy(filepath)
|
||||
: null;
|
||||
|
||||
const title =
|
||||
idx(i18n, ['localized-strings', 'docs', id, 'title']) || defaultTitle;
|
||||
const hasOnPageNav = this.props.config.onPageNav === 'separate';
|
||||
|
||||
const previousTitle =
|
||||
idx(i18n, ['localized-strings', metadata.previous_id]) ||
|
||||
idx(i18n, ['localized-strings', 'previous']) ||
|
||||
|
@ -90,15 +93,16 @@ class DocsLayout extends React.Component {
|
|||
version={metadata.version}
|
||||
language={metadata.language}
|
||||
/>
|
||||
{this.props.config.enableUpdateTime &&
|
||||
updateTime && (
|
||||
<div className="docLastUpdateTimestamp">
|
||||
<em>
|
||||
<strong>Last updated: </strong>
|
||||
{updateTime}
|
||||
</em>
|
||||
</div>
|
||||
)}
|
||||
{(updateTime || updateAuthor) && (
|
||||
<div className="docLastUpdate">
|
||||
<em>
|
||||
Last updated
|
||||
{updateTime && ` on ${updateTime}`}
|
||||
{updateAuthor && ` by ${updateAuthor}`}
|
||||
</em>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="docs-prevnext">
|
||||
{metadata.previous_id && (
|
||||
<a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue