@opendesign-plus-test/plugins 0.0.1-rc.19 → 0.0.1-rc.20

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.
@@ -1,78 +1,102 @@
1
- import { defineNuxtModule as y, addVitePlugin as S } from "nuxt/kit";
2
- import { g as j, m as w } from "../../generate-lastmod-changefreq-Wk3kOITw.js";
3
- import { existsSync as $, readFileSync as b, createWriteStream as x, readdirSync as A } from "node:fs";
4
- import r from "node:path";
5
- import { pipeline as O } from "node:stream/promises";
6
- const q = y({
1
+ import { defineNuxtModule as W, addVitePlugin as O } from "nuxt/kit";
2
+ import { g as v, m as A } from "../../generate-lastmod-changefreq-Wk3kOITw.js";
3
+ import { existsSync as b, readFileSync as D, createWriteStream as q, writeFileSync as C, readdirSync as T } from "node:fs";
4
+ import m, { join as z } from "node:path";
5
+ import { pipeline as J } from "node:stream/promises";
6
+ const I = W({
7
7
  meta: {
8
8
  name: "sitemap",
9
9
  configKey: "sitemap"
10
10
  },
11
- setup(t, s) {
12
- S(
13
- j({
14
- rootDir: s.options.dir.app,
11
+ setup(t, f) {
12
+ O(
13
+ v({
14
+ rootDir: f.options.dir.app,
15
15
  // @ts-ignore
16
16
  pageEntryPattern: "**/pages/**/*.vue",
17
17
  ...t.lastmodAndChangefreqOptions
18
18
  })
19
19
  );
20
- const p = Array.isArray(t.ignore) ? t.ignore : typeof t.ignore == "string" ? [t.ignore] : [], f = t.base.endsWith("/") ? t.base.slice(0, -1) : t.base;
21
- s.hook("close", async () => {
22
- var u;
23
- const a = r.join(s.options.rootDir, ".output", "public");
24
- if (!$(a))
20
+ const w = Array.isArray(t.ignore) ? t.ignore : typeof t.ignore == "string" ? [t.ignore] : [], c = t.hostname.endsWith("/") ? t.hostname.slice(0, -1) : t.hostname;
21
+ f.hook("close", async () => {
22
+ var h, u, x, g, P, y;
23
+ const r = m.join(f.options.rootDir, ".output", "public");
24
+ if (!b(r))
25
25
  return;
26
- const m = [], c = (e) => {
27
- const o = A(e, {
26
+ const s = {};
27
+ if ((h = t.index) != null && h.items)
28
+ for (const e of t.index.items)
29
+ e.pathPrefix && (s[e.pathPrefix.startsWith("/") ? e.pathPrefix : `/${e.pathPrefix}`] = []);
30
+ else
31
+ s["/"] = [];
32
+ const d = (e) => {
33
+ const n = T(e, {
28
34
  withFileTypes: !0,
29
35
  encoding: "utf-8"
30
36
  });
31
- for (const n of o) {
32
- if (n.isDirectory()) {
33
- c(r.join(e, n.name));
37
+ for (const o of n) {
38
+ if (o.isDirectory()) {
39
+ d(m.join(e, o.name));
34
40
  continue;
35
41
  }
36
- if (n.name === "index.html") {
37
- const i = `/${r.relative(a, e).replace(/\\/g, "/")}`;
38
- for (const l of p)
39
- w(i, l);
40
- m.push(i);
42
+ if (o.name === "index.html") {
43
+ const l = `/${m.relative(r, e).replace(/\\/g, "/")}`;
44
+ for (const i of w)
45
+ A(l, i);
46
+ for (const i in s)
47
+ l.startsWith(i) && s[i].push(l);
41
48
  }
42
49
  }
43
50
  };
44
- c(a), console.log("[module:generate-sitemap] collect html done");
45
- const g = ((u = t.lastmodAndChangefreqOptions) == null ? void 0 : u.outputFile) || r.join(s.options.dir.app, "last-modified.json"), d = JSON.parse(b(g, "utf-8")), h = x(r.join(a, "sitemap.xml"), "utf-8");
46
- try {
47
- await O(function* () {
48
- yield `<?xml version="1.0" encoding="UTF-8"?>
51
+ d(r), console.log("[module:generate-sitemap] collect html done");
52
+ const j = ((u = t.lastmodAndChangefreqOptions) == null ? void 0 : u.outputFile) || m.join(f.options.dir.app, "last-modified.json"), p = JSON.parse(D(j, "utf-8"));
53
+ await Promise.all(
54
+ (((x = t.index) == null ? void 0 : x.items) ?? [{ pathPrefix: "/", filename: "sitemap.xml" }]).filter((e) => e.pathPrefix && e.filename).map(async (e) => {
55
+ const n = e.pathPrefix.startsWith("/") ? e.pathPrefix : `/${e.pathPrefix}`, o = e.filename.endsWith(".xml") ? e.filename : `${e.filename}.xml`, l = q(m.join(r, n, o), "utf-8");
56
+ try {
57
+ await J(function* () {
58
+ yield `<?xml version="1.0" encoding="UTF-8"?>
49
59
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
50
60
  `;
51
- for (const e of m) {
52
- if (!e.startsWith("/"))
53
- continue;
54
- const o = d[`pages${e.endsWith("/") ? e.slice(0, -1) : e}/index.vue`] || d[`pages${e}.md`];
55
- o != null && o.lastmod && (o.lastmod = new Date(o.lastmod).toISOString());
56
- const n = {
57
- loc: f + e,
58
- ...o
59
- };
60
- yield ` <url>
61
- ${Object.entries(n).map(([i, l]) => ` <${i}>${l}</${i}>`).join(`
61
+ for (const i of s[n]) {
62
+ if (!i.startsWith("/"))
63
+ continue;
64
+ const a = p[`pages${i.endsWith("/") ? i.slice(0, -1) : i}/index.vue`] || p[`pages${i}.md`];
65
+ a != null && a.lastmod && (a.lastmod = new Date(a.lastmod).toISOString());
66
+ const F = {
67
+ loc: c + i,
68
+ ...a
69
+ };
70
+ yield ` <url>
71
+ ${Object.entries(F).map(([$, S]) => ` <${$}>${S}</${$}>`).join(`
62
72
  `)}
63
73
  </url>
64
74
  `;
75
+ }
76
+ yield "</urlset>";
77
+ }, l);
78
+ } catch (i) {
79
+ console.log("[module:generate-sitemap] error", i);
80
+ return;
65
81
  }
66
- yield "</urlset>";
67
- }, h);
68
- } catch (e) {
69
- console.log("[module:generate-sitemap] error", e);
70
- return;
71
- }
72
- console.log("[module:generate-sitemap] generate done");
82
+ })
83
+ ), (g = t.index) != null && g.indexFilename && ((y = (P = t.index) == null ? void 0 : P.items) != null && y.length) && C(
84
+ z(r, t.index.indexFilename),
85
+ `<?xml version="1.0" encoding="UTF-8"?>
86
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
87
+ ${t.index.items.filter((e) => e.loc || e.filename).map((e) => {
88
+ const n = e.pathPrefix ? e.pathPrefix.startsWith("/") ? e.pathPrefix : `/${e.pathPrefix}` : "";
89
+ return `<sitemap>
90
+ <loc>${e.filename ? `${c}${n}/${e.filename}` : e.loc}</loc>
91
+ </sitemap>`;
92
+ })}
93
+ </sitemapindex>
94
+ `,
95
+ "utf-8"
96
+ ), console.log("[module:generate-sitemap] generate done");
73
97
  });
74
98
  }
75
99
  });
76
100
  export {
77
- q as default
101
+ I as default
78
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendesign-plus-test/plugins",
3
- "version": "0.0.1-rc.19",
3
+ "version": "0.0.1-rc.20",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",