{"id":16795817,"url":"https://github.com/mrvautin/smart-matter","last_synced_at":"2026-02-15T09:43:40.958Z","repository":{"id":57363859,"uuid":"392268776","full_name":"mrvautin/smart-matter","owner":"mrvautin","description":"Parses front matter Yaml from a file path or a string and returns an Object. Used by https://squido.markmoffat.com.","archived":false,"fork":false,"pushed_at":"2024-10-20T10:23:18.000Z","size":226,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-24T15:19:03.067Z","etag":null,"topics":["front-matter","matter","parser","yaml"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrvautin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-03T09:53:50.000Z","updated_at":"2024-10-20T10:23:21.000Z","dependencies_parsed_at":"2024-11-14T22:34:24.965Z","dependency_job_id":null,"html_url":"https://github.com/mrvautin/smart-matter","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"49ac41bea6c262938ac66a7ca4aaa6f40ef3f861"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrvautin/smart-matter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrvautin%2Fsmart-matter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrvautin%2Fsmart-matter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrvautin%2Fsmart-matter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrvautin%2Fsmart-matter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrvautin","download_url":"https://codeload.github.com/mrvautin/smart-matter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrvautin%2Fsmart-matter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262347474,"owners_count":23296894,"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":["front-matter","matter","parser","yaml"],"created_at":"2024-10-13T09:17:29.603Z","updated_at":"2025-10-12T09:10:57.797Z","avatar_url":"https://github.com/mrvautin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save smart-matter\n```\n\n## How does it work\n\n`smart-matter` parses front-matter either from a file path or from a string containing `front-matter`.\n\nIf supplied, `smart-matter` will parse a `date` input into a Javascript Date Object. When using the `file`(path) API, `smart-matter` will return last modified date of the file.\n\n# API\n\n## File\n\nInput is a string with the full path to the input file.\n\n**Params**\n\n* `input` **{String}**: A full path string to the file with `front matter`.\n\n## Contents\n\nInput is a string contents which returns an object.\n\n**Params**\n\n* `input` **{String}**: String with the contents of the file with `front matter`.\n\n# Examples\n\n## file (path)\n\n```js\nimport path from 'path';\nimport { file } from 'smart-matter' ;\nconst sm = file(path.join(__dirname, 'file.markdown'));\nconsole.log('matter', sm);\n```\n\nThis assumes that `file.markdown` is formatted similar to this:\n\n``` yaml\n---\ntitle: Hello World\npermalink: hello-world\ndate: '2021-07-03 19:17:00'\ntags: \n  - my\n  - tags\n---\n\n## Hello world\n```\n\n`smart-matter` will parse this file and return an object like this:\n\n```javascript\n{\n    title: \"Hello World\",\n    permalink: \"hello-world\",\n    date: \"2021-07-03 19:17:00\",\n    tags: [ \"my\", \"tags\" ],\n    matter: \"title: Hello World\\n\n        permalink: hello-world\\n\n        date: 2021-07-03 19:17:00\\n\n        tags: \\n\n          - my\\n\n          - tags\\n\",\n    file: \"/Users/mark/Documents/Code/smart-matter/tests/test.markdown\",\n    lastupdated: 2021-08-03T06:45:46.170Z,\n    hash: \"b10a8db164e0754105b7a99be72e3fe5\",\n    content: \"\\n\\n## Hello world\",\n    dateObject: 2021-07-03T09:47:00.000Z,\n    dateISO: \"2021-07-03T09:47:00.000Z\",\n    error: null,\n    empty: false\n}\n```\n\n## contents (string)\n\n```js\nimport fs from 'fs';\nimport { contents } from 'smart-matter';\nconst filePath = fs.readFileSync('file.markdown', 'utf8');\nconst sm = contents(filePath);\nconsole.log('matter', sm);\n```\n\nThis assumes that `file.markdown` is formatted similar to this:\n\n``` yaml\n---\ntitle: Hello World\npermalink: hello-world\ndate: '2021-07-03 19:17:00'\ntags: \n  - my\n  - tags\n---\n\n## Hello world\n```\n\n`smart-matter` will parse this file and return an object like this:\n\n```javascript\n{\n    title: \"Hello World\",\n    permalink: \"hello-world\",\n    date: \"2021-07-03 19:17:00\",\n    tags: [ \"my\", \"tags\" ],\n    matter: \"title: Hello World\\n\n        permalink: hello-world\\n\n        date: 2021-07-03 19:17:00\\n\n        tags: \\n\n          - my\\n\n          - tags\\n\",\n    hash: \"b10a8db164e0754105b7a99be72e3fe5\",\n    content: \"\\n\\n## Hello world\",\n    dateObject: 2021-07-03T09:47:00.000Z,\n    dateISO: \"2021-07-03T09:47:00.000Z\",\n    error: null,\n    empty: false\n}\n```\n\n## Object returned\n\nAdded values to the object are:\n\n- `matter`: **{String}** The raw front-matter string\n- `content`: **{String}** The contents of the file outside of the front-matter data\n- `date`: **{String}** The original date value\n- `dateObject`: **{Date}** The `date` value parsed onto a Javascript Date\n- `dateISO`: **{String}** The `date` value parsed and formatted into an ISO Date\n- `hash`: **{String}** This is the `md5` hash of the front-matter title (if supplied)\n- `lastupdated`: **{Date}** The last updated value of the file on the disk \n\n\u003e Note: When using the `file` API more options are returned. Eg: `file` (the input file path) and `lastupdated` (the last updated date of the file on the disk)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvautin%2Fsmart-matter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrvautin%2Fsmart-matter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvautin%2Fsmart-matter/lists"}