Skip to content

Commit e8e996a

Browse files
publish: Bump package to 2.2.0. :shipit:
generated from commit 65f3f82
1 parent cbaf19f commit e8e996a

File tree

2,054 files changed

+228869
-3036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,054 files changed

+228869
-3036
lines changed

README.md

+35-34
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,40 @@
1919
react-amp-template is distributed via npm:
2020
- [yarn](https://yarnpkg.com/en/docs/install) add react-amp-template or `$npm install --save react-amp-template`
2121

22-
## Server Side Rendering
23-
24-
25-
#### Basic sample
2622

2723
```javascript
28-
import http from 'http';
29-
import React from 'react';
30-
import App from './app';
31-
import { renderToStaticMarkup } from '../../lib';
32-
const debug = require('debug')('example:server');
33-
const error = require('debug')('example:server:error');
34-
35-
const startServer = (html) => {
36-
http.createServer((request, response) => {
37-
response.writeHeader(200, { 'Content-Type': 'text/html' });
38-
response.write(html);
39-
response.end();
40-
})
41-
.listen(8000)
42-
.on('clientError', (err, socket) => {
43-
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
44-
error(err);
24+
var React = require('react');
25+
var RAMPT = require('react-amp-template').default;
26+
27+
var rampt = new RAMPT({
28+
template: {
29+
head: {
30+
title: 'react amp template',
31+
canonical: 'http',
32+
}
33+
}
34+
});
35+
36+
var element = React.createElement('div', null, 'Hello World');
37+
38+
// add meta tag single mode.
39+
addMeta({
40+
type: 'application/ld+json',
41+
content: "{'@context': 'http://schema.org', '@type': 'NewsArticle'}"
42+
});
43+
44+
// register any amp-script. just an example.
45+
addScript('amp-social-share');
46+
47+
rampt
48+
.renderStatic(element)
49+
.then(console.log)
50+
.catch(function(error){
51+
console.log('Errors founds! Use npm run debug for debug trace.');
52+
console.log('Document failed '+((error.validation) ? 'at AMP validations.' : 'at internal rendering.'));
53+
console.log('Markup output: ', error.markup);
54+
process.exit(1);
4555
});
46-
debug('Listening on port 8000');
47-
};
48-
49-
/**
50-
* react-amp-template returns a promise which will be fulfilled
51-
* with a string that holds the whole HTML document ready to serve.
52-
* The promise will reject for any internal error.
53-
*/
54-
renderToStaticMarkup(<App bannerText="React-AMP-Template" />, App.config)
55-
.catch(error)
56-
.then(startServer);
5756
```
5857
<br />
5958
<div align="left">
@@ -77,8 +76,7 @@ renderToStaticMarkup(<App bannerText="React-AMP-Template" />, App.config)
7776
## API
7877
:zzz:
7978

80-
## Data flow
81-
:zzz:
79+
8280

8381
## :penguin: Contributing
8482

@@ -94,6 +92,9 @@ renderToStaticMarkup(<App bannerText="React-AMP-Template" />, App.config)
9492
- Build examples and github demo `npm run dist`
9593
- `npm run demo` or `npm run examples`
9694

95+
- Complete example using npm:
96+
- `cd examples/simple && npm i && npm start`
97+
9798

9899
## License
99100

coverage/coverage.json

+1-1
Large diffs are not rendered by default.

coverage/lcov-report/examples/app.js.html

-183
This file was deleted.

0 commit comments

Comments
 (0)