mktcms 0.1.43 → 0.1.45

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.45",
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,9 @@
1
- export declare function sendMail({ subject, fields, replyTo }: {
1
+ export declare function sendMail({ to, from, subject, fields, replyTo, templateHtml, templateText, }: {
2
+ to?: string;
3
+ from?: string;
2
4
  subject: string;
3
5
  fields: Record<string, any>;
4
6
  replyTo?: string;
7
+ templateHtml?: string;
8
+ templateText?: string;
5
9
  }): Promise<import("nodemailer/lib/smtp-transport").SentMessageInfo>;
@@ -1,6 +1,15 @@
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
+ to,
6
+ from,
7
+ subject,
8
+ fields,
9
+ replyTo,
10
+ templateHtml,
11
+ templateText
12
+ }) {
4
13
  const { mktcms: { smtpHost, smtpPort, smtpUser, smtpPass, smtpSecure, mailerFrom, mailerTo } } = useRuntimeConfig();
5
14
  const transporter = nodemailer.createTransport({
6
15
  host: smtpHost,
@@ -11,13 +20,15 @@ export async function sendMail({ subject, fields, replyTo }) {
11
20
  pass: smtpPass
12
21
  }
13
22
  });
23
+ const finalHtml = templateHtml ? ejs.render(templateHtml, { fields }) : Object.entries(fields).map(([key, value]) => `<p><strong>${key}:</strong> ${value}</p>`).join("");
24
+ const finalText = templateText ? ejs.render(templateText, { fields }) : Object.entries(fields).map(([key, value]) => `${key}: ${value}`).join("\n");
14
25
  const mailOptions = {
15
- from: mailerFrom,
16
- to: mailerTo,
26
+ from: from || mailerFrom,
27
+ to: to || mailerTo,
17
28
  replyTo: replyTo || void 0,
18
29
  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")
30
+ html: finalHtml,
31
+ text: finalText
21
32
  };
22
33
  return await transporter.sendMail(mailOptions);
23
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mktcms",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
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",