Skip to main content

Front matter post-processor for static site generators

Project description

Prelims

Dry Run Build

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 git+https://github.com/takuti/prelims.git

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/"
    ]
  },
  ...
}

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

prelims-0.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

prelims-0.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file prelims-0.0.1.tar.gz.

File metadata

  • Download URL: prelims-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2

File hashes

Hashes for prelims-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a780b6249b6743ac5862ee02eb5868702189ec183f338978e57811b7dffd2f6b
MD5 8f9ec57a6d9ced720911ec0061b2f315
BLAKE2b-256 c21c107be98602fb8e8f1509c53a44d78d1872cfa337fc8415a94b4d2c6ee704

See more details on using hashes here.

File details

Details for the file prelims-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: prelims-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2

File hashes

Hashes for prelims-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6dd32898f1cda30e215677a432122ae54221488841b0420fc3b7c1de1c75873a
MD5 053846a89938ce8acb59033441e846be
BLAKE2b-256 3a19d7df4dad3591f2bcb7ee248e2e97867a6c1e021b84d81377ca94503aba41

See more details on using hashes here.

Supported by

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