Created
July 4, 2019 15:08
-
-
Save fstanis/040f5cdfa04206e1729e0b8c598d8ce5 to your computer and use it in GitHub Desktop.
Query AMP HTML ⚡ Validator JSON rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2019 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
/** | |
* This example demonstrates how to query the AMP validator rules hosted on the | |
* AMP CDN. | |
* | |
* It lists all tags allowed in the AMP4EMAIL spec. | |
*/ | |
async function fetchValidatorRules() { | |
const VALIDATOR_RULES_URL = 'https://cdn.ampproject.org/v0/validator.json'; | |
const req = await fetch(VALIDATOR_RULES_URL); | |
return req.json(); | |
} | |
const rules = await fetchValidatorRules(); | |
const emailTags = rules.tags.filter(t => t.htmlFormat.includes('AMP4EMAIL')); | |
const emailTagNames = new Set(emailTags.map(t => t.tagName)); | |
for (const tag of emailTagNames) { | |
console.log(tag); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment