seomate
v0.0.2
Published
An NPM module providing dead simple way to check your HTML defects
Readme
SEOMATE
An NPM module providing dead simple way to check your HTML defects.
Getting Started
Prerequisites
Node.js 8+Installation
npm install seomateUsage
Command line:
Usage: seomate [options] <filepath>
Options:
-V, --version output the version number
-c, --config-path [config path] configs file path
-r, --rules [rules] rules to be applied (separated by comma)
-o, --output [file path] write to file
-h, --help output usage informationExample:
seomate index.html -c configs.json -r title,h1 -o /tmp/seomate.logAPI:
const = seomate require('seomate');
seomate('your/file/path').then((t) => {
t.examine('rule1', 'rule2', 'rule3').toConsole();
}).catch((e) => {
console.log(e);
});Development Setup
git clone https://github.com/amigcamel/seomate
cd seomate
npm installTest
mochaRelease History
- 0.0.2
- add cli
- 0.0.1
- First release
Documentation
configDict
Format
configDict is configured in JSON format. A complete template is shown as the following:
{
"rule-name": {
"section": "",
"tag": "",
"attribute": "",
"value": "",
"action": {
"name": "",
"value": ""
}
}
}Here are the basic definitions:
rule-name: A rule name user definessection:headorbodytag: HTML tagattribute: Tag attributevalue: Attribute value of a tagaction: Expected behavior of the HTML parsername: rule name, currently supported rules are:must-havemust-have-attributenore-more-than
Fields
seomate laverage the use of css selector and parse fields in cascade manner:
section > tag[attribute=value]So, every field is dependant with its upper level.
section
head or body.
This should be sepcified to avoi cases like the following:
<html>
<head></head>
<body>
<title>This is a title</title>
</body>
</html>This HTML has the <title> in the <body> section, which is still valid but not standard. So, if we configure configDict as this:
{
"title-rule": {
"section": "head",
"tag": "tag",
"action": {
"name": "must-have"
}
}
}seomate will tell the non-existence of <title> as it'll look for <title> under <head> section.
tag
An HTML tag.
attribute
A tag attribute.
If tag is not set, value will be ignored.
value
An attribute value of a tag.
If attribute is not set, value will be ignored.
Rules
must-have
A HTML should have the provided pattern.
Example 1:
{
"title-rule": {
"section": "head",
"tag": "title",
"action": {
"name": "must-have"
}
}
}This rule can be read as "This HTML must have <title>."
Example 2:
{
"img-rule": {
"section": "head",
"tag": "body",
"attribute": "alt",
"action": {
"name": "must-have"
}
}
}This rule can be read as "This HTML must have <img> with attribute alt."
Example 3:
{
"meta-robots-rule": {
"section": "head",
"tag": "meta",
"attribute": "name",
"value": "robots",
"action": {
"name": "must-have"
}
}
}This rule can be read as "This HTML must have <meta> with attribute name whose value is robots, e.g., <meta name='robots'>"
must-have-attribute
A provided pattern should always have a specified attribute.
For example:
{
"a-rule": {
"section": "body",
"tag": "a",
"attribute": "rel"
},
"action": {
"name": "must-have-attr"
}
}This rule can be read as "<a>, if exists, must have attribute rel." If <a> is found with no rel attribute, line numbers will be provide for the ease of debugging.
Notice the field value is not in use with this rule.
nore-more-than
Numbers of provided pattern should be no more than the specified value.
For example:
{
"strong-rule": {
"section": "head",
"tag": "strong",
"action": {
"name": "no-more-than",
"value" 15
}
}
}This rule can be read as "<strong> cannot appear more than 15 times."
