Skip to content

Commit

Permalink
chore(example): add another example and make navigation between them
Browse files Browse the repository at this point in the history
  • Loading branch information
mastertheblaster committed Apr 16, 2019
1 parent 290485b commit ceb1910
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/email-second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { readFileSync } from 'fs';

import {
Mjml,
MjmlHead,
MjmlTitle,
MjmlPreview,
MjmlBody,
MjmlSection,
MjmlColumn,
MjmlButton,
MjmlImage,
MjmlStyle,
MjmlText
} from 'mjml-react';

export const generate = () => {
return (
<Mjml>
<MjmlHead>
<MjmlTitle>Last Minute Offer</MjmlTitle>
<MjmlPreview>Last Minute Offer...</MjmlPreview>
</MjmlHead>
<MjmlBody width={500}>
<MjmlSection fullWidth backgroundColor="#efefef">
<MjmlColumn>
<MjmlImage src="https://static.wixstatic.com/media/5cb24728abef45dabebe7edc1d97ddd2.jpg" />
</MjmlColumn>
</MjmlSection>
<MjmlSection>
<MjmlColumn>
<MjmlButton padding="20px" backgroundColor="#346DB7" href="https://www.wix.com/">
This Yet Another Template
</MjmlButton>
</MjmlColumn>
</MjmlSection>
<MjmlSection>
<MjmlColumn>
<MjmlText><a href="/">Go Back</a></MjmlText>
</MjmlColumn>
</MjmlSection>
</MjmlBody>
</Mjml>
);
};
5 changes: 5 additions & 0 deletions src/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export const generate = () => {
<MjmlText>I am red</MjmlText>
</MjmlColumn>
</MjmlSection>
<MjmlSection>
<MjmlColumn>
<MjmlText><a href="/2">Open Second Template</a></MjmlText>
</MjmlColumn>
</MjmlSection>
</MjmlBody>
</Mjml>
);
Expand Down
10 changes: 8 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import express from 'express';
import {render} from 'mjml-react';

import {generate} from './email';
import * as email1 from './email';
import * as email2 from './email-second';

const port = 3000;
const app = express();

app.get('/2', (req, res) => {
const {html} = render(email2.generate(), {validationLevel: 'soft'});
res.send(html);
});

app.get('*', (req, res) => {
const {html} = render(generate(), {validationLevel: 'soft'});
const {html} = render(email1.generate(), {validationLevel: 'soft'});
res.send(html);
});

Expand Down

0 comments on commit ceb1910

Please sign in to comment.