Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amp-site-validator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amp-site-validator

Full site AMP Pages validator

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
decreased by-39.68%
Maintainers
1
Weekly downloads
 
Created
Source

amp-site-validator | Full site AMP Pages 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
const validator = require('amp-site-validator');

// 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(){
  const results = await validator(urlGenerator, 10); // This will fetch and validate 10 pages at the same time
  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

  • How minimal it is? Less than 20 lines of code
  • Which version of Node is required? > 8.0.0 because it uses async/await
  • Where to find more documentation? Visit Google's official docs: https://www.npmjs.com/package/amphtml-validator
  • What's a function generator ? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*

Keywords

FAQs

Package last updated on 29 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc