1.2.0 • Published 6 years ago

seo-validate-tool v1.2.0

Weekly downloads
10
License
GPL-2.0
Repository
github
Last release
6 years ago

seo-validate-tool

A Node.js package for scan HTML contents and show SEO defects

build status

Installation

npm install seo-validate-tool

Input And Output

The validator supports 2 types of input objects and 3 types output objects

Input Type

  • FileInput
  • StreamInput

Output Type

  • FileOutput
  • StreamOutput
  • ConsoleOutput

Usage & Demo

Please refer to examples in examples folder, and check run_examples.sh, example1.js, and example1.js for the details.

Example

const {
  RuleBase,
  RuleTagWithoutAttribute,
  RuleBasetagWithoutTag,
  RuleBasetagWithoutTagAttributeValue,
  RuleTagCountLimit,
  Validator,
  IoBase,
  FileInput,
  StreamInput,
  FileOutput,
  StreamOutput,
  ConsoleOutput
} = require('seo-validate-tool')

var skipRules = [1, 4];  // rule index for skipping 
var validator = new Validator(skipRules);

// A defined object "someReadableStream"
var input = new StreamInput(someReadableStream);
var output = new ConsoleOutput();

// Set up input/output
validator.setInput(input);
validator.setOutput(output);

// Validate
validator.validate()

Run Demo

$ ./examples/run_examples.sh

Pre-defined SEO Rules

  1. Detect if any <img /> tag without alt attribute
  2. Detect if any <a /> tag without rel attribute
  3. In <head> tag
    1. Detect if header doesn’t have <title> tag
    2. Detect if header doesn’t have <meta name=“descriptions” ... /> tag
    3. Detect if header doesn’t have <meta name=“keywords” ... /> tag
  4. Detect if there’re more than 15 <strong> tag in HTML (15 is a value should be configurable by user)
  5. Detect if a HTML have more than one <H1> tag.

Skip Rules

Create Validator with skipRules can define which rules to skip.

var skipRules = [1, 4];  // rule index for skipping 
var validator = new Validator(skipRules);

Customized rules

  1. Define customized rules by
    • class RuleBase
    • class RuleTagWithoutAttribute
    • class RuleBasetagWithoutTag
    • class RuleBasetagWithoutTagAttributeValue
    • class RuleTagCountLimit
  2. Use Validator.addRule() to add customized rules
// Add a basic customized rule: RuleHeaderWithoutAuthor
const RuleHeaderWithoutAuthor = new RuleBasetagWithoutTagAttributeValue('head', 'meta', 'name', 'author')
validator.addRule(RuleHeaderWithoutAuthor)
1.2.0

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago