All Projects → rkazakov → Ampify

rkazakov / Ampify

Licence: mit
Convert your HTML to Google AMP (Accelerated Mobile Pages)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ampify

Laravel Amp
Package that helps you set up AMP (Accelerated Mobile Pages) using Laravel
Stars: ✭ 106 (+1.92%)
Mutual labels:  google, amp, mobile
Magicalexoplayer
The Easiest Way To Play/Stream Video And Audio Using Google ExoPlayer In Your Android Application
Stars: ✭ 171 (+64.42%)
Mutual labels:  google, mobile
Amp Theme Framework
Start Creating an AMP theme in minutes - This is a default / boilerplate theme, you can use this, modify and make one your own.
Stars: ✭ 69 (-33.65%)
Mutual labels:  amp, mobile
Jstoxml
JavaScript object to XML converter (useful for RSS, podcasts, GPX, AMP, etc)
Stars: ✭ 127 (+22.12%)
Mutual labels:  google, amp
React Native Header View
Fully customizable Header View with multiple design options for React Native.
Stars: ✭ 221 (+112.5%)
Mutual labels:  google, mobile
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (+205.77%)
Mutual labels:  google, mobile
Gmscore
Free implementation of Play Services
Stars: ✭ 4,356 (+4088.46%)
Mutual labels:  google, mobile
Mobly
E2E test framework for tests with complex environment requirements.
Stars: ✭ 424 (+307.69%)
Mutual labels:  google, mobile
React Native Streetview
React Native Google's Panorama/StreetView component for iOS and Android.
Stars: ✭ 79 (-24.04%)
Mutual labels:  google, mobile
Google Api Nodejs Client
Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
Stars: ✭ 9,722 (+9248.08%)
Mutual labels:  google
Pd Select
vue components ,like ios 3D picker style,vue 3d 选择器组件,3D滚轮
Stars: ✭ 101 (-2.88%)
Mutual labels:  mobile
Firebase
[DEPRECATED] Unofficial Carthage support for Firebase libraries
Stars: ✭ 99 (-4.81%)
Mutual labels:  google
Milligram
A minimalist CSS framework.
Stars: ✭ 9,568 (+9100%)
Mutual labels:  amp
Jscost.org
JSCost.org - a JavaScript cost visualizer 💸
Stars: ✭ 101 (-2.88%)
Mutual labels:  mobile
Searchconsoler
R interface with Google Search Console API v3, including Search Analytics.
Stars: ✭ 99 (-4.81%)
Mutual labels:  google
Boden
Purely native C++ cross-platform GUI framework for Android and iOS development. https://www.boden.io
Stars: ✭ 1,394 (+1240.38%)
Mutual labels:  mobile
Stompclientlib
Simple STOMP Client library, Swift 3 and 4, 4.2, 5 compatible
Stars: ✭ 99 (-4.81%)
Mutual labels:  mobile
Pixelslide
A up/down expand arrow anim sample likes Pixel Launcher.
Stars: ✭ 98 (-5.77%)
Mutual labels:  google
Amp Pwa Demo
A simple, dependency-free blog that uses a Progressive Web App (PWA) to show Accellerated Mobile Pages (AMP).
Stars: ✭ 104 (+0%)
Mutual labels:  amp
Ecency Mobile
Ecency Mobile - reimagined social blogging, contribute and get rewarded (for Android and iOS)
Stars: ✭ 103 (-0.96%)
Mutual labels:  mobile

ampify

NPM Version Downloads Stats

Build Status tested with jest Known Vulnerabilities Greenkeeper badge

Convert plain HTML to Google AMP (Accelerated Mobile Pages)

Installation

npm install ampify

Usage

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

Options

cwd

Assets (images/styles) file path

  • Type: String
  • Default: ''

round

Enable images dimensions rounding

  • Type: String
  • Default: true

Example

Input

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

image.png

image.png

style.css

body {
  background-color: #fff;
}

Output

<html amp="">
  <head>
    <style amp-custom="">body{background-color:#fff}</style>
  </head>
  <amp-img src="image.png" width="600" height="400"></amp-img>
</html>

More examples

See /examples folder for full source code.

Using in Express App

const ampify = require('ampify');
const express = require('express');

const app = express();

app.get('/article', async (req, res) => {
  const html = `
    <html>
      <head>
      <title>AMP page</title>
      </head>
      <body>
        <div>
          <p>This is an AMP article</p>
        </div>
      </body>
    </html>
  `;

  const amp = await ampify(html, {cwd: 'amp'});
  res.send(amp); // serving AMP content
});

app.listen(3000, () => {
  console.log('Listening on port 3000!');
});

Using as Express middleware

const ampify = require('ampify');
const express = require('express');

const app = express();

app.use((req, res, next) => {
  if (req.url.startsWith('/amp')) {
    const send = res.send;
    res.send = async (html) => {
      const amp = await ampify(html, {cwd: 'amp'});
      send.call(this, amp);
    };
  }
  next();
});

app.get('/amp/article', (req, res) => {
  const html = `
    <html>
      <head>
        <title>AMP page</title>
      </head>
      <body>
        <div>
          <p>This is AMP article</p>
        </div>
      </body>
    </html>
  `;
  res.send(html);
});

app.get('/article', (req, res) => {
  const html = `
    <html>
      <head>
        <title>HMTL page</title>
      </head>
      <body>
        <div>
          <p>This is HTML article</p>
        </div>
      </body>
    </html>
  `;
  res.send(html);
});

app.listen(3000, () => {
  console.log('Listening on port 3000!');
});

Release History

HISTORY

Licence

MIT (c) Ruslan Kazakov and contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].