1.1.2 • Published 7 years ago
detect-seo-rules v1.1.2
detect-seo-rules
Introduction
This is a module package was writen based on the shopback assignment. It scans a html file and detects all pre-defined SEO rules by user.
Dependencies
- htmlparser2 --- for HTML parser
Installation
$ npm install detect-seo-rules
Usage
Demo
var rDetectSeoRules = require(detect-seo-rules);
var htmlFileInput = 'path/to/your/input/html';
var rulesFile = 'path/to/your/json/rules'; //must be absolute path
var outputFile = 'path/to/your/output/file';
rDetectSeoRules.processDetectSEO(htmlFileInput, rulesFile, outputFile);
Note: You can set the absolute path by path
package
var rulesFile = require('path').join(__dirname, 'rulesDefined.json');
Define the rules
Currently, this package support three general rules:
- WITHOUT - A tag <> without attribute
- EXIST - A tag exist
- LIMIT - A tag with the limited appearance
These rules will be declare by the json file. The structure of this file like that:
[
{
"type": "without",
"data": {
"tagName": "_tageNameHere_",
"attribute": "_attributeNamehere_"
}
},
{
"type": "exist",
"data": {
"tagName": "_tagNameHere_"
}
},
{
"type": "exist",
"data": {
"tagName": "_tagNameHere_",
"listAttributes":
{
"_attributeName_": "_attributeValue_"
}
}
},
{
"type": "limit",
"data": {
"tagName": "_tagName_",
"quantity": inputNumber
}
}
]
By default, we pre-defined 5 rules in file default/rulesDefined.json
.
Testing
npm run test
Author
- Tran Van Nhan (navnahn)