Prelims
Front matter post-processor for static site generators.
Overview
Prelims eases updating YAML front matter of the static site generator contents (e.g., Hugo, Jekyll, Hexo).
You can extract keywords based on TF-IDF weighting, generate a list of recommended posts by content-based filtering, and even apply arbitrary custom functions to update front matters on-the-fly.
Example
Below is an original front matter for "User-Centricity Matters: My Reading List from RecSys 2021" at takuti.me:
---
categories: [Recommender Systems]
date: 2021-10-05
lang: en
title: 'User-Centricity Matters: My Reading List from RecSys 2021'
---
Once a Python script is executed against all the posts, new metadata recommendations and keywords are dynamically generated and inserted as:
---
categories: [Recommender Systems]
date: 2021-10-05
keywords: [recsys, bias, papers, wordcloud, echo, user, recommendations, metrics,
recommender, users]
lang: en
recommendations: [/note/recsys-2021-echo-chambers-and-filter-bubbles/, /note/recsys-wordcloud/,
/note/ethical-challenges-in-recommender-systems/]
title: 'User-Centricity Matters: My Reading List from RecSys 2021'
---
Installation
$ pip install prelims
Usage
Assume your posts are under /path/to/posts where a static site generator uses as a document root:
posts
├── article-aaa.md
├── ...
└── article-zzz.md
Here, the following script reads all .md and .html files in the folder, builds recommendations, and update each post's front matter:
from prelims import StaticSitePostsHandler
from prelims.processor import Recommender
handler = StaticSitePostsHandler('/path/to/posts')
handler.register_processor(
Recommender(permalink_base='/post')
)
handler.execute()
For instance, a front matter of article-aaa.md may eventually become:
---
date: 2022-01-01
title: Awesome Blog Post
recommendations: [/post/article-zzz/, /post/article-abc/, /post/article-xyz/]
keywords: [happy, beer, coffee, park, ...]
---
You can run the script as a pre-commit hook and automate the process e.g., with lint-staged:
$ npm install -D lint-staged
{
...
"lint-staged": {
"posts/*.{md,html}": [
"python ./scripts/prelims.py",
"git add -u posts/"
]
},
...
}
Limitations
- The author is testing and using Prelims mainly with Hugo. Although the tool is intended to be applicable to a variety of static site generators, there must be several edge cases that won't work properly due to unique behaviors associated with a specific generator.
- We assume there are hundreds of posts at most, not thousands. Every single post is sequentially processed one-by-one, and the
Recommendermodule, for example, trains a model from scratch every time. As the number of posts increases, you may encounter scalability issues.
Metadata
Release files for prelims 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| prelims-0.1.0.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prelims-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / prelims-0.1.0.tar.gz
| Download URL | prelims-0.1.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eea087b6a698fdc251a2589b06effc73bf7b790fa02ecab8b2eab33be4c847c6
|
|
BLAKE2b-256 checksum How to use checksums |
c87f4c35fcc887287c560fa29baf0ebe4e42a044f65cb1b19bb60fe0cc5e358d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / prelims-0.1.0-py3-none-any.whl
| Download URL | prelims-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1a116b7577ad6b540c2df7fee46afafbe2b22095c38d4e221154f90d4ff7034
|
|
BLAKE2b-256 checksum How to use checksums |
9d594794d71a715dfb9bbe49935f9172f74f104594f6aed2f2bc0ea6dee23eec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|