node-seo-defects
v1.0.9
Published
Scan a HTML file and show all of the SEO defects
Downloads
7
Readme
node-seo-defects
Scan a HTML file and show all of the SEO defects
Installation
npm install node-seo-defects
Config
If you assign your own yml, write the absolute path at filePath of input, ouput
input:
filePath: "/../test/html/RuleCheckerCase1.html" #file location of your html
output:
type: "console" #console or file
filePath: "/../output/report.txt" #if type is file, set the file location of output file
rules:
TagWithoutAttribute:
- img: alt
- a: rel
TagDoesnotHaveTag:
- head: title
TagMoreThanNumber:
- h1: 1
- strong: 15
HeadDoesnotHaveMeta:
- name: description
- name: keywords
Usage
Use default RuleChecker.yml
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
sd.run(); //run() is asynchronous function
Assign config yml to constructor
const seoDefects = require('node-seo-defects');
const sd = new seoDefects('your.yml'); //full path
sd.run()
Assign config json to run()
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
sd.run({
"input": { "filePath": "./node_modules/node-seo-defects/test/html/RuleCheckerCase1.html" },
"output": { "type": "console", filePath: "" }
})
Use input stream
const Readable = require('stream').Readable;
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
let s = new Readable();
s.push('<html><head></head><body></body></html>');
s.push(null);
sd.setInput(s);
sd.run()
Use output stream
const seoDefects = require('node-seo-defects');
const fs = require('fs');
const sd = new seoDefects();
let wstream = fs.createWriteStream('output.txt', {
flags: 'w'
});
sd.setOutput(wstream);
sd.run();
Set input file
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
sd.setInput('./node_modules/node-seo-defects/test/html/RuleCheckerCase2.html');
sd.run();
Set output file
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
sd.setOutput('/tmp/output.txt');
sd.run();
Set output to console
const seoDefects = require('node-seo-defects');
const sd = new seoDefects('your.yml');
sd.setOutput('console');
sd.run();
Use specific rule
const seoDefects = require('node-seo-defects');
const sd = new seoDefects();
sd.run({
"rules": {
"TagDoesnotHaveTag": [
{
"head": "title"
}
]
}
});
Test
npm test