npm-seo-def
A Node.js package to let a user use this package to scan a HTML file and show all of the SEO defects
Installation
Install the package globally using npm:
$ npm install -g npm-seo-def
Install the package locally using npm:
$ npm install npm-seo-def
Usage
var HtmlParser = ; //1. read from input file and outputs on console with default rulesvar htmlParser = {} "inputfile.html";htmlParser //2. read from input file and outputs on console with custom rulesvar rules = "tag":"img" "params": "attribute": "name": "height" "present": false "tag":"a" "params": "attribute": "name": "rel" "present": true ;var htmlParser1 = rules "inputfile.html";htmlParser1 //3. read from input file and outputs in an output filevar htmlParser2 = {} "inputfile.html" 'out.txt';htmlParser2 //4. read from readable stream and outputs in an output filevar fs = ;var s = fs;var htmlParser3 = {} s 'out1.txt';htmlParser3;
How to write custom rules
- Detect the number of
<img />
tagswithout
alt
attribute
"tag":"img" "params": "attribute": "name": "alt" "present": false
- Detect the number of
<img />
tagswith
alt
attribute
"tag":"img" "params": "attribute": "name": "alt" "present": true
- Detect if there are more than 5
<strong>
tag in HTML
"tag":"strong" "params": "min_count": 5
- Detect if there is any header that doesn’t have
<title>
tag
"tag":"head" "params": "child": "tag":"title" "present": false
- Detect if there is any header that does have
<title>
tag
"tag":"head" "params": "child": "tag":"title" "present": true
- Detect if there is any header that doesn’t have
<meta name=“descriptions” ... />
tag
"tag":"head" "params": "child": "tag":"meta" "present": false "name": "descriptions"
Development & Testing
Clone the repository and install it:
$ git clone https://github.com/kiritym/npm-seo-def.git$ cd npm-seo-def$ npm install
Run the test cases:
$ npm test