0.0.1 • Published 6 years ago

check4seo v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

check SEO defect in HTML

Install

npm i -g check4seo

Launch the command line tool.

check4seo web.html
curl www.google.com | check4seo

You could fork rules and customize it.

check4seo --fork config.yml
# edit config.yml ...
check4seo --config config.yml web.html

configuration

rules

A rule is described by three part, a data selector, a condition, and a message.

rules:
- count: head title
  if: {count: {$ne: 1}}
  message: title count {{count}} != {{if.count.$ne}}

For example, this rule select head title by the css selector and count the number of elements selected, then it check by the if: {count: {$ne: 1}}. The condition object is a subset of mongodb query conditions, see sift for more details. If this statement is true, the specified message will be emitted. The message construction will based on the rule object and the result of selector, so you could use these variables to construct the messages.

There are another select type select

rules:
- select: head meta[name="description"]
  if: {attribs.content.length: {$not: {$and: [{$gte: 80}, {$lt: 160}]}}}
  message: description length {{attribs.content.length}}

The same as count, it will select elements from html document. But this time it will pass all elements to the condition filter. Any construct a massage for each matched elements.

Add disable: true to temperary disable the rule and add debug: true for debug messages.

reporter

reporter section set the output destination, the default is outputto the standard output. And you could change it to a file name, for example

reporter:
    output: result.txt

extends DefectRule

In the configuration, we could not write functions to manipulate the dom nodes. You could write new helper class to achieve this. For example:

const DefectRule = require('../defect-rule');
class DefectRuleTextLength extends DefectRule {
    mapper(doc, els) {
        return els.map((i, el) => {
            return {length: doc(el).text().length, el: el};
        });
    }
}
module.exports = DefectRuleTextLength;

save it to lib/rules/rule-text-length.js, and it could be used in rule configuration.

- class: rule-text-length
  select: head title
  if: {length: {$gt: 60}}
  message: Title length more than {{if.length.$gt}} characters