Skip to content

mkdocs_nype.plugins.unique_blog_date.plugin

Synopsis

MkDocs plugin made to patch the date in a material/blog plugin instance.

This plugin was formerly a hook:

By default when using multiple blog instances the post_date_format option of the last instance modifies the date format for all instances. The patch replaces the date processor between pages to avoid the need to modify the template.

MIT License 2024 Kamil Krzyśków (HRY) for Nype (npe.cm)

PLUGIN_NAME

PLUGIN_NAME: str = 'unique_blog_date'

Name of this plugin. Used in logging.

LOG

LOG: PrefixedLogger = PrefixedLogger(PLUGIN_NAME, getLogger(f'mkdocs.plugins.{PLUGIN_NAME}'))

Logger instance for this plugin.

UniqueBlogDatePlugin

UniqueBlogDatePlugin()

Bases: BasePlugin[UniqueBlogDateConfig]

env_ref

env_ref = None

blog_filter_ref

blog_filter_ref = None

custom_filter_ref

custom_filter_ref = None

_blog_root

_blog_root = None

on_config

on_config(config: MkDocsConfig) -> MkDocsConfig | None

Validate a blog instance with the given root exists

on_env

on_env(env: Environment, *, config: MkDocsConfig, **__) -> Optional[Environment]

Main function. Triggers just before the build begins.

on_page_context

on_page_context(context, page, config, nav)

Depending on the page url replace the filter

_format_date

_format_date(date: datetime, format: str, config: MkDocsConfig)

Copied from the material/blog plugin