https://github.com/jlopezxs/express-amp
:zap: Express middleware to convert express website to Google AMP
https://github.com/jlopezxs/express-amp
amp express google-amp
Last synced: 6 months ago
JSON representation
:zap: Express middleware to convert express website to Google AMP
- Host: GitHub
- URL: https://github.com/jlopezxs/express-amp
- Owner: jlopezxs
- License: mit
- Created: 2017-07-24T13:19:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-04T21:40:41.000Z (about 6 years ago)
- Last Synced: 2025-04-02T00:01:39.475Z (6 months ago)
- Topics: amp, express, google-amp
- Language: JavaScript
- Homepage:
- Size: 135 KB
- Stars: 3
- Watchers: 0
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-amp
> :zap: Express middleware to convert website to Google AMP## Installation
```sh
npm install --save express-amp
```## Preview
```js
/**
* Overriding the render method
* You can use that to avoid use renderAMP
* With that you can transform all /path in AMP pages
*/import express from 'express';
import expressAMP from 'express-amp';const app = express();
app.use(expressAMP({
override: true,
staticsPath: `${process.cwd()}/public`
}));app.get('/', (req, res) => {
res.render('index', {});
});```
```js
// Using renderAMP methodimport express from 'express';
import expressAMP from 'express-amp';const app = express();
app.use(expressAMP({
override: false,
staticsPath: `${process.cwd()}/public`
}));app.get('/', (req, res) => {
res.renderAMP('index', {});
});```
## Usage
expressAMP({ [override], [staticsPath] });
where:
- `override` (optional): It brings you the possibility to override the method render or use renderAMP method.
- `staticsPath` (optional): Directory path of the statics files to get it and include inline in AMP page.## License
MIT © [Jordi López](http://jlopezxs.github.io)