Skip to main content

A plugin to extract authors, created date and updated date from YAML frontmatter

Project description

mkdocs-footermatter (Working title)

Build Status GitHub latest commit PyPi AGPLv3 license codecov

A plug-in to extract authors, created and updated data from the YAML fronmatter to be rendered in a footer template.

This solves a problem I had when batch renaming every file inside a GitHub action which would overwrite the aforementioned logs. (Renaming %20 to -)

img.png

Inspired by git-revision-date-localized and mkdocs-git-committers-plugin, without the need of using git logs.

Setup

Install the plugin using pip:

pip install mkdocs-footermatter

Activate the plugin in mkdocs.yml:

plugins:
  - search
  - footermatter:
      author_map:
        - Firstname Lastname | assets/img/firstname.png | https://github.com/firstnamelastname
        - Author2 | <path from "custom_dir"> | htts://github.com/author2

Note: If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set, but now you have to enable it explicitly.

Usage

Can be used in conjunction with the Obsidian plug-in update-time-on-edit-obsidian

Example frontmatter:

---
authors:
  - Firstname Lastname
  - Author2
created: 2022-04-09 08:52:19
updated: 2022-08-13 12:18:05
---

Configuration options

Fronmatter keys:

  • key_authors fronmatter syntax for authors. Default: authors
  • key_created frontmatter syntax for date created. Default: created
  • key_updated frontmatter syntax for date updated. Default: updated

Locale & format:

  • locale language format for date_format (some options may require this to be configured, see below) fallbacks to theme language (recommended) or en
  • date_format What format to use for the dates, see below for options. Default: date
  • timeago_absolute Boolean to omit the ago text. True: 2 days, False: 2 days ago. Default: True

Author rendering options:

  • author_map List of authors mapped image and url values: name | img (path relative to "custom_dir" or url) | url/website
  • separator_map separator for author_map. Default |
  • default_author_img fallback image if missing from author_map. Default https://ui-avatars.com (See template for details)
  • default_author_url fallback url if missing from author_map. Default: /

Date formats

Note: values are static and only change when re-building your docs. All formats are localized using the Pendulum package

  • timeago (2 hours ago) - a readable, relative date format.
  • date (January 1. 2022) - simple date format (LL).
  • datetime (January 1. 2022 12:00 PM) - same as date, but with added timestamp (LLL)
  • For custom formats just pass a valid pendulum string format. Example: MMMM YYYY = January 2022

Template

An example setup can be seen in the overrides folder, including some css styling and an example main.html

Relevant context values:

{{ footermatter_updated }}
{{ footermatter_created }}
{%- for author in footermatter_authors -%}
    {{ author.name }}
    {{ author.img }} 
    {{ base_url }}/{{ author.img }}
    {{ author.url }}
{%- endfor -%}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs-footermatter-1.3.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_footermatter-1.3.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-footermatter-1.3.0.tar.gz.

File metadata

  • Download URL: mkdocs-footermatter-1.3.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for mkdocs-footermatter-1.3.0.tar.gz
Algorithm Hash digest
SHA256 42427fa14564b66ab456ee9a8cdd2fe710deecb893cd0fb52bf1d0c2c558d6f1
MD5 ce5e4c4cd492b5fafb04a485c421878b
BLAKE2b-256 a6c119428b350087bdb899583de5fb550ce76afafeef56e594687e6107f7972c

See more details on using hashes here.

File details

Details for the file mkdocs_footermatter-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_footermatter-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bfc67cfe8534e7e6bc87efff3b0fff8f93cc76ce49c43a63c3f69a19901ffe3
MD5 430ef29a509b8525f711030fe567866b
BLAKE2b-256 3e863015716d88b95f0486bcdeb08cae86cf37abed6f7e3f940f636c9edf66fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page