alinea
Version:
Headless git-based CMS
76 lines (75 loc) • 2.45 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var with_alinea_exports = {};
__export(with_alinea_exports, {
createCMS: () => createCMS,
withAlinea: () => withAlinea
});
module.exports = __toCommonJS(with_alinea_exports);
var import_node_fs = require("node:fs");
var import_node_module = require("node:module");
var import_node_path = require("node:path");
function createCMS() {
throw new Error(
'Alinea was loaded in a CJS environment. Please ensure your project is marked as "type": "module" in package.json.'
);
}
function withAlinea(config) {
let nextVersion = 15;
try {
const require2 = (0, import_node_module.createRequire)((0, import_node_path.resolve)("./index.js"));
const pkgLocation = require2.resolve("next/package.json");
const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgLocation, "utf-8"));
nextVersion = Number(pkg.version.split(".")[0]);
} catch {
console.warn("Alinea could not determine Next.js version, assuming 15+");
}
const imagesConfig = config.images ?? {};
const remotePatterns = [
...imagesConfig.remotePatterns ?? [],
{
protocol: "https",
hostname: "uploads.alinea.cloud"
}
];
const images = {
...imagesConfig,
remotePatterns
};
if (nextVersion < 15)
return {
...config,
experimental: {
...config.experimental,
serverComponentsExternalPackages: [
...config.experimental?.serverComponentsExternalPackages ?? [],
"@alinea/generated"
]
},
images
};
return {
...config,
serverExternalPackages: [
...config.serverExternalPackages ?? [],
"@alinea/generated"
],
images
};
}