timvink / mkdocs-git-revision-date-localized-plugin

MkDocs plugin to add a last updated date to your site pages
https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html
MIT License
198 stars 40 forks source link

Get raw values, without HTML tags #64

Closed ZsharE closed 2 years ago

ZsharE commented 2 years ago

Hi,

Is there any way to get the plain data value, without the HTML tag ? Right know the {{ page.meta.git_revision_date_localized }} and {{ page.meta.git_creation_date_localized }} renders in a span tag.

<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2021-11-3</span>

There should be an option to be able to use only the date value.

I need this to be able to create custom meta tags for: article:published_time & article:modified_time properties like this:

<meta property="article:published_time" content="{{ page.meta.git_creation_date_localized }}">
<meta property="article:modified_time" content="{{ page.meta.git_revision_date_localized }}">

Thanks

timvink commented 2 years ago

Hi @ZsharE. Good point, I agree the raw date strings should be available for developers. Currently the span is hardcoded:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/ff73362e5be9250507ea8f8d6a22fa52124a7da3/mkdocs_git_revision_date_localized_plugin/util.py#L195-L200

I made some quick and dirty edits and exposed more date variants in page.meta (https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/commit/ff73362e5be9250507ea8f8d6a22fa52124a7da3). Just released in 0.10.1. You can find the list of new available tags at https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/howto/override-a-theme/#custom-themes

ZsharE commented 2 years ago

Hi @timvink ,

Thanks for the quick release, but there's a little problem:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/ff73362e5be9250507ea8f8d6a22fa52124a7da3/mkdocs_git_revision_date_localized_plugin/plugin.py#L224

is_first_commit should be True.

Right now, the revision_date = creation_date.

ZsharE commented 2 years ago

Hi @timvink , any update about this issue ?

timvink commented 2 years ago

It's on my list but have had other stuff on my plate. Will prob look at it next Wednesday.

ThomasArdal commented 2 years ago

@timvink Sounds great. Let us know if we can help with anything. Test, etc.

timvink commented 2 years ago

Should be fixed now. I also spent a bit more time refactoring the code as 0.10.1 introduced extra overhead due to extra git log operations.

Releases notes: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/releases/tag/v0.10.2

ZsharE commented 2 years ago

Everything works great now, thanks !