Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created October 3, 2022 03:39
Show Gist options
  • Save ancyrweb/719eb298415f46062734b0703fdf8b0d to your computer and use it in GitHub Desktop.
Save ancyrweb/719eb298415f46062734b0703fdf8b0d to your computer and use it in GitHub Desktop.
import * as React from 'react';
import { Injectable } from '@nestjs/common';
import {
render,
MjmlBody,
Mjml,
MjmlHead,
MjmlFont,
MjmlPreview,
MjmlSection,
MjmlColumn,
MjmlText,
} from 'mjml-react';
import { CommentDTO } from './comment.interfaces';
@Injectable()
export class CommentEmailGenerator {
generateCommentEmail(data: CommentDTO) {
const { html, errors } = render(
<Mjml>
<MjmlHead>
<MjmlFont
name="Lato"
href="https://fonts.googleapis.com/css?family=Lato"
/>
<MjmlPreview>A new comment has been added</MjmlPreview>
</MjmlHead>
<MjmlBody>
<MjmlSection>
<MjmlColumn>
<MjmlText>{data.text}</MjmlText>
</MjmlColumn>
</MjmlSection>
</MjmlBody>
</Mjml>,
{ validationLevel: 'soft' },
);
return html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment