mkdocs-rss-plugin icon indicating copy to clipboard operation
mkdocs-rss-plugin copied to clipboard

Ability to configure fallback to creation date when `as_update` not found?

Open stratself opened this issue 6 months ago • 1 comments

Hello ,

It seems like the plugin falls back to git logs, and then to build time, if a preconfigured as_update field is not found in the page's meta. Is it possible to configure fallback to another method, e.g. to as_created field?

I wanna explicitly define the update times of my RSS entries, and would like unspecified posts to show creation time as pubTime in the update feed. On a wider scope, it'd be nice to configure different fallback mechanisms for the created and updated fields.

Any current workarounds is appreciated. Thanks a lot.

stratself avatar Aug 18 '25 08:08 stratself

I managed to monkeypatch this by using mkdocs-macros-plugin to replace updated with created if said key isn't found:

def on_pre_page_macros(env):
    try:
        env.page.meta['updated']
    except KeyError:
        env.page.meta['updated'] = env.page.meta['created']

Per their technical notes, on_pre_page_macros(env) should intercept the meta before HTML (and other plugins) are triggered.

stratself avatar Aug 18 '25 09:08 stratself

Thank you for that workaround! I'm using a date dictionary, my front matter looks like this:

date:
  created: 2025-11-15T22:25:53+01:00

I have configured date_from_meta accordingly.

If anyone else is using a setup like that, you can use this version of on_pre_page_macros instead:

def on_pre_page_macros(env):
    if (
        (dates := env.page.meta.get("date"))
        and "created" in dates
        and "updated" not in dates
    ):
        dates["updated"] = dates["created"]

scy avatar Nov 16 '25 12:11 scy