A Node.js package scan a HTML content and show all of SEO defects.
const detector ReaderType WriteType DefaultRule SupportedRuleEngine } = ; var fileOption = input: type : ReaderTypeFILE path: __dirname + '/exampleInput.html' output: type: WriteTypeFILE path: __dirname + '/exampleOutput.html' ; var ruleOptions = ;// Filter default rule with index.for var i in DefaultRule var index = Object; if index >= 0 ruleOptions; // customized rule with supported rule engineruleOptions;ruleOptions;ruleOptions;ruleOptions; // customized rule with customized rule engineruleOptions; var seoDetector = fileOptioninput fileOptionoutput ruleOptions; seoDetector ;
Requirements
Node.js 8.9.1 or greater
Installation
npm install seo-detector-demo
Predefined Rules
- Detect if there are any
<img />
tags withoutalt
attribute - Detect if there are any
<a />
tags withoutrel
attribute - Detect if there is any header that doesn’t have
<title>
tag - Detect if there is any header that doesn’t have
<meta name="descriptions" … />
tag - Detect if there is any header that doesn’t have
<meta name="keywords" … />
tag - Detect if there are more than 15
<strong>
tag in HTML - Detect if a HTML have more than one
<h1>
tag
Supported rule format
ruleOption = name: 'defaultRuleName' // for default rule usage. engine: 'supportedRuleEngine' // for customized rule usage param: root: 'head' tag: 'meta' attr: 'name' value: 'descriptions' limit: 0; {} // for new rule engine usage.
Default rule option
const DefaultRule = ; /** Default rule name * imgWithoutAlt, * aWithoutRel, * headerNoTitle, * headerNoMetaDescription, * headerNoMetaKeywords, * moreThan15Strong, * moreThan1H1 */ var ruleOptions = ;for var i in DefaultRule var index = Object; if index >= 0 ruleOptions;
Customized rule option with default rule engine
const SupportedRuleEngine = ; /** Default rule engine name * tagWithoutAttrCount, * tagExistence, * tagExistenceWithAttrValue, * tagLimitCount */ var ruleOptions = ;ruleOptions;ruleOptions;ruleOptions;ruleOptions;
Customized rule option with customized rule engine
var ruleOptions = ;ruleOptions;
Reader
There are 2 reader types: FILE and STREAM.
const ReaderType = ; var inputOption = type : ReaderTypeFILE path: __dirname + '/exampleInput.html';
Writer
There are 3 writer types: FILE, STREAM, CONSOLE.
const WriterType = ; var inputOption = type : WriterFILE path: __dirname + '/exampleOutput.html';
Detector
constructor(inputOption, outputOption, ruleOptions)
User can choose which pre-defined rule will be used through ruleOptions
const detector = ;const seoDetector = inputOption outputOption ruleOptions;// skip pre-defined rules if it doesn't add into ruleOptions
Detect && WriteResult
seoDetector ;
Unit testing
Run npm test
in the seo-detector-demo.