🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ampifyjs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampifyjs

A function to convert HTML markup into AMP html

0.0.3
latest
Source
npm
Version published
Maintainers
1
Created
Source

[Beta] AMPIFY

Converts static HTML to AMP-ready HTML. This is a work in progress and is currently fairly narrow.

Getting Started

yarn add ampify

Usage

const ampify = require('ampifyjs');
const someHTML = '<html>...</html>';

ampify(someHTML, '/url-to-original-page', ($) => {
  // Do anything you want here to the AMP page using jQuery syntax from cheerio

  // For example, lets add Google Analytics
  $('head').append('<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>');
  $('body').prepend('<amp-analytics type="googleanalytics" id="analytics1">\
    <script type="application/json">{"vars": {"account": "UA-99380302"},"triggers": {"trackPageview": {"on": "visible","request": "pageview"}}}</script>\
    </amp-analytics>');
})

Requirements

  • All of your image tags must have heights and widths

Keywords

AMP

FAQs

Package last updated on 18 Jul 2017

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