npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ampl

v1.1.1

Published

ampl converts your markdown files into AMP-compliant html so they can be cached by google for the fastest possible page load

Downloads

47

Readme

ampl

Ampl transforms your Markdown into AMP-compliant html so it loads super-fast!

Build Status codecov.io Code Climate Dependency Status devDependency Status HitCount

Why?

Google is putting their clout behind the AMP (Accelerated Mobile Pages) Project to help speed up page load times on the Mobile Web: https://googleblog.blogspot.co.uk/2015/10/introducing-accelerated-mobile-pages.html

This module lets you convert Markdown (.md) files to AMP-compliant .html so that you can serve them up to mobile clients much faster.

What?

For many, reading on the mobile web is a slow, clunky and frustrating experience - but it doesn’t have to be that way. The Accelerated Mobile Pages (AMP) Project is an open source initiative that embodies the vision that publishers can create mobile optimized content once and have it load instantly everywhere.

Read: https://www.ampproject.org/

How?

The best place to understand how AMP works is on the official "How it Works" page: https://www.ampproject.org/how-it-works/

Usage Example

install ampl from NPM

First install the module from npm:

npm install ampl --save

use ampl.parse in your code

Then in your ES5 code:

var ampl = require('ampl');
var markdownString = '# Hello World!'; // or read from a .md file
var cssStyle = 'h1 { color: green; }'; // or load your style.css file
ampl.parse(markdownString, {style: cssStyle}, function(ampHtml) {
  console.log(ampHtml);
});

Alternatively, if you are already using ES6 in your project, write:

import { parse } from 'ampl';
const markdownString = '# Hello World!'; // or read from a .md file
const cssStyle = 'h1 { color: green; }'; // or load your style.css file
parse(markdownString, cssStyle, function(ampHtml) {
  console.log(ampHtml);
});

This simple example is in example/simple.js To run this example, execute the following command in your terminal:

./node_modules/babel-cli/bin/babel-node.js example/simple.js

This will output the following AMP-Compliant html:

<html amp>
  <head >
    <meta charset='utf-8'></meta>
    <link rel='canonical' href='default.html'></link>
    <meta name='viewport' content='width=device-width,minimum-scale=1,initial-scale=1'></meta>
    <style amp-custom>
      h1 { color: green; }
    </style>
    <style >body {opacity: 0}</style><noscript ><style >body {opacity: 1}</style></noscript>
    <script async src='https://cdn.ampproject.org/v0.js'></script>
    <title >Index</title>
  </head>

    <div class="wrapper-main">
      <body >
    <h1 >Hello World!</h1>

  </body>
    </div>
</html>

When viewed in a Browser: dwyl-ampl-simple-example-hello-world-screenshot

More elaborate example to follow...

Documentation

ampl.parse

  • markdown - (required) markdown string to be parsed
  • options - (required)
    • headOverride - (optional) custom html head to use if you do not want to use one generated by ampl. Using this option will mean other options will have no effect
    • style - (optional) css string to style the output html
    • title - (optional) sets the title property in the page
    • canonicalUrl- (optional) sets the canonicalUrl of the page
    • extraHeadHTML- (optional) extra html to be inserted into the bottom of the head
  • callback(res) - callback function with
    • res - a string constaining html string for ampl page

ampl.markdown2AmpHTML

  • options - (required)
    • markdown - (required) markdown string to be parsed
  • callback(res) - callback function with
    • res - a string constaining html string for ampl page

Background Reading

  • The AMP Spec: https://github.com/ampproject/amphtml

Questions?

If you have any questions please ask: https://github.com/dwyl/ampl/issues