{"id":17590970,"url":"https://github.com/stafyniaksacha/metalsmith-algolia","last_synced_at":"2025-04-29T10:35:55.812Z","repository":{"id":57295476,"uuid":"98430703","full_name":"stafyniaksacha/metalsmith-algolia","owner":"stafyniaksacha","description":"A metalsmith plugin for indexing content on Algolia","archived":false,"fork":false,"pushed_at":"2018-09-05T10:09:52.000Z","size":616,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T13:43:03.949Z","etag":null,"topics":["algolia","instant-search","metalsmith","search-engine"],"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/stafyniaksacha.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":"2017-07-26T14:15:16.000Z","updated_at":"2020-09-18T09:03:13.000Z","dependencies_parsed_at":"2022-08-26T13:30:25.095Z","dependency_job_id":null,"html_url":"https://github.com/stafyniaksacha/metalsmith-algolia","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-algolia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-algolia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-algolia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-algolia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stafyniaksacha","download_url":"https://codeload.github.com/stafyniaksacha/metalsmith-algolia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251484717,"owners_count":21596799,"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":["algolia","instant-search","metalsmith","search-engine"],"created_at":"2024-10-22T04:43:49.301Z","updated_at":"2025-04-29T10:35:55.786Z","avatar_url":"https://github.com/stafyniaksacha.png","language":"JavaScript","funding_links":[],"categories":["Community Integrations"],"sub_categories":[],"readme":"- [Installation](#installation)\n- [Usage](#usage)\n  - [Javascript API](#javascript-api)\n  - [Templates metadata](#templates-metadata)\n  - [Indexed document](#indexed-document)\n- [Customize indexed documents](#customize-indexed-documents)\n- [Options reference](#options-reference)\n- [Todolist](#todolist)\n\n# metalsmith-algolia\n\n\u003e A metalsmith plugin for indexing content on Algolia\n\nThis plugin allows you to index your content in Algolia search engine on metalsmith building process.\n\n_If this plugin doesn't fit your needs, please don't hesitate to ask for feature requests._\n\n## Installation\n```bash\nnpm install --save metalsmith-algolia\n```\n\n## Usage\n\n\n#### Javascript API\n\nThe exemple bellow show the minimum code required to index your content. _(node: metalsmith-markdown is not required)_\n\n```js\nconst metalsmith = require('metalsmith');\nconst markdown = require('metalsmith-markdown');\nconst algolia = require('metalsmith-algolia');\n\nmetalsmith(__dirname)\n  .source('./src')\n  .use(markdown())\n  .use(algolia({\n    projectId: '\u003calgolia-project-id\u003e',\n    privateKey: '\u003calgolia-private-key\u003e',\n    index: '\u003calgolia-index\u003e'\n  }))\n  .build();\n```\n\u003e please, use command line arguments or environement variables to store your algolia private key\n\n#### Templates metadata\n\nHere is an exemple with a fake markdown template `./src/mypage.md`\n\n```markdown\n---\ntitle: My awesome static page !\ndescription: This is a exemple page\nalgolia: true\n---\n# My awesome static page !\ncontent exemple\n```\n\n#### Indexed document\n\nBy default, metadata _(string/boolean/integers)_ and contents will be sent to Algolia for all files with `algolia: true` metadata  \nWith this exemple, the generated document will look like:\n\n```json\n{\n  \"title\": \"My awesome static page !\",\n  \"description\": \"This is a exemple page\",\n  \"contents\": \"\u003ch1\u003eMy awesome static page !\\n\u003cp\u003econtent exemple\u003c/p\u003e\"\n}\n```\n\n\n## Customize indexed documents\n\nIf you need to cleanup your contents, compute additional fields, or remove metadata from indexing, you can use the `fileParser` option to plugin constructor to give a custom callback to generate your own documents:\n\n\n```js\nconst metalsmith = require('metalsmith');\nconst markdown = require('metalsmith-markdown');\nconst algolia = require('metalsmith-algolia');\nconst cheerio = require('cheerio');\n\nfunction customFileParser(file, metadata) {\n  let documents = [];\n  let $ = cheerio.load(metadata.contents.toString());\n\n  // add as many as documents as you need\n  documents.push({\n    title: metadata.title,\n    contents: $('p').text();\n  })\n\n  return documents;\n}\n\nmetalsmith(__dirname)\n  .source('./src')\n  .use(markdown())\n  .use(algolia({\n    projectId: '\u003calgolia-project-id\u003e',\n    privateKey: '\u003calgolia-private-key\u003e',\n    index: '\u003calgolia-index\u003e',\n    fileParser: customFileParser\n  }))\n  .build();\n```\n\nThis time, the generated document will look like:\n\n```json\n{\n  \"title\": \"My awesome static page !\",\n  \"contents\": \"content exemple\"\n}\n```\n\n## Options reference\n| name   |  default  |  description  |\n| --- | --- | --- |\n| `projectId` |  | *(required)* Algolia project identifier |\n| `privateKey` |  | *(required)* Algolia private key |\n| `index` |  | *(required)** Algolia index |\n| `clearIndex` | false | Clear Algolia index before indexing new documents |\n| `fileParser` | null | Function reference to a custom handler for building documents |\n| `pattern` | **/\\* | Glob pattern to match input files against. Can be an array or a single string |\n\n\u003e *hint: metalsmith-algolia use `debug`*\n\n## Todolist\n\n- [ ] Add tests/linter\n- [ ] Add travis configuration\n- [ ] Try bulk operations (without fail fast)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-algolia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-algolia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-algolia/lists"}