Socket
Socket
Sign inDemoInstall

@bradymholt/ampify

Package Overview
Dependencies
25
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @bradymholt/ampify

Convert plain HTML to Google Accelerated Mobile Pages (AMP)


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
3.34 MB
Created
Weekly downloads
 

Readme

Source

ampify NPM Package

Convert plain HTML to Google AMP (Accelerated Mobile Pages)

Installation

npm install @bradymholt/ampify

Usage

const ampify = require("ampify");
const html = "<YOUR_HTML_CONTENT>";
const amp = await ampify(html, { cwd: "amp" });
console.log(amp); // Content of AMP HTML

Options

cwd

Assets (images/styles) file path

When <link rel=stylesheet> and <img/> tags with a local file reference are encountered, they will read and processed. This option specifies where the files are located (i.e. fs.existsSync(`${options.cwd}/${imagSrc}`)).

  • Type: String
  • Default: ''

round

Enable images dimensions rounding

  • Type: String
  • Default: true

Example

Input

<html>
  <head>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <img src="image.png" />
  </body>
</html>

Output

<html amp>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
    <noscript>
      <style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
    </noscript>
    <script async src="https://cdn.ampproject.org/v0.js"></script>
  </head>
  <body>
    <amp-img src="image.png" width="600" height="400"></amp-img>
  </body>
</html>

Keywords

FAQs

Last updated on 23 Jun 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc