deno.land / x / lume@v2.1.4 / cli / cms.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { log } from "../core/utils/log.ts";import { localIp } from "../core/utils/net.ts";import { toFileUrl } from "../deps/path.ts";import { getConfigFile } from "../core/utils/lume_config.ts";import { setEnv } from "../core/utils/env.ts";import { createSite } from "./run.ts";import { adapter } from "../cms.ts";
export async function runCms( config: string | undefined,) { const site = await createSite(config); const cmsConfig = await getConfigFile(undefined, ["_cms.ts", "_cms.js"]);
if (!cmsConfig) { throw new Error("CMS config file not found"); }
const mod = await import(toFileUrl(cmsConfig).href);
if (!mod.default) { throw new Error("CMS instance is not found"); }
// Enable drafts in the CMS setEnv("LUME_DRAFTS", "true");
const cms = mod.default; const app = await adapter({ site, cms }); const { port } = site.options.server; const { basePath } = cms.options;
Deno.serve({ port, handler: app.fetch, onListen() { const ipAddr = localIp();
log.info(" CMS server started at:"); log.info(` <green>http://localhost:${port}${basePath}</green> (local)`);
if (ipAddr) { log.info( ` <green>http://${ipAddr}:${port}${basePath}</green> (network)`, ); } }, });}
lume

Version Info

Tagged at
7 months ago