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

sj-mdlinks

v1.1.1

Published

Validator of links contained only in md files

Downloads

18

Readme

Markdown Links

Índice

Descripción

sj-mdlinks es una libreria que usa Node.js Contiene una función recursiva que recibe como parámetro una ruta, localiza todos los archivos con extensión .md que esten dentro de la ruta proporcionada (incluyendo subdirectorios), verifica los links que contenga cada archivo, valida su status (ok, fail) y calcula estadisticas básicas sobre los links (totales, únicos y rotos).


Homepage

Github StephanieJolianis


Diagrama de flujo


Instalación y uso (CLI)

Linux o MacOS

$ sudo npm i -g sj-mdlinks

Microsoft Windows

$ npm i -g sj-mdlinks

Ejecución de comandos:

Puedes ejecutar la aplicación de la siguiente manera a través de la terminal md-links [options]

Por ejemplo:
  • Para obtener links

Aquí puedes utilizar una ruta de un archivo con una extensión .md o una ruta de un directorio.

Comando:

$ mdlinks hola.md

Retorno:

[ { file: '/home/stephanie/Escritorio/pruebas-mdlinks/hola.md',
    href: 'https://www.npmjs.com/package/sj-mdlinks',
    text: 'Stephanie' },
  { file: '/home/stephanie/Escritorio/pruebas-mdlinks/hola.md',
    href: 'https://otra-cosa.net/algun-doc.html',
    text: 'Link roto' } ]
  • Options
--validate

Si pasas la opción --validate, el módulo hace una petición HTTP para averiguar si el link funciona o no. Si el link resulta en una redirección a una URL que responde ok, entonces se considera el link como ok.

Comando:

$ mdlinks hola.md --validate

Retorno:

[ { href: 'https://www.npmjs.com/package/sj-mdlinks',
    text: 'Stephanie',
    file: '/home/stephanie/Escritorio/pruebas-mdlinks/hola.md',
    code: 200,
    status: 'OK' },
  { href: 'https://otra-cosa.net/algun-doc.html',
    text: 'Link roto',
    file: '/home/stephanie/Escritorio/pruebas-mdlinks/hola.md',
    code: 404,
    status: 'FAIL' } ]
--stats

Si pasas la opción --stats el output será un texto con estadísticas básicas sobre los links.

Comando:

$ mdlinks hola.md --stats

Retorno:

[ total: 2, unique: 2 ]

También puedes combinar --stats y --validate para obtener estadísticas que necesites de los resultados de la validación.

Comando:

$ mdlinks hola.md --validate --stats

Retorno:

[ total: 2, unique: 2, broken: 1, ok: 1 ]

Instalación y uso (MÓDULO)

Instalar como dependencia npm

$ npm i sj-mdlinks

Ejemplo uso del módulo


const mdlinks = require("sj-mdlinks");

//Obtener datos de un archivo .md [{ href, text, file }]
mdlinks("./some/example.md", { validate: false, stats: false})
  .then(links => {
    console.log(links)
  })
  .catch(console.error);

//Obtener links validados [{ href, text, file, status, ok }]
mdlinks("./some/example.md", { validate: true, stats: false })
  .then(links => {
    console.log(links)
  })
  .catch(console.error);

//Obtener estadísticas [{ total, unique }]
mdlinks("./some/example.md", { validate: false, stats: true })
  .then(links => {
    console.log(links)
  })
  .catch(console.error);

//Obtener estadísticas y validación de links [{ total, unique, broken, ok }]
mdlinks("./some/example.md", { validate: true, stats: true })
  .then(links => {
    console.log(links)
  })
  .catch(console.error);

Objetivos de aprendizaje

JavaScript

  • [x] Uso de condicionales (if-else | switch | operador ternario)
  • [x] Uso de funciones (parámetros | argumentos | valor de retorno)
  • [x] Manipular arrays (filter | map | sort | reduce)
  • [x] Manipular objects (key | value)
  • [x] Uso ES modules (import | export)
  • [x] Diferenciar entre expression y statements.
  • [x] Diferenciar entre tipos de datos atómicos y estructurados.
  • [x] Uso de callbacks.
  • [x] Consumo de Promesas.
  • [x] Creación de Promesas.

Node

Testing

Estructura del código y guía de estilo

  • [x] Organizar y dividir el código en módulos (Modularización)
  • [ ] Uso de identificadores descriptivos (Nomenclatura | Semántica)
  • [ ] Uso de linter (ESLINT)

Git y GitHub

  • [x] Uso de comandos de git (add | commit | pull | status | push)
  • [x] Manejo de repositorios de GitHub (clone | fork | gh-pages)
  • [ ] Colaboración en Github (branches | pull requests | |tags)
  • [x] Organización en Github (projects | issues | labels | milestones)

HTTP

Fundamentos de programación


Checklist

General

  • [x] Puede instalarse via npm install --global <github-user>/md-links

README.md

  • [x] Un board con el backlog para la implementación de la librería.
  • [x] Documentación técnica de la librería.
  • [x] Guía de uso e instalación de la librería

API mdLinks(path, opts)

  • [x] El módulo exporta una función con la interfaz (API) esperada.
  • [x] Implementa soporte para archivo individual
  • [x] Implementa soporte para directorios
  • [x] Implementa options.validate

CLI

  • [x] Expone ejecutable md-links en el path (configurado en package.json)
  • [x] Se ejecuta sin errores / output esperado
  • [x] Implementa --validate
  • [x] Implementa --stats

Pruebas / tests

  • [x] Pruebas unitarias cubren un mínimo del 70% de statements, functions, lines, y branches.
  • [x] Pasa tests (y linters) (npm test).