Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate Last Updated on each page #706

Open
failfmi opened this issue Sep 28, 2023 · 1 comment
Open

Populate Last Updated on each page #706

failfmi opened this issue Sep 28, 2023 · 1 comment
Assignees

Comments

@failfmi
Copy link
Contributor

failfmi commented Sep 28, 2023

It would be nice to have the date when was the given page last updated. The field exists, it just has to be populated.
image

image

@heversonbr heversonbr self-assigned this Oct 3, 2023
@heversonbr
Copy link
Contributor

The issue here is that, the default docusaurus plugin (i.e.,plugin-content-docs) that captures the 'date' and 'author' information for doc file uses git log command to retrieve these information when the options: showLastUpdateAuthor and showLastUpdateTime are set to true.

file: node_modules/@docusaurus/utils/lib/gitUtils.js

function getFileCommitDate(file, { age = 'oldest', includeAuthor = false, }) {
    if (!shelljs_1.default.which('git')) {
        throw new GitNotFoundError(`Failed to retrieve git history for "${file}" because git is not installed.`);
    }
    if (!shelljs_1.default.test('-f', file)) {
        throw new Error(`Failed to retrieve git history for "${file}" because the file does not exist.`);
    }
    const args = [
        `--format=%ct${includeAuthor ? ',%an' : ''}`,
        '--max-count=1',
        age === 'oldest' ? '--follow --diff-filter=A' : undefined,
    ]
        .filter(Boolean)
        .join(' ');
    const result = shelljs_1.default.exec(`git log ${args} -- "${path_1.default.basename(file)}"`, {  
    

As the spec website is a submodule of the spec documentation and the source files are copied to the docusaurus's to 'src/docs' directory at building time, the default plugin cannot get the required information from the local website git repo (because the directory is ignored by the local .gitignore).
A potential solution I see here is to re-write a new plugin for docusaurus to grab the information from the spec-repo by using git API instead of git log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants