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

Custom meta variable for date of publish of article #48

Closed
michalzobec opened this issue Feb 27, 2021 · 6 comments
Closed

Custom meta variable for date of publish of article #48

michalzobec opened this issue Feb 27, 2021 · 6 comments
Labels
wontfix This will not be worked on

Comments

@michalzobec
Copy link

michalzobec commented Feb 27, 2021

Hello,

thank you very much for your plugin. is very useful for me and it works.

but I have one little problem, because it automatically generate at end of article information about last update.

I have my custom meta variable PublishedDate like

---
template: overrides/main.html
PublishedDate: 01.12.2020
---

it is possible add of support of this variable from your side? because I would like to avoid editing the template, if is possible.

and if is possible define of possition of update information in article (top/end), it will be great. :)

thank you very much for your help.

@timvink
Copy link
Owner

timvink commented Feb 27, 2021

Hi @michalzobec. Good to hear it's useful for you!

So if I understand correctly, you would like the revision date to be based off of a page meta variable like PublishedDate, instead of the last git commit on a file?

The date would have to be in ISO8601 format, and the variable name to look for should be configurable in the config.

Could be useful, but not sure if it fits in the scope of the plugin (which is revision-date based on git). I'll think about it, and also wait and see if some users upvote the issue.

@timvink timvink added the enhancement New feature or request label Feb 27, 2021
@michalzobec
Copy link
Author

michalzobec commented Feb 28, 2021

Hello @timvink

thank you for your fast reply :)

So if I understand correctly, you would like the revision date to be based off of a page meta variable like PublishedDate, instead of the last git commit on a file?

sorry, no. I need use both, your information, and my information (variable).

your plugin inserts information about last update. my variable inserts the date of first publish of same article.

for examle:

Published: <some date here>
Last update: <some date here>

Last update is your information from your plugin.
Published is my information from my variable in same article.

Here is real example: https://pomoc2.zobecdev.cz/testpage/

2021-02-28 22_45_09-Test Page - Pomoc a podpora

you will found on begin of page:

Vydáno: 01.12.2020 14:00:00
Změněno: 27. února 2021 22:38:39

It is clear for you now? :)

The date would have to be in ISO8601 format, and the variable name to look for should be configurable in the config.

yes, I understand that. :)

Have nice day.

Michal

@timvink
Copy link
Owner

timvink commented Mar 1, 2021

Oh I see. The {{ page.meta.git_revision_date_localized }} tag has been embedded into mkdocs-material (see https://github.com/squidfunk/mkdocs-material/blob/master/material/partials/source-date.html), which is why you don't need an override for that one.

Using overrides is the preferred way to go. You can improve your setup by overriding the source-date.html instead of main.html, which will make your customization much more stable (as mkdocs-material's main.html is updated much more frequently, meaning you will have to update your override more often).

@timvink timvink closed this as completed Mar 1, 2021
@timvink timvink added wontfix This will not be worked on and removed enhancement New feature or request labels Mar 1, 2021
@michalzobec
Copy link
Author

yeah, but if you add you support for custom meta variable (to your plugin), I do not must use override. and that's why I asked you, for exactly the reasons you're giving. so that I don't have to deal with customizations at all and have problems with upgrades.

@timvink
Copy link
Owner

timvink commented Mar 2, 2021

Initially to use this plugin's {{ page.meta.git_revision_date_localized }} with mkdocs-material theme, you also needed to use an override. Because so many people use this plugin, I was able to convince the author of mkdocs-material to update his template to include it.

If you want support for your PublishedDate variable inside mkdocs-material, you will have to open an issue in that repository. Overriding partials is the preferred way of extending a theme, and mkdocs-material providing the very specific partials/source-date.html makes it really easy already. But if you can make a strong case in an issue to mkdocs-material perhaps you will be able to convince the author.

@michalzobec
Copy link
Author

ahh, okay, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants