mktcms 0.1.43 → 0.1.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mktcms",
3
3
  "configKey": "mktcms",
4
- "version": "0.1.43",
4
+ "version": "0.1.44",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -17,7 +17,6 @@ const value = defineModel("value", { type: Boolean, ...{
17
17
  >
18
18
  {{ label }}
19
19
  </label>
20
- <div class="relative">
21
- </div>
20
+ <div class="relative" />
22
21
  </div>
23
22
  </template>
@@ -1,5 +1,7 @@
1
- export declare function sendMail({ subject, fields, replyTo }: {
1
+ export declare function sendMail({ subject, fields, replyTo, templateHtml, templateText, }: {
2
2
  subject: string;
3
3
  fields: Record<string, any>;
4
4
  replyTo?: string;
5
+ templateHtml?: string;
6
+ templateText?: string;
5
7
  }): Promise<import("nodemailer/lib/smtp-transport").SentMessageInfo>;
@@ -1,6 +1,13 @@
1
1
  import nodemailer from "nodemailer";
2
+ import ejs from "ejs";
2
3
  import { useRuntimeConfig } from "nitropack/runtime";
3
- export async function sendMail({ subject, fields, replyTo }) {
4
+ export async function sendMail({
5
+ subject,
6
+ fields,
7
+ replyTo,
8
+ templateHtml,
9
+ templateText
10
+ }) {
4
11
  const { mktcms: { smtpHost, smtpPort, smtpUser, smtpPass, smtpSecure, mailerFrom, mailerTo } } = useRuntimeConfig();
5
12
  const transporter = nodemailer.createTransport({
6
13
  host: smtpHost,
@@ -11,13 +18,15 @@ export async function sendMail({ subject, fields, replyTo }) {
11
18
  pass: smtpPass
12
19
  }
13
20
  });
21
+ const finalHtml = templateHtml ? ejs.render(templateHtml, { fields }) : Object.entries(fields).map(([key, value]) => `<p><strong>${key}:</strong> ${value}</p>`).join("");
22
+ const finalText = templateText ? ejs.render(templateText, { fields }) : Object.entries(fields).map(([key, value]) => `${key}: ${value}`).join("\n");
14
23
  const mailOptions = {
15
24
  from: mailerFrom,
16
25
  to: mailerTo,
17
26
  replyTo: replyTo || void 0,
18
27
  subject,
19
- html: Object.entries(fields).map(([key, value]) => `<p><strong>${key}:</strong> ${value}</p>`).join(""),
20
- text: Object.entries(fields).map(([key, value]) => `${key}: ${value}`).join("\n")
28
+ html: finalHtml,
29
+ text: finalText
21
30
  };
22
31
  return await transporter.sendMail(mailOptions);
23
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mktcms",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "Simple CMS module for Nuxt",
5
5
  "repository": "mktcode/mktcms",
6
6
  "license": "MIT",
@@ -39,10 +39,12 @@
39
39
  "dependencies": {
40
40
  "@nuxt/kit": "^4.2.2",
41
41
  "@nuxtjs/mdc": "^0.20.0",
42
+ "@types/ejs": "^3.1.5",
42
43
  "@vueuse/core": "^14.1.0",
43
44
  "csv-parse": "^6.1.0",
44
45
  "csv-stringify": "^6.6.0",
45
46
  "defu": "^6.1.4",
47
+ "ejs": "^4.0.1",
46
48
  "marked": "^17.0.1",
47
49
  "nodemailer": "^7.0.12",
48
50
  "sharp": "^0.34.5",