Skip to content

Commit

Permalink
Add PostXML AMP example app
Browse files Browse the repository at this point in the history
  • Loading branch information
rkazakov committed Jun 3, 2018
1 parent 19457eb commit 7d46252
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
examples/
node_modules/
test/
npm-debug.log
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## Installation

```sh
npm install postxml-amp --save-dev
npm install postxml-amp --save
```

## Usage
Expand Down
19 changes: 19 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "postxml-app",
"version": "1.0.0",
"description": "PostXML App example",
"main": "postxml-app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": {
"name": "rkazakov",
"email": "ruslan.kazakov@gmail.com"
},
"license": "MIT",
"dependencies": {
"postxml": "^0.2.9",
"postxml-amp": "^0.2.6"
}
}
29 changes: 29 additions & 0 deletions examples/postxml-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const postxml = require('postxml');
const postxmlAmp = require('postxml-amp');

const cheerioOptions = {};

const output = postxml([
postxmlAmp(cheerioOptions),
])
.process(`<html>
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123456789-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-123456789-1');
</script>
<title>AMP page</title>
</head>
<body>
<div>
<p>This is an AMP article</p>
<iframe src="http://www.youtube.com/embed/OO9oKhs80aI"
width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
</body>
</hmtl>`, cheerioOptions);

console.log(output);

0 comments on commit 7d46252

Please sign in to comment.