{"id":19324355,"url":"https://github.com/unifiedjs/unified-infer-git-meta","last_synced_at":"2025-04-22T19:32:37.232Z","repository":{"id":57386245,"uuid":"404693842","full_name":"unifiedjs/unified-infer-git-meta","owner":"unifiedjs","description":"unified plugin to infer some `meta` from Git","archived":false,"fork":false,"pushed_at":"2023-08-30T11:42:45.000Z","size":61,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-10T19:49:51.925Z","etag":null,"topics":["git","meta","rehype","unified","unified-plugin","unifiedjs"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","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/unifiedjs.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,"governance":null}},"created_at":"2021-09-09T11:21:54.000Z","updated_at":"2025-02-17T06:11:06.000Z","dependencies_parsed_at":"2022-09-02T00:42:22.235Z","dependency_job_id":"9f9e1bdb-3c9b-4949-a4a4-13dfbf7b9f3a","html_url":"https://github.com/unifiedjs/unified-infer-git-meta","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"fd410aff422f5582c7e59f704e76f922c7016cb7"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-infer-git-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-infer-git-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-infer-git-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-infer-git-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unifiedjs","download_url":"https://codeload.github.com/unifiedjs/unified-infer-git-meta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249711388,"owners_count":21314227,"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":["git","meta","rehype","unified","unified-plugin","unifiedjs"],"created_at":"2024-11-10T02:04:49.967Z","updated_at":"2025-04-22T19:32:37.195Z","avatar_url":"https://github.com/unifiedjs.png","language":"JavaScript","funding_links":["https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# unified-infer-git-meta\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[unified][]** plugin to infer file metadata from Git of a document.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`unified().use(unifiedInferGitMeta, options?)`](#unifieduseunifiedinfergitmeta-options)\n    *   [`Format`](#format)\n    *   [`Options`](#options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a [unified][] plugin to infer when content was first published,\nlast modified, and who contributed to it, from Git.\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**vfile** is the virtual file interface used in unified.\nThis is a unified plugin that extracts metadata from Git and exposes it on the\nvfile.\n\n## When should I use this?\n\nThis plugin is particularly useful in combination with\n[`rehype-meta`][rehype-meta].\nWhen both are used together, output such as the following is generated:\n\n```html\n\u003cmeta name=\"copyright\" content=\"© 2019 Jane\"\u003e\n\u003cmeta name=\"author\" content=\"Jane\"\u003e\n\u003c!-- … --\u003e\n\u003cmeta property=\"article:published_time\" content=\"2019-12-02T10:00:00.000Z\"\u003e\n\u003cmeta property=\"article:modified_time\" content=\"2019-12-03T19:13:00.000Z\"\u003e\n```\n\nThe downside is that Git might be sparesely cloned when building a website,\nmeaning that only the last commit is available, which means that this plugin\ncannot find all data.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unified-infer-git-meta\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport unifiedInferGitMeta from 'https://esm.sh/unified-infer-git-meta@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import unifiedInferGitMeta from 'https://esm.sh/unified-infer-git-meta@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay our module `example.js` looks as follows:\n\n```js\nimport rehypeDocument from 'rehype-document'\nimport rehypeFormat from 'rehype-format'\nimport rehypeMeta from 'rehype-meta'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\nimport unifiedInferGitMeta from 'unified-infer-git-meta'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(unifiedInferGitMeta)\n  .use(remarkRehype)\n  .use(rehypeDocument)\n  .use(rehypeMeta, {\n    // Published and modified are only added if these two are also defined:\n    og: true,\n    type: 'article'\n  })\n  .use(rehypeFormat)\n  .use(rehypeStringify)\n  .process(await read('readme.md'))\n\nconsole.log(file.data)\nconsole.log(String(file))\n```\n\n…now running `node example.js` yields:\n\n```js\n{\n  meta: {\n    author: 'Titus Wormer',\n    modified: new Date('2023-08-24T10:13:50.000Z'),\n    published: new Date('2021-09-09T11:22:32.000Z')\n  }\n}\n```\n\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003ereadme\u003c/title\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n    \u003cmeta name=\"author\" content=\"Titus Wormer\"\u003e\n    \u003cmeta property=\"og:type\" content=\"article\"\u003e\n    \u003cmeta property=\"article:published_time\" content=\"2021-09-09T11:22:32.000Z\"\u003e\n    \u003cmeta property=\"article:modified_time\" content=\"2023-08-24T10:13:50.000Z\"\u003e\n  \u003c/head\u003e\n  …\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`unifiedInferGitMeta`][api-unified-infer-git-meta].\n\n### `unified().use(unifiedInferGitMeta, options?)`\n\nPlugin to infer some `meta` from Git.\n\nThis plugin sets [`file.data.meta.published`][meta-published] to the date a\nfile was first committed, [`file.data.meta.modified`][meta-modified] to the\ndate a file was last committed, and [`file.data.meta.author`][meta-author] to\nan abbreviated list of top authors of the file.\n\n###### Parameters\n\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nTransform ([`Transformer`][transformer]).\n\n### `Format`\n\nFormat function (TypeScript type).\n\n###### Parameters\n\n*   `authors` (`Iterable\u003cstring\u003e`)\n    — list of authors\n\n###### Returns\n\nFormatted authors (`string`).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `authorRest` (`string`, default: `'others'`)\n    — text to use to label more authors when abbreviating\n*   `format` ([`Format`][api-format], default: `format` of\n    `Intl.ListFormat(locales)`)\n    — alternative format function to use; if the authors had to be abbreviated,\n    the last author is instead replaced by `authorRest`; set `limit: -1` to\n    receive all author names\n*   `limit` (`number`, default: `3`)\n    — max number of authors to include; set to `-1` to not limit authors\n*   `locales` (`Array\u003cstring\u003e` or `string`, default: `'en'`)\n    — locale(s) to use to join authors and sort their names\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types\n[`Format`][api-format] and\n[`Options`][api-options].\n\nIt also registers the `file.data.meta` fields with `vfile`.\nIf you’re working with the file, make sure to import this plugin somewhere in\nyour types, as that registers the new fields on the file.\n\n```js\n/**\n * @typedef {import('unified-infer-git-meta')}\n */\n\nimport {VFile} from 'vfile'\n\nconst file = new VFile()\n\nconsole.log(file.data.meta.published) //=\u003e TS now knows that this is a `Date?`.\n```\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`unified-infer-git-meta@^2`, compatible with Node.js 16.\n\n## Related\n\n*   [`rehype-meta`](https://github.com/rehypejs/rehype-meta)\n    — add metadata to the head of a document\n*   [`rehype-infer-title-meta`](https://github.com/rehypejs/rehype-infer-title-meta)\n    — infer file metadata from the title of a document\n*   [`rehype-infer-description-meta`](https://github.com/rehypejs/rehype-infer-description-meta)\n    — infer file metadata from the description of a document\n*   [`rehype-infer-reading-time-meta`](https://github.com/rehypejs/rehype-infer-reading-time-meta)\n    — infer file metadata from the reading time of a document\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`unifiedjs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/unifiedjs/unified-infer-git-meta/workflows/main/badge.svg\n\n[build]: https://github.com/unifiedjs/unified-infer-git-meta/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/unifiedjs/unified-infer-git-meta.svg\n\n[coverage]: https://codecov.io/github/unifiedjs/unified-infer-git-meta\n\n[downloads-badge]: https://img.shields.io/npm/dm/unified-infer-git-meta.svg\n\n[downloads]: https://www.npmjs.com/package/unified-infer-git-meta\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/unifiedjs/unified/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[health]: https://github.com/unifiedjs/.github\n\n[contributing]: https://github.com/unifiedjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/unifiedjs/.github/blob/main/support.md\n\n[coc]: https://github.com/unifiedjs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[unified]: https://github.com/unifiedjs/unified\n\n[transformer]: https://github.com/unifiedjs/unified#transformer\n\n[rehype-meta]: https://github.com/rehypejs/rehype-meta\n\n[meta-published]: https://github.com/rehypejs/rehype-meta#configpublished\n\n[meta-modified]: https://github.com/rehypejs/rehype-meta#configmodified\n\n[meta-author]: https://github.com/rehypejs/rehype-meta#configauthor\n\n[api-unified-infer-git-meta]: #unifieduseunifiedinfergitmeta-options\n\n[api-format]: #format\n\n[api-options]: #options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funifiedjs%2Funified-infer-git-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funifiedjs%2Funified-infer-git-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funifiedjs%2Funified-infer-git-meta/lists"}