check-seo

1.0.2 • Public • Published

SeoCheck

SeoCheck module is build to check if there is/are any irregularites in your HTML file. You can customise your own set of rules to check if your end requirements are met.

npm npm

Install via npm

npm i check-seo
npm test

Usage

Load all the modules

const fs = require('fs');
const {Configure, Rule, Writer, Reader} = require('check-seo');
 
// Or load individual modules 
const Configure = require('check-seo').Configure;
const Rule = require('check-seo').Rule;
const Writer = require('check-seo').Writer;
const Reader = require('check-seo').Reader;

Rules Available

RuleAllContainTagAttribute(parentTag, tagSearch, attributeSearch, valueSearch(optional))
RuleMaxTagAttribute(parentTag, tagSearch, attributeSearch, valueSearch or '', maxCount)
RuleExistsTagAttribute(parentTag, tagSearch, attributeSearch, valueSearch(optional))
RuleMaxTag(parentTag, tagSearch, maxCount)
RuleExistsTag(parentTag, tagSearch)

Example

// To write data to console 
var writeConsole = new Writer.writeConsole()
// To write data to file
var writeFile = new Writer.writeFile('path/to/outputfile');
// To write data to file stream
var writeFilestream = new Writer.writeStream(fs.createWriteStream('path/to/outputfile'));
 
var rules = [];
//Check if all tag contains attribute eg. all <img> contain alt attribute
rules.push(new Rule.RuleAllContainTagAttribute('', 'img', 'alt'));
 
//Check <img alt> tag count greater than 4 
rules.push(new Rule.RuleMaxTagAttribute('', 'img', 'alt', '' ,4));
 
//check parent contains <tag attribute> eg: body containg <img alt>
rules.push(new Rule.RuleExistsTagAttribute('body', 'img', 'rel'));
 
//check parent contains <tag attribute=value> eg: head contains  <meta name="keywords">
rules.push(new Rule.RuleExistsTagAttribute('head', 'meta', 'name', 'keywords'));
 
//check if parent contains <tag> eg: body conatins <img>
rules.push(new Rule.RuleExistsTag('body', 'img'));
 
//check tag count: parent contains <tag> eg: body conatins <img>
rules.push(new Rule.RuleMaxTag('', 'strong',5))
 
 
var config1 = new Configure(new Reader.readStream(fs.createReadStream(path/to/input)), writeConsole, rules);
 
config1.validate(function(err, data){
      console.log(err);
      console.log(data);
});
 

Readme

Keywords

Package Sidebar

Install

npm i check-seo

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

379 kB

Total Files

16

Last publish

Collaborators

  • murtuza007