vaza-content 0.1.0
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/adapters/astro/index.cjs +75 -0
- package/dist/adapters/astro/index.cjs.map +1 -0
- package/dist/adapters/astro/index.d.cts +23 -0
- package/dist/adapters/astro/index.d.ts +23 -0
- package/dist/adapters/astro/index.js +75 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/next/index.cjs +82 -0
- package/dist/adapters/next/index.cjs.map +1 -0
- package/dist/adapters/next/index.d.cts +17 -0
- package/dist/adapters/next/index.d.ts +17 -0
- package/dist/adapters/next/index.js +82 -0
- package/dist/adapters/next/index.js.map +1 -0
- package/dist/adapters/nuxt/index.cjs +70 -0
- package/dist/adapters/nuxt/index.cjs.map +1 -0
- package/dist/adapters/nuxt/index.d.cts +18 -0
- package/dist/adapters/nuxt/index.d.ts +18 -0
- package/dist/adapters/nuxt/index.js +70 -0
- package/dist/adapters/nuxt/index.js.map +1 -0
- package/dist/adapters/sveltekit/index.cjs +78 -0
- package/dist/adapters/sveltekit/index.cjs.map +1 -0
- package/dist/adapters/sveltekit/index.d.cts +19 -0
- package/dist/adapters/sveltekit/index.d.ts +19 -0
- package/dist/adapters/sveltekit/index.js +78 -0
- package/dist/adapters/sveltekit/index.js.map +1 -0
- package/dist/blog-7EEJJG26.js +106 -0
- package/dist/blog-7EEJJG26.js.map +1 -0
- package/dist/blog-Z3R5GOMP.cjs +106 -0
- package/dist/blog-Z3R5GOMP.cjs.map +1 -0
- package/dist/chunk-7VCRDESM.cjs +1050 -0
- package/dist/chunk-7VCRDESM.cjs.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +11 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/chunk-L4VH2NSA.js +1050 -0
- package/dist/chunk-L4VH2NSA.js.map +1 -0
- package/dist/cli/index.cjs +256 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +256 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/dark-6E36AKLN.js +70 -0
- package/dist/dark-6E36AKLN.js.map +1 -0
- package/dist/dark-EX2GRAYK.cjs +70 -0
- package/dist/dark-EX2GRAYK.cjs.map +1 -0
- package/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/minimal-D2PRAVG6.js +54 -0
- package/dist/minimal-D2PRAVG6.js.map +1 -0
- package/dist/minimal-RHOK4XEZ.cjs +54 -0
- package/dist/minimal-RHOK4XEZ.cjs.map +1 -0
- package/dist/process-FYZZ5QAG.js +8 -0
- package/dist/process-FYZZ5QAG.js.map +1 -0
- package/dist/process-XEGGGY6S.cjs +8 -0
- package/dist/process-XEGGGY6S.cjs.map +1 -0
- package/dist/product-NCUW3U72.js +97 -0
- package/dist/product-NCUW3U72.js.map +1 -0
- package/dist/product-OT3XYMWD.cjs +97 -0
- package/dist/product-OT3XYMWD.cjs.map +1 -0
- package/dist/types-Bkue7DeN.d.cts +247 -0
- package/dist/types-Bkue7DeN.d.ts +247 -0
- package/package.json +94 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk7VCRDESMcjs = require('../../chunk-7VCRDESM.cjs');
|
|
6
|
+
require('../../chunk-JEQ2X3Z6.cjs');
|
|
7
|
+
|
|
8
|
+
// src/adapters/astro/index.ts
|
|
9
|
+
var _fs = require('fs');
|
|
10
|
+
var _path = require('path');
|
|
11
|
+
function vazaContent(config) {
|
|
12
|
+
return {
|
|
13
|
+
name: "vaza-content",
|
|
14
|
+
hooks: {
|
|
15
|
+
"astro:build:done": async () => {
|
|
16
|
+
await processAndWrite(config);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async function buildVazaContent(config) {
|
|
22
|
+
return processAndWrite(config);
|
|
23
|
+
}
|
|
24
|
+
async function processAndWrite(config) {
|
|
25
|
+
const output = await _chunk7VCRDESMcjs.processCollections.call(void 0, config);
|
|
26
|
+
const outDir = ".vaza-content";
|
|
27
|
+
ensureDir(outDir);
|
|
28
|
+
ensureDir("public");
|
|
29
|
+
if (_optionalChain([config, 'access', _ => _.sitemap, 'optionalAccess', _2 => _2.enabled]) !== false) {
|
|
30
|
+
writeJson(_path.join.call(void 0, outDir, "sitemap-data.json"), output.sitemap);
|
|
31
|
+
const xml = _chunk7VCRDESMcjs.renderSitemapXml.call(void 0, output.sitemap);
|
|
32
|
+
_fs.writeFileSync.call(void 0, "public/sitemap.xml", xml, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
if (_optionalChain([config, 'access', _3 => _3.rss, 'optionalAccess', _4 => _4.enabled]) !== false) {
|
|
35
|
+
const xml = _chunk7VCRDESMcjs.renderRssXml.call(void 0, output.rss, config);
|
|
36
|
+
const rssPath = _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.rss, 'optionalAccess', _6 => _6.path]), () => ( "/rss.xml"));
|
|
37
|
+
_fs.writeFileSync.call(void 0,
|
|
38
|
+
_path.join.call(void 0, "public", rssPath.replace(/^\//, "")),
|
|
39
|
+
xml,
|
|
40
|
+
"utf-8"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (_optionalChain([config, 'access', _7 => _7.jsonLd, 'optionalAccess', _8 => _8.enabled]) !== false) {
|
|
44
|
+
const jsonLdDir = _path.join.call(void 0, outDir, "json-ld");
|
|
45
|
+
ensureDir(jsonLdDir);
|
|
46
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
47
|
+
writeJson(_path.join.call(void 0, jsonLdDir, `${slug}.json`), schemas);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (_optionalChain([config, 'access', _9 => _9.taxonomy, 'optionalAccess', _10 => _10.enabled]) !== false) {
|
|
51
|
+
writeJson(_path.join.call(void 0, outDir, "taxonomy.json"), output.taxonomy);
|
|
52
|
+
}
|
|
53
|
+
if (_optionalChain([config, 'access', _11 => _11.redirects, 'optionalAccess', _12 => _12.enabled]) !== false) {
|
|
54
|
+
writeJson(_path.join.call(void 0, outDir, "redirects.json"), output.redirects);
|
|
55
|
+
}
|
|
56
|
+
writeJson(_path.join.call(void 0, outDir, "integrity-report.json"), output.integrity);
|
|
57
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
58
|
+
writeJson(_path.join.call(void 0, outDir, "slugs.json"), slugManifest);
|
|
59
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
function ensureDir(dir) {
|
|
63
|
+
if (!_fs.existsSync.call(void 0, dir)) {
|
|
64
|
+
_fs.mkdirSync.call(void 0, dir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function writeJson(path, data) {
|
|
68
|
+
ensureDir(_path.dirname.call(void 0, path));
|
|
69
|
+
_fs.writeFileSync.call(void 0, path, JSON.stringify(data, null, 2), "utf-8");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
exports.buildVazaContent = buildVazaContent; exports.vazaContent = vazaContent;
|
|
75
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mehdi/vaza-content/dist/adapters/astro/index.cjs","../../../src/adapters/astro/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,4DAAiC;AACjC,oCAAiC;AACjC;AACA;ACHA,wBAAqD;AACrD,4BAA8B;AAWvB,SAAS,WAAA,CAAY,MAAA,EAAoB;AAC9C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,cAAA;AAAA,IACN,KAAA,EAAO;AAAA,MACL,kBAAA,EAAoB,MAAA,CAAA,EAAA,GAAY;AAC9B,QAAA,MAAM,eAAA,CAAgB,MAAM,CAAA;AAAA,MAC9B;AAAA,IACF;AAAA,EACF,CAAA;AACF;AAKA,MAAA,SAAsB,gBAAA,CAAiB,MAAA,EAAyC;AAC9E,EAAA,OAAO,eAAA,CAAgB,MAAM,CAAA;AAC/B;AAEA,MAAA,SAAe,eAAA,CAAgB,MAAA,EAAyC;AACtE,EAAA,MAAM,OAAA,EAAS,MAAM,kDAAA,MAAyB,CAAA;AAC9C,EAAA,MAAM,OAAA,EAAS,eAAA;AAEf,EAAA,SAAA,CAAU,MAAM,CAAA;AAChB,EAAA,SAAA,CAAU,QAAQ,CAAA;AAGlB,EAAA,GAAA,iBAAI,MAAA,mBAAO,OAAA,6BAAS,UAAA,IAAY,KAAA,EAAO;AACrC,IAAA,SAAA,CAAU,wBAAA,MAAK,EAAQ,mBAAmB,CAAA,EAAG,MAAA,CAAO,OAAO,CAAA;AAC3D,IAAA,MAAM,IAAA,EAAM,gDAAA,MAAiB,CAAO,OAAO,CAAA;AAC3C,IAAA,+BAAA,oBAAc,EAAsB,GAAA,EAAK,OAAO,CAAA;AAAA,EAClD;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,GAAA,6BAAK,UAAA,IAAY,KAAA,EAAO;AACjC,IAAA,MAAM,IAAA,EAAM,4CAAA,MAAa,CAAO,GAAA,EAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,QAAA,mCAAU,MAAA,qBAAO,GAAA,6BAAK,MAAA,UAAQ,YAAA;AACpC,IAAA,+BAAA;AAAA,MACE,wBAAA,QAAK,EAAU,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA;AAAA,MACzC,GAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,MAAA,6BAAQ,UAAA,IAAY,KAAA,EAAO;AACpC,IAAA,MAAM,UAAA,EAAY,wBAAA,MAAK,EAAQ,SAAS,CAAA;AACxC,IAAA,SAAA,CAAU,SAAS,CAAA;AACnB,IAAA,IAAA,CAAA,MAAW,CAAC,IAAA,EAAM,OAAO,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,MAAM,CAAA,EAAG;AAC3D,MAAA,SAAA,CAAU,wBAAA,SAAK,EAAW,CAAA,EAAA;AAC5B,IAAA;AACF,EAAA;AAGqB,EAAA;AACI,IAAA;AACzB,EAAA;AAGsB,EAAA;AACG,IAAA;AACzB,EAAA;AAGuB,EAAA;AAGK,EAAA;AACL,EAAA;AAEX,EAAA;AAEL,EAAA;AACT;AAEsC;AACd,EAAA;AACQ,IAAA;AAC9B,EAAA;AACF;AAEsD;AAC7B,EAAA;AACE,EAAA;AAC3B;AD7BiC;AACA;AACA;AACA","file":"/Users/mehdi/vaza-content/dist/adapters/astro/index.cjs","sourcesContent":[null,"import { processCollections } from \"../../process.js\";\nimport type { VazaConfig, VazaOutput } from \"../../types.js\";\nimport { renderSitemapXml } from \"../../generate/sitemap.js\";\nimport { renderRssXml } from \"../../generate/rss.js\";\nimport { writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\n\n/**\n * Astro adapter — integration that hooks into build lifecycle.\n *\n * Usage in astro.config.mjs:\n * import { vazaContent } from 'vaza-content/astro'\n * export default defineConfig({\n * integrations: [vazaContent(vazaConfig)]\n * })\n */\nexport function vazaContent(config: VazaConfig) {\n return {\n name: \"vaza-content\",\n hooks: {\n \"astro:build:done\": async () => {\n await processAndWrite(config);\n },\n },\n };\n}\n\n/**\n * Standalone function to process and write outputs.\n */\nexport async function buildVazaContent(config: VazaConfig): Promise<VazaOutput> {\n return processAndWrite(config);\n}\n\nasync function processAndWrite(config: VazaConfig): Promise<VazaOutput> {\n const output = await processCollections(config);\n const outDir = \".vaza-content\";\n\n ensureDir(outDir);\n ensureDir(\"public\");\n\n // Write sitemap\n if (config.sitemap?.enabled !== false) {\n writeJson(join(outDir, \"sitemap-data.json\"), output.sitemap);\n const xml = renderSitemapXml(output.sitemap);\n writeFileSync(\"public/sitemap.xml\", xml, \"utf-8\");\n }\n\n // Write RSS\n if (config.rss?.enabled !== false) {\n const xml = renderRssXml(output.rss, config);\n const rssPath = config.rss?.path ?? \"/rss.xml\";\n writeFileSync(\n join(\"public\", rssPath.replace(/^\\//, \"\")),\n xml,\n \"utf-8\",\n );\n }\n\n // Write JSON-LD per slug\n if (config.jsonLd?.enabled !== false) {\n const jsonLdDir = join(outDir, \"json-ld\");\n ensureDir(jsonLdDir);\n for (const [slug, schemas] of Object.entries(output.jsonLd)) {\n writeJson(join(jsonLdDir, `${slug}.json`), schemas);\n }\n }\n\n // Write taxonomy data\n if (config.taxonomy?.enabled !== false) {\n writeJson(join(outDir, \"taxonomy.json\"), output.taxonomy);\n }\n\n // Write redirects\n if (config.redirects?.enabled !== false) {\n writeJson(join(outDir, \"redirects.json\"), output.redirects);\n }\n\n // Write integrity report\n writeJson(join(outDir, \"integrity-report.json\"), output.integrity);\n\n // Write slug manifest\n const slugManifest = output.entries.map((e) => e.slug);\n writeJson(join(outDir, \"slugs.json\"), slugManifest);\n\n console.log(`[vaza-content] Generated ${output.entries.length} entries`);\n\n return output;\n}\n\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction writeJson(path: string, data: unknown): void {\n ensureDir(dirname(path));\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Astro adapter — integration that hooks into build lifecycle.
|
|
5
|
+
*
|
|
6
|
+
* Usage in astro.config.mjs:
|
|
7
|
+
* import { vazaContent } from 'vaza-content/astro'
|
|
8
|
+
* export default defineConfig({
|
|
9
|
+
* integrations: [vazaContent(vazaConfig)]
|
|
10
|
+
* })
|
|
11
|
+
*/
|
|
12
|
+
declare function vazaContent(config: VazaConfig): {
|
|
13
|
+
name: string;
|
|
14
|
+
hooks: {
|
|
15
|
+
"astro:build:done": () => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Standalone function to process and write outputs.
|
|
20
|
+
*/
|
|
21
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
22
|
+
|
|
23
|
+
export { buildVazaContent, vazaContent };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Astro adapter — integration that hooks into build lifecycle.
|
|
5
|
+
*
|
|
6
|
+
* Usage in astro.config.mjs:
|
|
7
|
+
* import { vazaContent } from 'vaza-content/astro'
|
|
8
|
+
* export default defineConfig({
|
|
9
|
+
* integrations: [vazaContent(vazaConfig)]
|
|
10
|
+
* })
|
|
11
|
+
*/
|
|
12
|
+
declare function vazaContent(config: VazaConfig): {
|
|
13
|
+
name: string;
|
|
14
|
+
hooks: {
|
|
15
|
+
"astro:build:done": () => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Standalone function to process and write outputs.
|
|
20
|
+
*/
|
|
21
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
22
|
+
|
|
23
|
+
export { buildVazaContent, vazaContent };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
processCollections,
|
|
3
|
+
renderRssXml,
|
|
4
|
+
renderSitemapXml
|
|
5
|
+
} from "../../chunk-L4VH2NSA.js";
|
|
6
|
+
import "../../chunk-DGUM43GV.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/astro/index.ts
|
|
9
|
+
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
10
|
+
import { join, dirname } from "path";
|
|
11
|
+
function vazaContent(config) {
|
|
12
|
+
return {
|
|
13
|
+
name: "vaza-content",
|
|
14
|
+
hooks: {
|
|
15
|
+
"astro:build:done": async () => {
|
|
16
|
+
await processAndWrite(config);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async function buildVazaContent(config) {
|
|
22
|
+
return processAndWrite(config);
|
|
23
|
+
}
|
|
24
|
+
async function processAndWrite(config) {
|
|
25
|
+
const output = await processCollections(config);
|
|
26
|
+
const outDir = ".vaza-content";
|
|
27
|
+
ensureDir(outDir);
|
|
28
|
+
ensureDir("public");
|
|
29
|
+
if (config.sitemap?.enabled !== false) {
|
|
30
|
+
writeJson(join(outDir, "sitemap-data.json"), output.sitemap);
|
|
31
|
+
const xml = renderSitemapXml(output.sitemap);
|
|
32
|
+
writeFileSync("public/sitemap.xml", xml, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
if (config.rss?.enabled !== false) {
|
|
35
|
+
const xml = renderRssXml(output.rss, config);
|
|
36
|
+
const rssPath = config.rss?.path ?? "/rss.xml";
|
|
37
|
+
writeFileSync(
|
|
38
|
+
join("public", rssPath.replace(/^\//, "")),
|
|
39
|
+
xml,
|
|
40
|
+
"utf-8"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (config.jsonLd?.enabled !== false) {
|
|
44
|
+
const jsonLdDir = join(outDir, "json-ld");
|
|
45
|
+
ensureDir(jsonLdDir);
|
|
46
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
47
|
+
writeJson(join(jsonLdDir, `${slug}.json`), schemas);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (config.taxonomy?.enabled !== false) {
|
|
51
|
+
writeJson(join(outDir, "taxonomy.json"), output.taxonomy);
|
|
52
|
+
}
|
|
53
|
+
if (config.redirects?.enabled !== false) {
|
|
54
|
+
writeJson(join(outDir, "redirects.json"), output.redirects);
|
|
55
|
+
}
|
|
56
|
+
writeJson(join(outDir, "integrity-report.json"), output.integrity);
|
|
57
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
58
|
+
writeJson(join(outDir, "slugs.json"), slugManifest);
|
|
59
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
function ensureDir(dir) {
|
|
63
|
+
if (!existsSync(dir)) {
|
|
64
|
+
mkdirSync(dir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function writeJson(path, data) {
|
|
68
|
+
ensureDir(dirname(path));
|
|
69
|
+
writeFileSync(path, JSON.stringify(data, null, 2), "utf-8");
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
buildVazaContent,
|
|
73
|
+
vazaContent
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/astro/index.ts"],"sourcesContent":["import { processCollections } from \"../../process.js\";\nimport type { VazaConfig, VazaOutput } from \"../../types.js\";\nimport { renderSitemapXml } from \"../../generate/sitemap.js\";\nimport { renderRssXml } from \"../../generate/rss.js\";\nimport { writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\n\n/**\n * Astro adapter — integration that hooks into build lifecycle.\n *\n * Usage in astro.config.mjs:\n * import { vazaContent } from 'vaza-content/astro'\n * export default defineConfig({\n * integrations: [vazaContent(vazaConfig)]\n * })\n */\nexport function vazaContent(config: VazaConfig) {\n return {\n name: \"vaza-content\",\n hooks: {\n \"astro:build:done\": async () => {\n await processAndWrite(config);\n },\n },\n };\n}\n\n/**\n * Standalone function to process and write outputs.\n */\nexport async function buildVazaContent(config: VazaConfig): Promise<VazaOutput> {\n return processAndWrite(config);\n}\n\nasync function processAndWrite(config: VazaConfig): Promise<VazaOutput> {\n const output = await processCollections(config);\n const outDir = \".vaza-content\";\n\n ensureDir(outDir);\n ensureDir(\"public\");\n\n // Write sitemap\n if (config.sitemap?.enabled !== false) {\n writeJson(join(outDir, \"sitemap-data.json\"), output.sitemap);\n const xml = renderSitemapXml(output.sitemap);\n writeFileSync(\"public/sitemap.xml\", xml, \"utf-8\");\n }\n\n // Write RSS\n if (config.rss?.enabled !== false) {\n const xml = renderRssXml(output.rss, config);\n const rssPath = config.rss?.path ?? \"/rss.xml\";\n writeFileSync(\n join(\"public\", rssPath.replace(/^\\//, \"\")),\n xml,\n \"utf-8\",\n );\n }\n\n // Write JSON-LD per slug\n if (config.jsonLd?.enabled !== false) {\n const jsonLdDir = join(outDir, \"json-ld\");\n ensureDir(jsonLdDir);\n for (const [slug, schemas] of Object.entries(output.jsonLd)) {\n writeJson(join(jsonLdDir, `${slug}.json`), schemas);\n }\n }\n\n // Write taxonomy data\n if (config.taxonomy?.enabled !== false) {\n writeJson(join(outDir, \"taxonomy.json\"), output.taxonomy);\n }\n\n // Write redirects\n if (config.redirects?.enabled !== false) {\n writeJson(join(outDir, \"redirects.json\"), output.redirects);\n }\n\n // Write integrity report\n writeJson(join(outDir, \"integrity-report.json\"), output.integrity);\n\n // Write slug manifest\n const slugManifest = output.entries.map((e) => e.slug);\n writeJson(join(outDir, \"slugs.json\"), slugManifest);\n\n console.log(`[vaza-content] Generated ${output.entries.length} entries`);\n\n return output;\n}\n\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction writeJson(path: string, data: unknown): void {\n ensureDir(dirname(path));\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n"],"mappings":";;;;;;;;AAIA,SAAS,eAAe,WAAW,kBAAkB;AACrD,SAAS,MAAM,eAAe;AAWvB,SAAS,YAAY,QAAoB;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,oBAAoB,YAAY;AAC9B,cAAM,gBAAgB,MAAM;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;AAKA,eAAsB,iBAAiB,QAAyC;AAC9E,SAAO,gBAAgB,MAAM;AAC/B;AAEA,eAAe,gBAAgB,QAAyC;AACtE,QAAM,SAAS,MAAM,mBAAmB,MAAM;AAC9C,QAAM,SAAS;AAEf,YAAU,MAAM;AAChB,YAAU,QAAQ;AAGlB,MAAI,OAAO,SAAS,YAAY,OAAO;AACrC,cAAU,KAAK,QAAQ,mBAAmB,GAAG,OAAO,OAAO;AAC3D,UAAM,MAAM,iBAAiB,OAAO,OAAO;AAC3C,kBAAc,sBAAsB,KAAK,OAAO;AAAA,EAClD;AAGA,MAAI,OAAO,KAAK,YAAY,OAAO;AACjC,UAAM,MAAM,aAAa,OAAO,KAAK,MAAM;AAC3C,UAAM,UAAU,OAAO,KAAK,QAAQ;AACpC;AAAA,MACE,KAAK,UAAU,QAAQ,QAAQ,OAAO,EAAE,CAAC;AAAA,MACzC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,MAAI,OAAO,QAAQ,YAAY,OAAO;AACpC,UAAM,YAAY,KAAK,QAAQ,SAAS;AACxC,cAAU,SAAS;AACnB,eAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,OAAO,MAAM,GAAG;AAC3D,gBAAU,KAAK,WAAW,GAAG,IAAI,OAAO,GAAG,OAAO;AAAA,IACpD;AAAA,EACF;AAGA,MAAI,OAAO,UAAU,YAAY,OAAO;AACtC,cAAU,KAAK,QAAQ,eAAe,GAAG,OAAO,QAAQ;AAAA,EAC1D;AAGA,MAAI,OAAO,WAAW,YAAY,OAAO;AACvC,cAAU,KAAK,QAAQ,gBAAgB,GAAG,OAAO,SAAS;AAAA,EAC5D;AAGA,YAAU,KAAK,QAAQ,uBAAuB,GAAG,OAAO,SAAS;AAGjE,QAAM,eAAe,OAAO,QAAQ,IAAI,CAAC,MAAM,EAAE,IAAI;AACrD,YAAU,KAAK,QAAQ,YAAY,GAAG,YAAY;AAElD,UAAQ,IAAI,4BAA4B,OAAO,QAAQ,MAAM,UAAU;AAEvE,SAAO;AACT;AAEA,SAAS,UAAU,KAAmB;AACpC,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,EACpC;AACF;AAEA,SAAS,UAAU,MAAc,MAAqB;AACpD,YAAU,QAAQ,IAAI,CAAC;AACvB,gBAAc,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC,GAAG,OAAO;AAC5D;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk7VCRDESMcjs = require('../../chunk-7VCRDESM.cjs');
|
|
6
|
+
require('../../chunk-JEQ2X3Z6.cjs');
|
|
7
|
+
|
|
8
|
+
// src/adapters/next/index.ts
|
|
9
|
+
var _fs = require('fs');
|
|
10
|
+
var _path = require('path');
|
|
11
|
+
function withVazaContent(nextConfig, vazaConfig) {
|
|
12
|
+
const originalWebpack = nextConfig.webpack;
|
|
13
|
+
return {
|
|
14
|
+
...nextConfig,
|
|
15
|
+
webpack(config, options) {
|
|
16
|
+
if (options.isServer && vazaConfig) {
|
|
17
|
+
processAndWrite(vazaConfig).catch((err) => {
|
|
18
|
+
console.error("[vaza-content] Build error:", err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (originalWebpack) {
|
|
23
|
+
return originalWebpack(config, options);
|
|
24
|
+
}
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function buildVazaContent(config) {
|
|
30
|
+
return processAndWrite(config);
|
|
31
|
+
}
|
|
32
|
+
async function processAndWrite(config) {
|
|
33
|
+
const output = await _chunk7VCRDESMcjs.processCollections.call(void 0, config);
|
|
34
|
+
const outDir = ".vaza-content";
|
|
35
|
+
ensureDir(outDir);
|
|
36
|
+
if (_optionalChain([config, 'access', _ => _.sitemap, 'optionalAccess', _2 => _2.enabled]) !== false) {
|
|
37
|
+
writeJson(_path.join.call(void 0, outDir, "sitemap-data.json"), output.sitemap);
|
|
38
|
+
const xml = _chunk7VCRDESMcjs.renderSitemapXml.call(void 0, output.sitemap);
|
|
39
|
+
ensureDir("public");
|
|
40
|
+
_fs.writeFileSync.call(void 0, "public/sitemap.xml", xml, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
if (_optionalChain([config, 'access', _3 => _3.rss, 'optionalAccess', _4 => _4.enabled]) !== false) {
|
|
43
|
+
const xml = _chunk7VCRDESMcjs.renderRssXml.call(void 0, output.rss, config);
|
|
44
|
+
const rssPath = _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.rss, 'optionalAccess', _6 => _6.path]), () => ( "/rss.xml"));
|
|
45
|
+
const rssFile = _path.join.call(void 0, "public", rssPath.replace(/^\//, ""));
|
|
46
|
+
ensureDir(_path.dirname.call(void 0, rssFile));
|
|
47
|
+
_fs.writeFileSync.call(void 0, rssFile, xml, "utf-8");
|
|
48
|
+
}
|
|
49
|
+
if (_optionalChain([config, 'access', _7 => _7.jsonLd, 'optionalAccess', _8 => _8.enabled]) !== false) {
|
|
50
|
+
const jsonLdDir = _path.join.call(void 0, outDir, "json-ld");
|
|
51
|
+
ensureDir(jsonLdDir);
|
|
52
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
53
|
+
writeJson(_path.join.call(void 0, jsonLdDir, `${slug}.json`), schemas);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (_optionalChain([config, 'access', _9 => _9.taxonomy, 'optionalAccess', _10 => _10.enabled]) !== false) {
|
|
57
|
+
writeJson(_path.join.call(void 0, outDir, "taxonomy.json"), output.taxonomy);
|
|
58
|
+
}
|
|
59
|
+
if (_optionalChain([config, 'access', _11 => _11.redirects, 'optionalAccess', _12 => _12.enabled]) !== false) {
|
|
60
|
+
writeJson(_path.join.call(void 0, outDir, "redirects.json"), output.redirects);
|
|
61
|
+
}
|
|
62
|
+
writeJson(_path.join.call(void 0, outDir, "integrity-report.json"), output.integrity);
|
|
63
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
64
|
+
writeJson(_path.join.call(void 0, outDir, "slugs.json"), slugManifest);
|
|
65
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
66
|
+
console.log(`[vaza-content] Outputs written to ${outDir}/ and public/`);
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
69
|
+
function ensureDir(dir) {
|
|
70
|
+
if (!_fs.existsSync.call(void 0, dir)) {
|
|
71
|
+
_fs.mkdirSync.call(void 0, dir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function writeJson(path, data) {
|
|
75
|
+
ensureDir(_path.dirname.call(void 0, path));
|
|
76
|
+
_fs.writeFileSync.call(void 0, path, JSON.stringify(data, null, 2), "utf-8");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
exports.buildVazaContent = buildVazaContent; exports.withVazaContent = withVazaContent;
|
|
82
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mehdi/vaza-content/dist/adapters/next/index.cjs","../../../src/adapters/next/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,4DAAiC;AACjC,oCAAiC;AACjC;AACA;ACHA,wBAAqD;AACrD,4BAA8B;AASvB,SAAS,eAAA,CACd,UAAA,EACA,UAAA,EACyB;AACzB,EAAA,MAAM,gBAAA,EAAkB,UAAA,CAAW,OAAA;AAInC,EAAA,OAAO;AAAA,IACL,GAAG,UAAA;AAAA,IACH,OAAA,CAAQ,MAAA,EAAiB,OAAA,EAAkC;AAEzD,MAAA,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,UAAA,EAAY;AAElC,QAAA,eAAA,CAAgB,UAAU,CAAA,CAAE,KAAA,CAAM,CAAC,GAAA,EAAA,GAAiB;AAClD,UAAA,OAAA,CAAQ,KAAA,CAAM,6BAAA,EAA+B,GAAG,CAAA;AAChD,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAAA,QAChB,CAAC,CAAA;AAAA,MACH;AAEA,MAAA,GAAA,CAAI,eAAA,EAAiB;AACnB,QAAA,OAAO,eAAA,CAAgB,MAAA,EAAQ,OAAO,CAAA;AAAA,MACxC;AACA,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAA;AACF;AAMA,MAAA,SAAsB,gBAAA,CAAiB,MAAA,EAAyC;AAC9E,EAAA,OAAO,eAAA,CAAgB,MAAM,CAAA;AAC/B;AAEA,MAAA,SAAe,eAAA,CAAgB,MAAA,EAAyC;AACtE,EAAA,MAAM,OAAA,EAAS,MAAM,kDAAA,MAAyB,CAAA;AAC9C,EAAA,MAAM,OAAA,EAAS,eAAA;AAEf,EAAA,SAAA,CAAU,MAAM,CAAA;AAGhB,EAAA,GAAA,iBAAI,MAAA,mBAAO,OAAA,6BAAS,UAAA,IAAY,KAAA,EAAO;AACrC,IAAA,SAAA,CAAU,wBAAA,MAAK,EAAQ,mBAAmB,CAAA,EAAG,MAAA,CAAO,OAAO,CAAA;AAG3D,IAAA,MAAM,IAAA,EAAM,gDAAA,MAAiB,CAAO,OAAO,CAAA;AAC3C,IAAA,SAAA,CAAU,QAAQ,CAAA;AAClB,IAAA,+BAAA,oBAAc,EAAsB,GAAA,EAAK,OAAO,CAAA;AAAA,EAClD;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,GAAA,6BAAK,UAAA,IAAY,KAAA,EAAO;AACjC,IAAA,MAAM,IAAA,EAAM,4CAAA,MAAa,CAAO,GAAA,EAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,QAAA,mCAAU,MAAA,qBAAO,GAAA,6BAAK,MAAA,UAAQ,YAAA;AACpC,IAAA,MAAM,QAAA,EAAU,wBAAA,QAAK,EAAU,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA;AACzD,IAAA,SAAA,CAAU,2BAAA,OAAe,CAAC,CAAA;AAC1B,IAAA,+BAAA,OAAc,EAAS,GAAA,EAAK,OAAO,CAAA;AAAA,EACrC;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,MAAA,6BAAQ,UAAA,IAAY,KAAA,EAAO;AACpC,IAAA,MAAM,UAAA,EAAY,wBAAA,MAAK,EAAQ,SAAS,CAAA;AACxC,IAAA,SAAA,CAAU,SAAS,CAAA;AACnB,IAAA,IAAA,CAAA,MAAW,CAAC,IAAA,EAAM,OAAO,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,MAAM,CAAA,EAAG;AAC3D,MAAA,SAAA,CAAU,wBAAA,SAAK,EAAW,CAAA,EAAA;AAC5B,IAAA;AACF,EAAA;AAGqB,EAAA;AACI,IAAA;AACzB,EAAA;AAGsB,EAAA;AACG,IAAA;AACzB,EAAA;AAGuB,EAAA;AAGK,EAAA;AACL,EAAA;AAEX,EAAA;AACA,EAAA;AAEL,EAAA;AACT;AAEsC;AACd,EAAA;AACQ,IAAA;AAC9B,EAAA;AACF;AAEsD;AAC7B,EAAA;AACE,EAAA;AAC3B;ADvCiC;AACA;AACA;AACA","file":"/Users/mehdi/vaza-content/dist/adapters/next/index.cjs","sourcesContent":[null,"import { processCollections } from \"../../process.js\";\nimport type { VazaConfig, VazaOutput } from \"../../types.js\";\nimport { renderSitemapXml } from \"../../generate/sitemap.js\";\nimport { renderRssXml } from \"../../generate/rss.js\";\nimport { writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\n\n/**\n * Next.js adapter — wraps next.config and hooks into the build.\n *\n * Usage in next.config.ts:\n * import { withVazaContent } from 'vaza-content/next'\n * export default withVazaContent(nextConfig)\n */\nexport function withVazaContent(\n nextConfig: Record<string, unknown>,\n vazaConfig?: VazaConfig,\n): Record<string, unknown> {\n const originalWebpack = nextConfig.webpack as\n | ((config: unknown, options: unknown) => unknown)\n | undefined;\n\n return {\n ...nextConfig,\n webpack(config: unknown, options: Record<string, unknown>) {\n // Only run during server build (not client)\n if (options.isServer && vazaConfig) {\n // Schedule processing after webpack compilation\n processAndWrite(vazaConfig).catch((err: unknown) => {\n console.error(\"[vaza-content] Build error:\", err);\n process.exit(1);\n });\n }\n\n if (originalWebpack) {\n return originalWebpack(config, options);\n }\n return config;\n },\n };\n}\n\n/**\n * Standalone function to process and write outputs.\n * Can be called from a build script instead of withVazaContent.\n */\nexport async function buildVazaContent(config: VazaConfig): Promise<VazaOutput> {\n return processAndWrite(config);\n}\n\nasync function processAndWrite(config: VazaConfig): Promise<VazaOutput> {\n const output = await processCollections(config);\n const outDir = \".vaza-content\";\n\n ensureDir(outDir);\n\n // Write sitemap data\n if (config.sitemap?.enabled !== false) {\n writeJson(join(outDir, \"sitemap-data.json\"), output.sitemap);\n\n // Also write the XML to public/\n const xml = renderSitemapXml(output.sitemap);\n ensureDir(\"public\");\n writeFileSync(\"public/sitemap.xml\", xml, \"utf-8\");\n }\n\n // Write RSS\n if (config.rss?.enabled !== false) {\n const xml = renderRssXml(output.rss, config);\n const rssPath = config.rss?.path ?? \"/rss.xml\";\n const rssFile = join(\"public\", rssPath.replace(/^\\//, \"\"));\n ensureDir(dirname(rssFile));\n writeFileSync(rssFile, xml, \"utf-8\");\n }\n\n // Write JSON-LD per slug\n if (config.jsonLd?.enabled !== false) {\n const jsonLdDir = join(outDir, \"json-ld\");\n ensureDir(jsonLdDir);\n for (const [slug, schemas] of Object.entries(output.jsonLd)) {\n writeJson(join(jsonLdDir, `${slug}.json`), schemas);\n }\n }\n\n // Write taxonomy data\n if (config.taxonomy?.enabled !== false) {\n writeJson(join(outDir, \"taxonomy.json\"), output.taxonomy);\n }\n\n // Write redirects\n if (config.redirects?.enabled !== false) {\n writeJson(join(outDir, \"redirects.json\"), output.redirects);\n }\n\n // Write integrity report\n writeJson(join(outDir, \"integrity-report.json\"), output.integrity);\n\n // Write slug manifest for redirect detection\n const slugManifest = output.entries.map((e) => e.slug);\n writeJson(join(outDir, \"slugs.json\"), slugManifest);\n\n console.log(`[vaza-content] Generated ${output.entries.length} entries`);\n console.log(`[vaza-content] Outputs written to ${outDir}/ and public/`);\n\n return output;\n}\n\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction writeJson(path: string, data: unknown): void {\n ensureDir(dirname(path));\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Next.js adapter — wraps next.config and hooks into the build.
|
|
5
|
+
*
|
|
6
|
+
* Usage in next.config.ts:
|
|
7
|
+
* import { withVazaContent } from 'vaza-content/next'
|
|
8
|
+
* export default withVazaContent(nextConfig)
|
|
9
|
+
*/
|
|
10
|
+
declare function withVazaContent(nextConfig: Record<string, unknown>, vazaConfig?: VazaConfig): Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Standalone function to process and write outputs.
|
|
13
|
+
* Can be called from a build script instead of withVazaContent.
|
|
14
|
+
*/
|
|
15
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
16
|
+
|
|
17
|
+
export { buildVazaContent, withVazaContent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Next.js adapter — wraps next.config and hooks into the build.
|
|
5
|
+
*
|
|
6
|
+
* Usage in next.config.ts:
|
|
7
|
+
* import { withVazaContent } from 'vaza-content/next'
|
|
8
|
+
* export default withVazaContent(nextConfig)
|
|
9
|
+
*/
|
|
10
|
+
declare function withVazaContent(nextConfig: Record<string, unknown>, vazaConfig?: VazaConfig): Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Standalone function to process and write outputs.
|
|
13
|
+
* Can be called from a build script instead of withVazaContent.
|
|
14
|
+
*/
|
|
15
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
16
|
+
|
|
17
|
+
export { buildVazaContent, withVazaContent };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
processCollections,
|
|
3
|
+
renderRssXml,
|
|
4
|
+
renderSitemapXml
|
|
5
|
+
} from "../../chunk-L4VH2NSA.js";
|
|
6
|
+
import "../../chunk-DGUM43GV.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/next/index.ts
|
|
9
|
+
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
10
|
+
import { join, dirname } from "path";
|
|
11
|
+
function withVazaContent(nextConfig, vazaConfig) {
|
|
12
|
+
const originalWebpack = nextConfig.webpack;
|
|
13
|
+
return {
|
|
14
|
+
...nextConfig,
|
|
15
|
+
webpack(config, options) {
|
|
16
|
+
if (options.isServer && vazaConfig) {
|
|
17
|
+
processAndWrite(vazaConfig).catch((err) => {
|
|
18
|
+
console.error("[vaza-content] Build error:", err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (originalWebpack) {
|
|
23
|
+
return originalWebpack(config, options);
|
|
24
|
+
}
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function buildVazaContent(config) {
|
|
30
|
+
return processAndWrite(config);
|
|
31
|
+
}
|
|
32
|
+
async function processAndWrite(config) {
|
|
33
|
+
const output = await processCollections(config);
|
|
34
|
+
const outDir = ".vaza-content";
|
|
35
|
+
ensureDir(outDir);
|
|
36
|
+
if (config.sitemap?.enabled !== false) {
|
|
37
|
+
writeJson(join(outDir, "sitemap-data.json"), output.sitemap);
|
|
38
|
+
const xml = renderSitemapXml(output.sitemap);
|
|
39
|
+
ensureDir("public");
|
|
40
|
+
writeFileSync("public/sitemap.xml", xml, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
if (config.rss?.enabled !== false) {
|
|
43
|
+
const xml = renderRssXml(output.rss, config);
|
|
44
|
+
const rssPath = config.rss?.path ?? "/rss.xml";
|
|
45
|
+
const rssFile = join("public", rssPath.replace(/^\//, ""));
|
|
46
|
+
ensureDir(dirname(rssFile));
|
|
47
|
+
writeFileSync(rssFile, xml, "utf-8");
|
|
48
|
+
}
|
|
49
|
+
if (config.jsonLd?.enabled !== false) {
|
|
50
|
+
const jsonLdDir = join(outDir, "json-ld");
|
|
51
|
+
ensureDir(jsonLdDir);
|
|
52
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
53
|
+
writeJson(join(jsonLdDir, `${slug}.json`), schemas);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (config.taxonomy?.enabled !== false) {
|
|
57
|
+
writeJson(join(outDir, "taxonomy.json"), output.taxonomy);
|
|
58
|
+
}
|
|
59
|
+
if (config.redirects?.enabled !== false) {
|
|
60
|
+
writeJson(join(outDir, "redirects.json"), output.redirects);
|
|
61
|
+
}
|
|
62
|
+
writeJson(join(outDir, "integrity-report.json"), output.integrity);
|
|
63
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
64
|
+
writeJson(join(outDir, "slugs.json"), slugManifest);
|
|
65
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
66
|
+
console.log(`[vaza-content] Outputs written to ${outDir}/ and public/`);
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
69
|
+
function ensureDir(dir) {
|
|
70
|
+
if (!existsSync(dir)) {
|
|
71
|
+
mkdirSync(dir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function writeJson(path, data) {
|
|
75
|
+
ensureDir(dirname(path));
|
|
76
|
+
writeFileSync(path, JSON.stringify(data, null, 2), "utf-8");
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
buildVazaContent,
|
|
80
|
+
withVazaContent
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/next/index.ts"],"sourcesContent":["import { processCollections } from \"../../process.js\";\nimport type { VazaConfig, VazaOutput } from \"../../types.js\";\nimport { renderSitemapXml } from \"../../generate/sitemap.js\";\nimport { renderRssXml } from \"../../generate/rss.js\";\nimport { writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\n\n/**\n * Next.js adapter — wraps next.config and hooks into the build.\n *\n * Usage in next.config.ts:\n * import { withVazaContent } from 'vaza-content/next'\n * export default withVazaContent(nextConfig)\n */\nexport function withVazaContent(\n nextConfig: Record<string, unknown>,\n vazaConfig?: VazaConfig,\n): Record<string, unknown> {\n const originalWebpack = nextConfig.webpack as\n | ((config: unknown, options: unknown) => unknown)\n | undefined;\n\n return {\n ...nextConfig,\n webpack(config: unknown, options: Record<string, unknown>) {\n // Only run during server build (not client)\n if (options.isServer && vazaConfig) {\n // Schedule processing after webpack compilation\n processAndWrite(vazaConfig).catch((err: unknown) => {\n console.error(\"[vaza-content] Build error:\", err);\n process.exit(1);\n });\n }\n\n if (originalWebpack) {\n return originalWebpack(config, options);\n }\n return config;\n },\n };\n}\n\n/**\n * Standalone function to process and write outputs.\n * Can be called from a build script instead of withVazaContent.\n */\nexport async function buildVazaContent(config: VazaConfig): Promise<VazaOutput> {\n return processAndWrite(config);\n}\n\nasync function processAndWrite(config: VazaConfig): Promise<VazaOutput> {\n const output = await processCollections(config);\n const outDir = \".vaza-content\";\n\n ensureDir(outDir);\n\n // Write sitemap data\n if (config.sitemap?.enabled !== false) {\n writeJson(join(outDir, \"sitemap-data.json\"), output.sitemap);\n\n // Also write the XML to public/\n const xml = renderSitemapXml(output.sitemap);\n ensureDir(\"public\");\n writeFileSync(\"public/sitemap.xml\", xml, \"utf-8\");\n }\n\n // Write RSS\n if (config.rss?.enabled !== false) {\n const xml = renderRssXml(output.rss, config);\n const rssPath = config.rss?.path ?? \"/rss.xml\";\n const rssFile = join(\"public\", rssPath.replace(/^\\//, \"\"));\n ensureDir(dirname(rssFile));\n writeFileSync(rssFile, xml, \"utf-8\");\n }\n\n // Write JSON-LD per slug\n if (config.jsonLd?.enabled !== false) {\n const jsonLdDir = join(outDir, \"json-ld\");\n ensureDir(jsonLdDir);\n for (const [slug, schemas] of Object.entries(output.jsonLd)) {\n writeJson(join(jsonLdDir, `${slug}.json`), schemas);\n }\n }\n\n // Write taxonomy data\n if (config.taxonomy?.enabled !== false) {\n writeJson(join(outDir, \"taxonomy.json\"), output.taxonomy);\n }\n\n // Write redirects\n if (config.redirects?.enabled !== false) {\n writeJson(join(outDir, \"redirects.json\"), output.redirects);\n }\n\n // Write integrity report\n writeJson(join(outDir, \"integrity-report.json\"), output.integrity);\n\n // Write slug manifest for redirect detection\n const slugManifest = output.entries.map((e) => e.slug);\n writeJson(join(outDir, \"slugs.json\"), slugManifest);\n\n console.log(`[vaza-content] Generated ${output.entries.length} entries`);\n console.log(`[vaza-content] Outputs written to ${outDir}/ and public/`);\n\n return output;\n}\n\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction writeJson(path: string, data: unknown): void {\n ensureDir(dirname(path));\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n"],"mappings":";;;;;;;;AAIA,SAAS,eAAe,WAAW,kBAAkB;AACrD,SAAS,MAAM,eAAe;AASvB,SAAS,gBACd,YACA,YACyB;AACzB,QAAM,kBAAkB,WAAW;AAInC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,QAAQ,QAAiB,SAAkC;AAEzD,UAAI,QAAQ,YAAY,YAAY;AAElC,wBAAgB,UAAU,EAAE,MAAM,CAAC,QAAiB;AAClD,kBAAQ,MAAM,+BAA+B,GAAG;AAChD,kBAAQ,KAAK,CAAC;AAAA,QAChB,CAAC;AAAA,MACH;AAEA,UAAI,iBAAiB;AACnB,eAAO,gBAAgB,QAAQ,OAAO;AAAA,MACxC;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAMA,eAAsB,iBAAiB,QAAyC;AAC9E,SAAO,gBAAgB,MAAM;AAC/B;AAEA,eAAe,gBAAgB,QAAyC;AACtE,QAAM,SAAS,MAAM,mBAAmB,MAAM;AAC9C,QAAM,SAAS;AAEf,YAAU,MAAM;AAGhB,MAAI,OAAO,SAAS,YAAY,OAAO;AACrC,cAAU,KAAK,QAAQ,mBAAmB,GAAG,OAAO,OAAO;AAG3D,UAAM,MAAM,iBAAiB,OAAO,OAAO;AAC3C,cAAU,QAAQ;AAClB,kBAAc,sBAAsB,KAAK,OAAO;AAAA,EAClD;AAGA,MAAI,OAAO,KAAK,YAAY,OAAO;AACjC,UAAM,MAAM,aAAa,OAAO,KAAK,MAAM;AAC3C,UAAM,UAAU,OAAO,KAAK,QAAQ;AACpC,UAAM,UAAU,KAAK,UAAU,QAAQ,QAAQ,OAAO,EAAE,CAAC;AACzD,cAAU,QAAQ,OAAO,CAAC;AAC1B,kBAAc,SAAS,KAAK,OAAO;AAAA,EACrC;AAGA,MAAI,OAAO,QAAQ,YAAY,OAAO;AACpC,UAAM,YAAY,KAAK,QAAQ,SAAS;AACxC,cAAU,SAAS;AACnB,eAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,OAAO,MAAM,GAAG;AAC3D,gBAAU,KAAK,WAAW,GAAG,IAAI,OAAO,GAAG,OAAO;AAAA,IACpD;AAAA,EACF;AAGA,MAAI,OAAO,UAAU,YAAY,OAAO;AACtC,cAAU,KAAK,QAAQ,eAAe,GAAG,OAAO,QAAQ;AAAA,EAC1D;AAGA,MAAI,OAAO,WAAW,YAAY,OAAO;AACvC,cAAU,KAAK,QAAQ,gBAAgB,GAAG,OAAO,SAAS;AAAA,EAC5D;AAGA,YAAU,KAAK,QAAQ,uBAAuB,GAAG,OAAO,SAAS;AAGjE,QAAM,eAAe,OAAO,QAAQ,IAAI,CAAC,MAAM,EAAE,IAAI;AACrD,YAAU,KAAK,QAAQ,YAAY,GAAG,YAAY;AAElD,UAAQ,IAAI,4BAA4B,OAAO,QAAQ,MAAM,UAAU;AACvE,UAAQ,IAAI,qCAAqC,MAAM,eAAe;AAEtE,SAAO;AACT;AAEA,SAAS,UAAU,KAAmB;AACpC,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,EACpC;AACF;AAEA,SAAS,UAAU,MAAc,MAAqB;AACpD,YAAU,QAAQ,IAAI,CAAC;AACvB,gBAAc,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC,GAAG,OAAO;AAC5D;","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk7VCRDESMcjs = require('../../chunk-7VCRDESM.cjs');
|
|
6
|
+
require('../../chunk-JEQ2X3Z6.cjs');
|
|
7
|
+
|
|
8
|
+
// src/adapters/nuxt/index.ts
|
|
9
|
+
var _fs = require('fs');
|
|
10
|
+
var _path = require('path');
|
|
11
|
+
function defineVazaContentModule(config) {
|
|
12
|
+
return async function vazaContentModule() {
|
|
13
|
+
await processAndWrite(config);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function buildVazaContent(config) {
|
|
17
|
+
return processAndWrite(config);
|
|
18
|
+
}
|
|
19
|
+
async function processAndWrite(config) {
|
|
20
|
+
const output = await _chunk7VCRDESMcjs.processCollections.call(void 0, config);
|
|
21
|
+
const outDir = ".vaza-content";
|
|
22
|
+
ensureDir(outDir);
|
|
23
|
+
ensureDir("public");
|
|
24
|
+
if (_optionalChain([config, 'access', _ => _.sitemap, 'optionalAccess', _2 => _2.enabled]) !== false) {
|
|
25
|
+
writeJson(_path.join.call(void 0, outDir, "sitemap-data.json"), output.sitemap);
|
|
26
|
+
const xml = _chunk7VCRDESMcjs.renderSitemapXml.call(void 0, output.sitemap);
|
|
27
|
+
_fs.writeFileSync.call(void 0, "public/sitemap.xml", xml, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
if (_optionalChain([config, 'access', _3 => _3.rss, 'optionalAccess', _4 => _4.enabled]) !== false) {
|
|
30
|
+
const xml = _chunk7VCRDESMcjs.renderRssXml.call(void 0, output.rss, config);
|
|
31
|
+
const rssPath = _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.rss, 'optionalAccess', _6 => _6.path]), () => ( "/rss.xml"));
|
|
32
|
+
_fs.writeFileSync.call(void 0,
|
|
33
|
+
_path.join.call(void 0, "public", rssPath.replace(/^\//, "")),
|
|
34
|
+
xml,
|
|
35
|
+
"utf-8"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (_optionalChain([config, 'access', _7 => _7.jsonLd, 'optionalAccess', _8 => _8.enabled]) !== false) {
|
|
39
|
+
const jsonLdDir = _path.join.call(void 0, outDir, "json-ld");
|
|
40
|
+
ensureDir(jsonLdDir);
|
|
41
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
42
|
+
writeJson(_path.join.call(void 0, jsonLdDir, `${slug}.json`), schemas);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (_optionalChain([config, 'access', _9 => _9.taxonomy, 'optionalAccess', _10 => _10.enabled]) !== false) {
|
|
46
|
+
writeJson(_path.join.call(void 0, outDir, "taxonomy.json"), output.taxonomy);
|
|
47
|
+
}
|
|
48
|
+
if (_optionalChain([config, 'access', _11 => _11.redirects, 'optionalAccess', _12 => _12.enabled]) !== false) {
|
|
49
|
+
writeJson(_path.join.call(void 0, outDir, "redirects.json"), output.redirects);
|
|
50
|
+
}
|
|
51
|
+
writeJson(_path.join.call(void 0, outDir, "integrity-report.json"), output.integrity);
|
|
52
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
53
|
+
writeJson(_path.join.call(void 0, outDir, "slugs.json"), slugManifest);
|
|
54
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
55
|
+
return output;
|
|
56
|
+
}
|
|
57
|
+
function ensureDir(dir) {
|
|
58
|
+
if (!_fs.existsSync.call(void 0, dir)) {
|
|
59
|
+
_fs.mkdirSync.call(void 0, dir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeJson(path, data) {
|
|
63
|
+
ensureDir(_path.dirname.call(void 0, path));
|
|
64
|
+
_fs.writeFileSync.call(void 0, path, JSON.stringify(data, null, 2), "utf-8");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.buildVazaContent = buildVazaContent; exports.defineVazaContentModule = defineVazaContentModule;
|
|
70
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mehdi/vaza-content/dist/adapters/nuxt/index.cjs","../../../src/adapters/nuxt/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,4DAAiC;AACjC,oCAAiC;AACjC;AACA;ACHA,wBAAqD;AACrD,4BAA8B;AAWvB,SAAS,uBAAA,CAAwB,MAAA,EAAoB;AAC1D,EAAA,OAAO,MAAA,SAAe,iBAAA,CAAA,EAAoB;AACxC,IAAA,MAAM,eAAA,CAAgB,MAAM,CAAA;AAAA,EAC9B,CAAA;AACF;AAKA,MAAA,SAAsB,gBAAA,CAAiB,MAAA,EAAyC;AAC9E,EAAA,OAAO,eAAA,CAAgB,MAAM,CAAA;AAC/B;AAEA,MAAA,SAAe,eAAA,CAAgB,MAAA,EAAyC;AACtE,EAAA,MAAM,OAAA,EAAS,MAAM,kDAAA,MAAyB,CAAA;AAC9C,EAAA,MAAM,OAAA,EAAS,eAAA;AAEf,EAAA,SAAA,CAAU,MAAM,CAAA;AAChB,EAAA,SAAA,CAAU,QAAQ,CAAA;AAGlB,EAAA,GAAA,iBAAI,MAAA,mBAAO,OAAA,6BAAS,UAAA,IAAY,KAAA,EAAO;AACrC,IAAA,SAAA,CAAU,wBAAA,MAAK,EAAQ,mBAAmB,CAAA,EAAG,MAAA,CAAO,OAAO,CAAA;AAC3D,IAAA,MAAM,IAAA,EAAM,gDAAA,MAAiB,CAAO,OAAO,CAAA;AAC3C,IAAA,+BAAA,oBAAc,EAAsB,GAAA,EAAK,OAAO,CAAA;AAAA,EAClD;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,GAAA,6BAAK,UAAA,IAAY,KAAA,EAAO;AACjC,IAAA,MAAM,IAAA,EAAM,4CAAA,MAAa,CAAO,GAAA,EAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,QAAA,mCAAU,MAAA,qBAAO,GAAA,6BAAK,MAAA,UAAQ,YAAA;AACpC,IAAA,+BAAA;AAAA,MACE,wBAAA,QAAK,EAAU,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA;AAAA,MACzC,GAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF;AAGA,EAAA,GAAA,iBAAI,MAAA,qBAAO,MAAA,6BAAQ,UAAA,IAAY,KAAA,EAAO;AACpC,IAAA,MAAM,UAAA,EAAY,wBAAA,MAAK,EAAQ,SAAS,CAAA;AACxC,IAAA,SAAA,CAAU,SAAS,CAAA;AACnB,IAAA,IAAA,CAAA,MAAW,CAAC,IAAA,EAAM,OAAO,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,MAAM,CAAA,EAAG;AAC3D,MAAA,SAAA,CAAU,wBAAA,SAAK,EAAW,CAAA,EAAA;AAC5B,IAAA;AACF,EAAA;AAGqB,EAAA;AACI,IAAA;AACzB,EAAA;AAGsB,EAAA;AACG,IAAA;AACzB,EAAA;AAGuB,EAAA;AAGK,EAAA;AACL,EAAA;AAEX,EAAA;AAEL,EAAA;AACT;AAEsC;AACd,EAAA;AACQ,IAAA;AAC9B,EAAA;AACF;AAEsD;AAC7B,EAAA;AACE,EAAA;AAC3B;AD7BiC;AACA;AACA;AACA","file":"/Users/mehdi/vaza-content/dist/adapters/nuxt/index.cjs","sourcesContent":[null,"import { processCollections } from \"../../process.js\";\nimport type { VazaConfig, VazaOutput } from \"../../types.js\";\nimport { renderSitemapXml } from \"../../generate/sitemap.js\";\nimport { renderRssXml } from \"../../generate/rss.js\";\nimport { writeFileSync, mkdirSync, existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\n\n/**\n * Nuxt adapter — module that hooks into the Nuxt build.\n *\n * Usage in nuxt.config.ts:\n * modules: [\n * '@nuxt/content',\n * ['vaza-content/nuxt', vazaConfig]\n * ]\n */\nexport function defineVazaContentModule(config: VazaConfig) {\n return async function vazaContentModule() {\n await processAndWrite(config);\n };\n}\n\n/**\n * Standalone function to process and write outputs.\n */\nexport async function buildVazaContent(config: VazaConfig): Promise<VazaOutput> {\n return processAndWrite(config);\n}\n\nasync function processAndWrite(config: VazaConfig): Promise<VazaOutput> {\n const output = await processCollections(config);\n const outDir = \".vaza-content\";\n\n ensureDir(outDir);\n ensureDir(\"public\");\n\n // Write sitemap\n if (config.sitemap?.enabled !== false) {\n writeJson(join(outDir, \"sitemap-data.json\"), output.sitemap);\n const xml = renderSitemapXml(output.sitemap);\n writeFileSync(\"public/sitemap.xml\", xml, \"utf-8\");\n }\n\n // Write RSS\n if (config.rss?.enabled !== false) {\n const xml = renderRssXml(output.rss, config);\n const rssPath = config.rss?.path ?? \"/rss.xml\";\n writeFileSync(\n join(\"public\", rssPath.replace(/^\\//, \"\")),\n xml,\n \"utf-8\",\n );\n }\n\n // Write JSON-LD per slug\n if (config.jsonLd?.enabled !== false) {\n const jsonLdDir = join(outDir, \"json-ld\");\n ensureDir(jsonLdDir);\n for (const [slug, schemas] of Object.entries(output.jsonLd)) {\n writeJson(join(jsonLdDir, `${slug}.json`), schemas);\n }\n }\n\n // Write taxonomy data\n if (config.taxonomy?.enabled !== false) {\n writeJson(join(outDir, \"taxonomy.json\"), output.taxonomy);\n }\n\n // Write redirects\n if (config.redirects?.enabled !== false) {\n writeJson(join(outDir, \"redirects.json\"), output.redirects);\n }\n\n // Write integrity report\n writeJson(join(outDir, \"integrity-report.json\"), output.integrity);\n\n // Write slug manifest\n const slugManifest = output.entries.map((e) => e.slug);\n writeJson(join(outDir, \"slugs.json\"), slugManifest);\n\n console.log(`[vaza-content] Generated ${output.entries.length} entries`);\n\n return output;\n}\n\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n}\n\nfunction writeJson(path: string, data: unknown): void {\n ensureDir(dirname(path));\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Nuxt adapter — module that hooks into the Nuxt build.
|
|
5
|
+
*
|
|
6
|
+
* Usage in nuxt.config.ts:
|
|
7
|
+
* modules: [
|
|
8
|
+
* '@nuxt/content',
|
|
9
|
+
* ['vaza-content/nuxt', vazaConfig]
|
|
10
|
+
* ]
|
|
11
|
+
*/
|
|
12
|
+
declare function defineVazaContentModule(config: VazaConfig): () => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Standalone function to process and write outputs.
|
|
15
|
+
*/
|
|
16
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
17
|
+
|
|
18
|
+
export { buildVazaContent, defineVazaContentModule };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { V as VazaConfig, a as VazaOutput } from '../../types-Bkue7DeN.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Nuxt adapter — module that hooks into the Nuxt build.
|
|
5
|
+
*
|
|
6
|
+
* Usage in nuxt.config.ts:
|
|
7
|
+
* modules: [
|
|
8
|
+
* '@nuxt/content',
|
|
9
|
+
* ['vaza-content/nuxt', vazaConfig]
|
|
10
|
+
* ]
|
|
11
|
+
*/
|
|
12
|
+
declare function defineVazaContentModule(config: VazaConfig): () => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Standalone function to process and write outputs.
|
|
15
|
+
*/
|
|
16
|
+
declare function buildVazaContent(config: VazaConfig): Promise<VazaOutput>;
|
|
17
|
+
|
|
18
|
+
export { buildVazaContent, defineVazaContentModule };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
processCollections,
|
|
3
|
+
renderRssXml,
|
|
4
|
+
renderSitemapXml
|
|
5
|
+
} from "../../chunk-L4VH2NSA.js";
|
|
6
|
+
import "../../chunk-DGUM43GV.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/nuxt/index.ts
|
|
9
|
+
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
10
|
+
import { join, dirname } from "path";
|
|
11
|
+
function defineVazaContentModule(config) {
|
|
12
|
+
return async function vazaContentModule() {
|
|
13
|
+
await processAndWrite(config);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function buildVazaContent(config) {
|
|
17
|
+
return processAndWrite(config);
|
|
18
|
+
}
|
|
19
|
+
async function processAndWrite(config) {
|
|
20
|
+
const output = await processCollections(config);
|
|
21
|
+
const outDir = ".vaza-content";
|
|
22
|
+
ensureDir(outDir);
|
|
23
|
+
ensureDir("public");
|
|
24
|
+
if (config.sitemap?.enabled !== false) {
|
|
25
|
+
writeJson(join(outDir, "sitemap-data.json"), output.sitemap);
|
|
26
|
+
const xml = renderSitemapXml(output.sitemap);
|
|
27
|
+
writeFileSync("public/sitemap.xml", xml, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
if (config.rss?.enabled !== false) {
|
|
30
|
+
const xml = renderRssXml(output.rss, config);
|
|
31
|
+
const rssPath = config.rss?.path ?? "/rss.xml";
|
|
32
|
+
writeFileSync(
|
|
33
|
+
join("public", rssPath.replace(/^\//, "")),
|
|
34
|
+
xml,
|
|
35
|
+
"utf-8"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (config.jsonLd?.enabled !== false) {
|
|
39
|
+
const jsonLdDir = join(outDir, "json-ld");
|
|
40
|
+
ensureDir(jsonLdDir);
|
|
41
|
+
for (const [slug, schemas] of Object.entries(output.jsonLd)) {
|
|
42
|
+
writeJson(join(jsonLdDir, `${slug}.json`), schemas);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (config.taxonomy?.enabled !== false) {
|
|
46
|
+
writeJson(join(outDir, "taxonomy.json"), output.taxonomy);
|
|
47
|
+
}
|
|
48
|
+
if (config.redirects?.enabled !== false) {
|
|
49
|
+
writeJson(join(outDir, "redirects.json"), output.redirects);
|
|
50
|
+
}
|
|
51
|
+
writeJson(join(outDir, "integrity-report.json"), output.integrity);
|
|
52
|
+
const slugManifest = output.entries.map((e) => e.slug);
|
|
53
|
+
writeJson(join(outDir, "slugs.json"), slugManifest);
|
|
54
|
+
console.log(`[vaza-content] Generated ${output.entries.length} entries`);
|
|
55
|
+
return output;
|
|
56
|
+
}
|
|
57
|
+
function ensureDir(dir) {
|
|
58
|
+
if (!existsSync(dir)) {
|
|
59
|
+
mkdirSync(dir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeJson(path, data) {
|
|
63
|
+
ensureDir(dirname(path));
|
|
64
|
+
writeFileSync(path, JSON.stringify(data, null, 2), "utf-8");
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
buildVazaContent,
|
|
68
|
+
defineVazaContentModule
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|