ccss-md-links
v1.5.3
Published
Test create md-links library
Downloads
4
Readme
ccss-md-links
JavaScript API
mdLinks(path [, options])
Arguments
- path: You can pass absolute or relative path of your directory or file.
- options: Is an object with this values:
validate
: Is a boolean value for active validate links in your files.
Return value:
You get a (Promise
), when you resolved it you get an (Array
) of (Object
) with this values:
href
: URL from links in markdown filestext
: Text from links in markdown filesfile
: Path of the file where the link was found
Example
// ES6
import mdLinks from "ccss-md-links";
// CommonJS
const mdLinks = require("ccss-md-links");
mdLinks("./some/example.md")
.then((links) => {
// => [{ href, text, file }]
})
.catch(console.error);
mdLinks("./some/example.md", { validate: true })
.then((links) => {
// => [{ href, text, file, status, statusText }]
})
.catch(console.error);
mdLinks("dir")
.then((links) => {
// => [{ href, text, file }]
})
.catch(console.error);
CLI (Command Line Interface - Interfaz de Línea de Comando)
You can install CLI locally or globally:
$ npm install ccss-md-links
$ npm install -g ccss-md-links
Now, you can try whith this command:
$ ccss-md-links <path-to-file> [options]
You can try with npx in Windows OS:
$ npx ccss-md-links <path-to-file> [options]
For example:
$ ccss-md-links ./some/example.md
./some/example.md http://algo.com/2/3/ Link a algo
./some/example.md https://otra-cosa.net/algun-doc.html algún doc
./some/example.md http://google.com/ Google
OPTIONS
-v | --validate
You can pass validate option for check and validate all links in your file or files markdown:
$ ccss-md-links ./some/example.md -v
$ ccss-md-links ./some/example.md --validate
./some/example.md http://algo.com/2/3/ ok 200 Link a algo
./some/example.md https://otra-cosa.net/algun-doc.html fail 404 algún doc
./some/example.md http://google.com/ ok 301 Google
-s | --stats
You can pass stats option for get information about all links in your file or files markdown:
$ ccss-md-links ./some/ -s
$ ccss-md-links ./some/example.md --stats
Total: 3
Unique: 3
-v -s | --validate --stats
You can pass both option and get more information about all links in your file or files markdown:
$ ccss-md-links some -v -s
$ ccss-md-links some/example.md --validate --stats
Total: 3
Unique: 3
Broken: 1