{"id":15350480,"url":"https://github.com/takuti/prelims","last_synced_at":"2025-04-15T04:20:26.920Z","repository":{"id":44850370,"uuid":"442522487","full_name":"takuti/prelims","owner":"takuti","description":"Front matter post-processor for static site generators","archived":false,"fork":false,"pushed_at":"2022-09-08T04:33:21.000Z","size":53,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T15:48:22.827Z","etag":null,"topics":["content-management-system","frontmatter","natural-language-processing","python","recommender-systems","static-site-generator","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-28T16:35:58.000Z","updated_at":"2023-06-21T15:41:03.000Z","dependencies_parsed_at":"2022-08-24T05:21:23.532Z","dependency_job_id":null,"html_url":"https://github.com/takuti/prelims","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuti%2Fprelims","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuti%2Fprelims/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuti%2Fprelims/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuti%2Fprelims/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuti","download_url":"https://codeload.github.com/takuti/prelims/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004315,"owners_count":21196852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-management-system","frontmatter","natural-language-processing","python","recommender-systems","static-site-generator","yaml"],"created_at":"2024-10-01T11:58:32.081Z","updated_at":"2025-04-15T04:20:26.880Z","avatar_url":"https://github.com/takuti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Prelims\n===\n\n[![Dry Run Build](https://github.com/takuti/prelims/actions/workflows/dryrun.yml/badge.svg)](https://github.com/takuti/prelims/actions/workflows/dryrun.yml) [![PyPI version](https://badge.fury.io/py/prelims.svg)](https://badge.fury.io/py/prelims)\n\nFront matter post-processor for static site generators.\n\n## Overview\n\n**Prelims** eases updating YAML front matter of the static site generator contents (e.g., [Hugo](https://gohugo.io/content-management/front-matter/), [Jekyll](https://jekyllrb.com/docs/front-matter/), [Hexo](https://hexo.io/docs/front-matter.html)).\n\nYou can extract keywords based on [TF-IDF weighting](https://en.wikipedia.org/wiki/Tf%E2%80%93idf), generate a list of recommended posts by [content-based filtering](https://en.wikipedia.org/wiki/Recommender_system#Content-based_filtering), and even apply arbitrary custom functions to update front matters on-the-fly.\n\n### Example\n\nBelow is an original front matter for \"[User-Centricity Matters: My Reading List from RecSys 2021](https://takuti.me/note/recsys-2021/)\" at [takuti.me](https://takuti.me/):\n\n```yaml\n---\ncategories: [Recommender Systems]\ndate: 2021-10-05\nlang: en\ntitle: 'User-Centricity Matters: My Reading List from RecSys 2021'\n---\n```\n\nOnce a Python script is executed against all the posts, new metadata `recommendations` and `keywords` are dynamically generated and inserted as:\n\n```yaml\n---\ncategories: [Recommender Systems]\ndate: 2021-10-05\nkeywords: [recsys, bias, papers, wordcloud, echo, user, recommendations, metrics,\n  recommender, users]\nlang: en\nrecommendations: [/note/recsys-2021-echo-chambers-and-filter-bubbles/, /note/recsys-wordcloud/,\n  /note/ethical-challenges-in-recommender-systems/]\ntitle: 'User-Centricity Matters: My Reading List from RecSys 2021'\n---\n```\n\n## Installation\n\n```\n$ pip install prelims\n```\n\n## Usage\n\nAssume your posts are under `/path/to/posts` where a static site generator uses as a document root:\n\n```\nposts\n├── article-aaa.md\n├── ...\n└── article-zzz.md\n```\n\nHere, the following script reads all `.md` and `.html` files in the folder, builds recommendations, and update each post's front matter:\n\n```py\nfrom prelims import StaticSitePostsHandler\nfrom prelims.processor import Recommender\n\n\nhandler = StaticSitePostsHandler('/path/to/posts')\nhandler.register_processor(\n\tRecommender(permalink_base='/post')\n)\nhandler.execute()\n```\n\nFor instance, a front matter of `article-aaa.md` may eventually become:\n\n```yaml\n---\ndate: 2022-01-01\ntitle: Awesome Blog Post\nrecommendations: [/post/article-zzz/, /post/article-abc/, /post/article-xyz/]\nkeywords: [happy, beer, coffee, park, ...]\n---\n```\n\nYou can run the script as a pre-commit hook and automate the process e.g., with [lint-staged](https://github.com/okonet/lint-staged):\n\n```\n$ npm install -D lint-staged\n```\n\n```json\n{\n  ...\n  \"lint-staged\": {\n    \"posts/*.{md,html}\": [\n      \"python ./scripts/prelims.py\",\n      \"git add -u posts/\"\n    ]\n  },\n  ...\n}\n```\n\n## Limitations\n\n- The author is testing and using Prelims mainly with [Hugo](https://gohugo.io/). 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.\n- We assume there are hundreds of posts at most, not thousands. Every single post is sequentially processed one-by-one, and the `Recommender` module, for example, trains a model from scratch every time. As the number of posts increases, you may encounter scalability issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuti%2Fprelims","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuti%2Fprelims","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuti%2Fprelims/lists"}