Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including check-seo with all npm packages installed. Try it out:

var checkSeo = require("check-seo")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

check-seo v1.0.2

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.

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);
});

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free