{"id":31476070,"url":"https://github.com/stephanmax/metalsmith-slug","last_synced_at":"2025-10-02T00:54:53.823Z","repository":{"id":57295705,"uuid":"20792554","full_name":"stephanmax/metalsmith-slug","owner":"stephanmax","description":"Add a slug property to targeted files in Metalsmith","archived":false,"fork":false,"pushed_at":"2018-10-28T15:34:02.000Z","size":23,"stargazers_count":20,"open_issues_count":3,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T01:45:12.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/stephanmax.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}},"created_at":"2014-06-13T04:56:08.000Z","updated_at":"2020-06-14T20:10:52.000Z","dependencies_parsed_at":"2022-08-30T18:51:54.517Z","dependency_job_id":null,"html_url":"https://github.com/stephanmax/metalsmith-slug","commit_stats":null,"previous_names":["nsonnad/metalsmith-slug"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stephanmax/metalsmith-slug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanmax%2Fmetalsmith-slug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanmax%2Fmetalsmith-slug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanmax%2Fmetalsmith-slug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanmax%2Fmetalsmith-slug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephanmax","download_url":"https://codeload.github.com/stephanmax/metalsmith-slug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanmax%2Fmetalsmith-slug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277936836,"owners_count":25902302,"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","status":"online","status_checked_at":"2025-10-01T02:00:09.286Z","response_time":88,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-02T00:54:51.133Z","updated_at":"2025-10-02T00:54:53.816Z","avatar_url":"https://github.com/stephanmax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metalsmith slug\n\nAdd a `slug` property to the metadata for targeted files in your\n[Metalsmith](http://www.metalsmith.io/), based on a particular property.\nUseful for generating links to pages based on, say, their `title`.\n\n## Installation\n\n    npm install metalsmith-slug --save\n\n## Usage\n\nIf you're not familiar with Metalsmith, [check it out](http://metalsmith.io). It's a versatile file processor that can be used for static site generation,\nproject scaffolding and more. It can be interacted with via a CLI or\nJavaScript API.\n\n### Metalsmith CLI\n\nAdd `metalsmith-slug` to your `metalsmith.json`.\n\n```json\n{\n  \"plugins\": {\n    \"metalsmith-slug\": {}\n  }\n}\n```\n\n### Metalsmith JavaScript API\n\nAdd `metalsmith-slug` to your project and `.use()` it.\n\n```js\nvar slug = require('metalsmith-slug');\n\nmetalsmith.use(slug());\n```\n\n## Options\n\n**patterns** `Array`: Glob patterns of files to match. Uses\n[minimatch](https://github.com/isaacs/minimatch). Default: `[]`.\n\n```js\nmetalsmith.use(slug({\n  patterns: ['*.md', '*.rst'] // Defaults to all files\n}));\n```\n\n**property** `String`: Property to generate the slug from. Default: `title`.\n\n```js\nmetalsmith.use(slug({\n  property: 'name'\n}));\n```\n\n**renameFiles** `Boolean`: When set to `true`, will rename the files passed to\nmetalsmith-slug to the file's new slug property. Default: `false`.\n\n```js\nmetalsmith.use(slug({\n  renameFiles: true\n}));\n```\n\n**slug options**: You can additionally use any of the options available for [node-slug][node-slug-options].\n\n```js\n// This are the defaults for node-slug 'pretty' mode\nmetalsmith.use(slug({\n  replacement: '-',\n  symbols: true,\n  remove: /[.]/g,\n  lower: false,\n  charmap: [object Object], // slug.defaults.charmap\n  multicharmap: [object Object], // slug.defaults.multicharmap\n}));\n```\n\nAlternatively you can change the default node-slug mode:\n\n```\nmetalsmith.use(slug({\n  mode: 'rfc3986'\n}));\n```\n\n## Manual override\n\nAlso, it's possible to override the `slug` property in a single file.\nIf you define a `slug` in the front matter, the plugin won't replace it with a new one.\nHowever, it will apply the same [slug options][node-slug-options], if any.\n\n```yaml\n---\ntitle: Something\nslug: Something-Else\n---\ncontents...\n```\n\n```js\nmetalsmith.use(slug());              // =\u003e {slug: 'Something-Else', ...}\nmetalsmith.use(slug({lower: true})); // =\u003e {slug: 'something-else', ...}\n```\n\n## Tests\n\n`npm test` to run the tests.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Nikhil Sonnad\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n[node-slug-options]: https://github.com/dodo/node-slug#options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanmax%2Fmetalsmith-slug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanmax%2Fmetalsmith-slug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanmax%2Fmetalsmith-slug/lists"}