From e7f74f4bb28f765dde5e7a4e322890dd81f2052d Mon Sep 17 00:00:00 2001 From: sbansal3096 Date: Thu, 23 Aug 2018 10:50:49 +0530 Subject: [PATCH 1/9] Adding last updated time for docs --- lib/core/DocsLayout.js | 15 +++++++++++++++ package.json | 1 + 2 files changed, 16 insertions(+) diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index decf445e4b84..ee44d43c2ab5 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -40,6 +40,17 @@ class DocsLayout extends React.Component { if (this.props.Doc) { DocComponent = this.props.Doc; } + const spawn = require('cross-spawn'); + const timeSpan = spawn + .sync('git', [ + 'log', + '-1', + '--format=%ct', + `versioned_docs/${metadata.source}`, + ]) + .stdout.toString('utf-8'); + const date = new Date(parseInt(timeSpan, 10) * 1000); + const updateTime = date.toLocaleString(); const title = i18n ? translation[this.props.metadata.language]['localized-strings'][ this.props.metadata.localized_id @@ -110,6 +121,10 @@ class DocsLayout extends React.Component { )} +

+ Last updated: + {updateTime} +

{hasOnPageNav && (