npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

camilaf-md-links

v0.1.1

Published

* [1. Proyect summary](#1-Proyect-summary) * [2. Library technical documentation](#2-Library-technical-documentation) * [3. Use and Installation guide](#3-Use-and-Installation-guide)

Downloads

1

Readme

Markdown Links

Index

1. Proyect summary

This library is created using Node.js, which allows reading and analyzing files in Markdown format, where the links found are extracted for validation and report some basic statistics.

The program is executable through a CLI, and its programming is based on promises and recursion.

2. Library technical documentation

2.1 JavaScript API

mdLinks(path, options)

Arguments
  • path: Absolute or relative path to the file or directory. If the path passed is relative, it should resolve to relative to the directory where node is invoked from - current working directory).
  • options: An object with only the following properties:
    • validar: Boolean that determines if you want to validate the links found.
    • stats: Boolean that determines if you want to get an output with general statistical information.
Return value

The function must return a promise (Promise) that resolves to an array (Array) of objects (Object), where each object represents a link and contains the properties.

2.2 CLI (Command Line Interface)

To run md-links in the terminal, it must be entered as follows: md-links <path-to-file> [options]

The Md-links program receives a relative or absolute path as the first parameter and allows the following options as input.

  • Validate
  • Stats

When entering only the path, the result will be the path, the link and the link text.

For example: With validate: false:

  • href: URL found.
  • text: Text that appears inside the link (<a>).
  • file: Path of the file where the link was found.
Options
--validate

If you enter the --validate option, the module must make an HTTP request to find out if the link works or not. If the link results in a redirect to a URL that responds ok or fail. ( Validate:true )

With validate:true :

  • href: URL found.
  • text: Text that appears inside the link (<a>).
  • file: Path of the file where the link was found.
  • status: HTTP response code.
  • ok: Message fail on failure or ok on success.

For example:

$ 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
--stats

If you enter the --stats option the output will be a text with basic statistics about the links.

$ md-links ./some/example.md --stats
Total: 3
Unique: 3

Also if you enter --stats and --validate you can get statistics that need the validation results. you need from the validation results.

$ md-links ./some/example.md --stats --validate
Total: 3
Unique: 3
Broken: 1

3. Use and Installation guide

Write the command line run bellow to install the module:

npm i camilaf-md-links

This module includes an executable as an interface that can be imported with require.

 const {mdLinks} = require('camilaf-md-links')

To run it from the CLI:

md-links <path-to-file> [options]