amp-site-validator

3.0.0 • Public • Published

Current Version NPM Minified size Github Code Size Downloads/Year Issues License Contributors

NPM

amp-site-validator

Full site AMP validator

If you publish your pages in AMP, you want to be sure any change does not affect your AMP performance. How? Setup a function generator that returns all URLS you want to validate and test them with the official Google's validator.

Usage

// 1. Import module and create a Validator
const createValidator = require('amp-site-validator');
const validator = createValidator();

// 2. Create your own url generator
const urlGenerator = function* (){
  for(let i=1; i < 200; i++){
    yield 'https://yourSite.com/page/'+i;
  }
}

// 3. Set the number of parallel jobs and validate!
async function run(){
  // This will fetch and validate 10 pages at the same time
  const results = await validator(urlGenerator, 10);
  console.log(results);
}
run();

Another way to create a generator?

const urlGenerator = function* (){
  yield 'https://yourSite.com/page/1';
  yield 'https://yourSite.com/page/2';
  yield 'https://yourSite.com/page/3';
  yield 'https://yourSite.com/page/4';
  yield 'https://yourSite.com/page/5';
  yield 'https://yourSite.com/page/6';
}

How to count correct and failed pages ?

console.log('Valid pages : '+ results.filter( result => result.status === 'PASS').length)
console.log('Invalid pages : '+ results.filter( result => result.status !== 'PASS').length)

FAQs

Package Sidebar

Install

npm i amp-site-validator

Weekly Downloads

22

Version

3.0.0

License

MIT

Unpacked Size

4.86 kB

Total Files

4

Last publish

Collaborators

  • wjsc