This package has been deprecated

Author message:

this package has been deprecated

lf-seo-scan

0.0.3 • Public • Published

LF SEO Scannner

A tool to identify your SEO set.

Install

npm install lf-seo-scan --save

How to use

var LFSEOScan = require('lf-seo-scan');
LFSEOScan.withUri('https://www.shopback.com.tw/').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).addCustomRules({
        ".home" : {
            "#fb-root": {
                moreThan: 0
            }
        }
    }).log();
}, function(error){
    console.log(error);
});

screensho 0

Initial

This tool support three different way to import your resource, after init function it will return a Promise object and will resolve with scan object after your resource finish load.

File path

var LFSEOScan = require('lf-seo-scan');
LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).log();
}, function(error){
    console.log(error);
});

Uri

var LFSEOScan = require('lf-seo-scan');
FSEOScan.withUri('https://www.shopback.com.tw/').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).log();
}, function(error){
    console.log(error);
});

ReadStream

var LFSEOScan = require('lf-seo-scan');
var readStream = fs.createReadStream('./sample1.html', {encoding: 'utf8'});
LFSEOScan.withReadableStream(readStream).then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).log();
}, function(error){
    console.log(error);
});

Output

This tool also support three different way to output your SEO result.

Console.log

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).log();
});

File

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).exportTo('./output.txt');
});

Write Stream

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    var outStream = fs.createWriteStream('./output2.txt', {encoding: 'utf8'});
    scanner.addPredefineRules([1,2,3,4,5]).pipeTo(outStream);
});

Rule syntax

This tool use a particular object rule to help user can define their SEO rule easily.

key Description
moreThan Detect current rule has more than condition or not.
attr Get element attribute, must have attribute name in next level.
required Detect current rule has particular attr name or not. (only available in attribute name)
contains Detect current rule contains value or not. (only available in attribute name)

Notice: Every key outside above rules will treat as CSS selector

{
   img: {
        attr: {
            alt: {
                required: true
            }
        }
    },
    head: {
        title: {
            moreThan: 0
        },
        meta: {
            attr: {
                name: {
                    contains: ["descriptions", "keywords"]
                }
            }
        }
    },
    ".header": {
        "#ad": {
            strong: {
                moreThan: 0
            }
        }
    }
}

Add pre-defined rules

There have 5 pre-defined SEO rules in this tool, you can add pre-defined rule easily by using addPredefineRules.

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).log();
});

Every pre-defined rule actully map to a rule syntax, so you also can add syntax yourself by using addCustomRules.

  1. Detect if any <img /> tag without alt attribute
     {
         img: {
             attr: {
                 alt: {
                     required: true
                 }
             }
         }
     }
  2. Detect if any <a /> tag without rel attribute
    {
        a: {
            attr: {
                rel: {
                    required: true
                }
            }
        }
    }
  3. In <head> tag Detect if header doesn’t have <title> tag Detect if header doesn’t have <meta name=“descriptions” ... /> tag Detect if header doesn’t have <meta name=“keywords” ... /> tag
    {
        head: {
            title: {
                moreThan: 0
            },
            meta: {
                attr: {
                    name: {
                        contains: ["descriptions", "keywords"]
                    }
                }
            }
        }
    }
  4. Detect if there’re more than 15 <strong> tag in HTML (15 is a value should be configurable by user)
    {
        strong: {
            moreThan: 15
        }
    }
  5. Detect if a HTML have more than one <H1> tag.
    {
        h1: {
            moreThan: 1
        }
    }

Add custom rules

var customRules = {
    img: {
        attr: {
            alt: {
                required: true
            }
        }
    },
    a: {
        attr: {
            rel: {
                required: true
            }
        }
    },
    head: {
        title: {
            moreThan: 0
        },
        meta: {
            attr: {
                name: {
                    contains: ["descriptions", "keywords"]
                }
            }
        }
    }
};

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addCustomRules(customRules).log()
});     

You can also add rule many times, but notice if rule has duplicate the newer one will replace onlder one.

LFSEOScan.withPath('./sample1.html').then(function(scanner){
    scanner.addPredefineRules([1,2,3,4,5]).addCustomRules({
        ".content": {
            strong: {
                moreThan: 3
            }
        }
    }).addCustomRules({
        ".header": {
            "#ad": {
                strong: {
                    moreThan: 0
                }
            }
        }
    }).log();
});

Remove all rules

You can remove whole rules and reset other rules.

LFSEOScan.withPath('./sample1.html').then(function(scanner){

    scanner.addPredefineRules([1,2,3,4,5]);
    scanner.log();

    scanner.removeAllRules();
    scanner.addPredefineRules([1,3,5]);
    scanner.log();

});

Readme

Keywords

none

Package Sidebar

Install

npm i lf-seo-scan

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

15.9 kB

Total Files

5

Last publish

Collaborators

  • lfshuyu