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

Add most recent update date to main page #19

Closed
luukvandervelden opened this issue Mar 23, 2020 · 2 comments · Fixed by #66
Closed

Add most recent update date to main page #19

luukvandervelden opened this issue Mar 23, 2020 · 2 comments · Fixed by #66
Labels
enhancement New feature or request

Comments

@luukvandervelden
Copy link
Contributor

I find it usefull to see a 'updated by' date at the bottom of each page. However, I'm looking for a way to add an overall 'last updated' date to the main page, for example to the header.

Do you have a suggestion how to do that?

@timvink
Copy link
Owner

timvink commented Mar 24, 2020

Do you mean the last update to the site (any page)?

That would be a great addition. I'm working on a large release for mkdocs-git-authors-plugin . In that plugin I already process all pages with git, and adding the git revision date should be fairly easy. I plan to merge both plugins due to the similarities in the future.

Planning to add two tags:

  • {{ git_site_last_update }} (last update of any page in site)
  • {{ git_page_last_update }} (last update of page)

I will report in this issue once the functionality is there.

@luukvandervelden
Copy link
Contributor Author

luukvandervelden commented Mar 27, 2020

Yes that's the feature I'm suggesting!

For now I got it to work with this:


        # Date of the page
        file_revision_dates = self.util.get_revision_date_for_file(
            path=page.file.abs_src_path,
            locale = self.locale
        )
        file_revision_date = file_revision_dates[self.config['type']]
        page.meta['git_revision_date_localized'] = file_revision_date

        # Date of the full documentation
        main_revision_dates = self.util.get_revision_date_for_file(
            path=os.path.dirname(page.file.abs_src_path),
            locale=self.locale
        )
        main_revision_date = main_revision_dates[self.config['type']]
        page.meta['git_main_date_localized'] = main_revision_date

        temp_str = re.sub(r"\{\{\s*[page\.meta\.]*git_revision_date_localized\s*\}\}",
                          file_revision_date,
                          markdown,
                          flags=re.IGNORECASE)

        return re.sub(r"\{\{\s*[page\.meta\.]*git_main_date_localized\s*\}\}",
                      main_revision_date,
                      temp_str,
                      flags=re.IGNORECASE)

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

Successfully merging a pull request may close this issue.

2 participants