{"_id":"@certible/remark-links-extractor","name":"@certible/remark-links-extractor","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@certible/remark-links-extractor","type":"module","version":"1.0.0","description":"Remark plugin to extract internal, external and hash links from parsed AST markdown","author":{"name":"Certible","email":"oberreiter@certible.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/certible/remark-links-extractor.git"},"bugs":{"url":"https://github.com/certible/remark-links-extractor/issues"},"keywords":["remark","markdown","astro","mdx"],"sideEffects":false,"exports":"./index.js","main":"index.js","engines":{"node":">=20.0.0"},"scripts":{"lint":"eslint .","lint:fix":"npm run lint --fix","build":"tsc --build --clean && tsc --build","test":"npm run build && node --test"},"dependencies":{"github-slugger":"2.0.0","hast-util-from-html":"2.0.3","hast-util-has-property":"3.0.0","is-absolute-url":"4.0.1","mdast-util-mdx-jsx":"3.2.0","mdast-util-to-string":"4.0.0","unist-util-visit":"5.0.0"},"devDependencies":{"@antfu/eslint-config":"^3.9.2","eslint":"^9.15.0","remark":"15.0.1","remark-parse":"11.0.0","typescript":"5.7.3","vitest":"3.0.7"},"_id":"@certible/remark-links-extractor@1.0.0","gitHead":"d273b7de48966ebdb0a659ef845f64727957f10a","types":"./index.d.ts","homepage":"https://github.com/certible/remark-links-extractor#readme","_nodeVersion":"18.19.1","_npmVersion":"10.9.0","dist":{"integrity":"sha512-jjlWPIEFJ2m+7Ijf98WnnNn0ufSofdznvS1Cuycad2W9IpcdsQIQYoTtJAnGybUC2KjpDMMbXrRDR7i+dZywXQ==","shasum":"1616fd2c5b5bd1304e9f7cf4970c6385f910c1f1","tarball":"https://registry.npmjs.org/@certible/remark-links-extractor/-/remark-links-extractor-1.0.0.tgz","fileCount":7,"unpackedSize":16422,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCKoRpObnVvH8mLzq8ucusAfcqbzT7z7ly1gngMP04cJwIhAOLgyaPO83aw9/9KjToqCLCDsf/Brb6BV/wWVYw14ulP"}]},"_npmUser":{"name":"oberreiter","email":"oberreiter@certible.com"},"directories":{},"maintainers":[{"name":"oberreiter","email":"oberreiter@certible.com"},{"name":"alexanderfeder","email":"npm@certible.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/remark-links-extractor_1.0.0_1741075099166_0.1295906680641583"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-04T07:58:19.113Z","1.0.0":"2025-03-04T07:58:19.307Z","modified":"2025-03-04T07:58:19.522Z"},"maintainers":[{"name":"oberreiter","email":"oberreiter@certible.com"},{"name":"alexanderfeder","email":"npm@certible.com"}],"description":"Remark plugin to extract internal, external and hash links from parsed AST markdown","homepage":"https://github.com/certible/remark-links-extractor#readme","keywords":["remark","markdown","astro","mdx"],"repository":{"type":"git","url":"git+https://github.com/certible/remark-links-extractor.git"},"author":{"name":"Certible","email":"oberreiter@certible.com"},"bugs":{"url":"https://github.com/certible/remark-links-extractor/issues"},"license":"MIT","readme":"# @certible/remark-link-extractor\n\nRemark plugin to extract internal, external, and hash links from markdown. This remark plugin is **module only** and does not support CommonJS. Ensure your project is configured to use ES modules.\n\nWe @[certible.com](https://www.certible.com) use this plugin to check for broken links in our markdown content after an automated build of our Astro site.\n\n## Installation\n\n```sh\nnpm install @certible/remark-links-extractor\n```\n\n## Usage\n\n```javascript\nimport { getData, remarkLinksExtractor } from '@certible/remark-links-extractor';\nimport { remark } from 'remark';\nimport remarkParse from 'remark-parse';\n\nconst markdown = `\n# Heading 1\n\n[Internal Link](/internal)\n[External Link](https://example.com)\n`;\n\nremark()\n .use(remarkParse)\n .use(remarkLinkExtractor)\n .process(markdown, (err, file) => {\n  if (err)\n   throw err;\n  const data = getData();\n  console.log(data);\n });\n```\n\n## Plugin Options\n\n### `astroIgnoreDraft`\n\nType: `boolean`\nDefault: `false`\n\nWhether to ignore draft files if declared in Astro frontmatter.\n\n### `astroUseSlug`\n\nType: `boolean`\nDefault: `false`\n\nWhether to use the slug from Astro frontmatter and not the file path as the key.\n\n### `createHeadingsSlug`\n\nType: `boolean`\nDefault: `false`\n\nWhether to create a slug from the heading text if no `id` attribute is present, if `true` it will use `github-slugger` to create a slug from the heading text.\n\n### `resetDataOnRun`\n\nType: `boolean`\nDefault: `false`\n\nWhether to reset the data collections before processing a new file.\n\n### Method `getData()`\n\nReturns the extracted link data.\n\n#### Returns\n\nAn object containing the following properties, as `Record<string, []string>`. The keys are the file path or slug if `astroUseSlug` is `true`. If no file path or slug is available, the key will be an ordered number.\n\n- `headings`: Record of headings extracted from the markdown files.\n- `internalLinks`: Record of internal links extracted from the markdown files.\n- `externalLinks`: Record of external links extracted from the markdown files.\n\n### Method `resetData()`\n\nResets the extracted link data.\n\n## License\n\nMIT License. See [LICENSE](./LICENSE) for more information.\n","readmeFilename":"README.md"}