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

neo-seo

v1.0.1

Published

SEO detector with default 7 rules, and user can add custom rule or disable default rule.

Downloads

5

Readme

NeoSeo

SEO defects detector for node.js.

var NeoSeo = require('neo-seo')

var customConfigs =  [
  {
    'ruleName': 'Rule: link with rel',
    'tag': 'link',
    'attributeName': 'rel',
    'attributeType': 'with',
    'minimum': 0
  },
  {
    'ruleName': 'Rule: div with class d-flex'
    'root': 'body',
    'tag': 'div',
    'attributeName': 'class',
    'attributeValue': 'd-flex',
    'attributeType': 'with',
    'minimum': 2,
    'maximum': 8
  }
]
var disableList = [0, 1, 2]
var app = new NeoSeo(customConfigs, disableList)
// or use default settings
// var app = new NeoSeo()

var input = 'file_to_run_seo.html'
var output = 'export_report.txt'
app.getResult(input, output)

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

Installation is done using the npm install command:

$ npm install neo-seo

Features

  • Input could be a file (HTML or txt), a Node Readable Stream, or a URL (http or https).
  • Output coule be a file (string path), a Node Writable Stream, or a function such as Consoel.log.
  • Build-in seven seo rules, and user could turn-off some of them.
  • High flexibility custom rule by custom configuration setting.
  • High test coverage

Docs

Input

  • Use a file path as input:
    var input = 'file_to_run_seo.html'
  • Use a Node Readable Stream:
    var input = fs.CreateReadStream()
    or
    var input = new stream.Readable()
    input.push('some data need to run seo')
    input.push(null)
  • Use a URL
    var input = 'http://some-url.to.run.seo/'
    or
    var input = 'https://https-url.to.run.seo/'

Output

  • Use a file path as output:
    var output = 'export_file.txt'
  • Use a Node Writable Stream:
    var output = fs.CreateWriteStream()
    or
    var output = process.stdout
  • Use a Node function
    var output = console.log

Rule Configuration Setting

  • Template

    {
      'ruleName': 'The name of this rule',
      'root': 'head',
      'tag': 'meta',
      'attributeName': 'name',
      'attributeValue': 'descriptions',
      'attributeType': 'with',
      'minimum': null,
      'maximum': 1
    }
  • Property

    • ruleName: The name of this rule, which will show in the output message. User can use ruleName to disable default rules. (optional)
    • root: The html section this rule will apply. For example, head means only search the head, and body means only search the body. NULL means search the whole html file or data. (optional)
    • tag: Which html tag we want to find. (required)
    • attributeName: Which attribute in the tag we want to find. (optional)
    • attributeValue: Which value of the attribute we want to find. (optional)
    • attributeType: If we want to find the tag with specific attribute, use with here. Otherwise, use without to get the opposite results. (optional)
    • minimum and maximum: Use these two numbers to define when this rule will be effective. For example, 'minimum': null and 'maximum': 1 means we want to check if this html file (or data) has less than 1 match. These two numbers are exclusively!
  • Example

    • Using heading tag appropriately is good. We want to check if there are <h2> tags in <body> section, and we hope there is at least one <h2> tag, but no more than 5.
      {
        'ruleName': 'Rule H2',
        'root': 'body',
        'tag': 'h2',
        'minimum': 0,
        'maximum': 5
      }

Disabled List

  • Use an array to list which default rule(s) should be disabled.
// disable the rule number 1, 2, 3 in default rules.
let disabledList = [1, 2, 3]
// disable the rule by rule name.
let disabledList = ['No <title> tag in <haed>', '<img /> tag without alt attribute']

Tests

$ npm install
$ npm test

ToDo

  • More integration test cases about different input and output.
  • More efficient way to parse html file (or data). I try to use regular expression, it runs more quickly than cheerio.js (run some benchmarks). But I encountered problem in tags or attributes with line breaker. Some other npm packages which are used to parse html have the same problem.
  • Better architecture...maybe after I study these three topics, I can it better.
    • EventEmitter
    • Stream
    • Design Patterns in Node.js