@vedyua/cms 0.1.1 → 0.1.2
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/README.md +10 -0
- package/dist/admin-bar.js +7 -15
- package/dist/admin-bar.js.map +1 -1
- package/dist/styles.css +2 -7
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -30,6 +30,16 @@ npm run build
|
|
|
30
30
|
npm run dev
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Playground (single-page preview)
|
|
34
|
+
|
|
35
|
+
Run a local Vite page that imports `src/` directly (HMR) and mocks save/publish APIs:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run playground
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Open http://localhost:5173 — toggle edit mode, click outlined text, try **Save draft** / **Publish** / **Page settings**.
|
|
42
|
+
|
|
33
43
|
## Publish (maintainers)
|
|
34
44
|
|
|
35
45
|
```bash
|
package/dist/admin-bar.js
CHANGED
|
@@ -2,26 +2,23 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useContentCms } from "./context";
|
|
5
|
-
import { getDocument
|
|
5
|
+
import { getDocument } from "./define";
|
|
6
6
|
import { PageSettingsPanel } from "./page-settings";
|
|
7
7
|
function AdminBar({ title = "Content CMS" }) {
|
|
8
8
|
const {
|
|
9
9
|
config,
|
|
10
10
|
editMode,
|
|
11
|
-
session,
|
|
12
11
|
publishEnabled,
|
|
13
12
|
dirtyCount,
|
|
14
13
|
saving,
|
|
15
14
|
publishing,
|
|
16
15
|
lastError,
|
|
17
|
-
lastPublishSha,
|
|
18
16
|
saveDrafts,
|
|
19
17
|
publish,
|
|
20
18
|
discardDrafts
|
|
21
19
|
} = useContentCms();
|
|
22
20
|
const [pageSettingsOpen, setPageSettingsOpen] = useState(false);
|
|
23
21
|
if (!editMode) return null;
|
|
24
|
-
const fields = listTextFields(config);
|
|
25
22
|
const busy = saving || publishing;
|
|
26
23
|
const logoutPath = config.logoutPath ?? "/api/content/auth/logout";
|
|
27
24
|
const seoDocumentName = config.seoDocument ?? "seo";
|
|
@@ -30,13 +27,10 @@ function AdminBar({ title = "Content CMS" }) {
|
|
|
30
27
|
/* @__PURE__ */ jsxs("div", { className: "scms-admin-bar__main", children: [
|
|
31
28
|
/* @__PURE__ */ jsxs("div", { className: "scms-admin-bar__brand", children: [
|
|
32
29
|
/* @__PURE__ */ jsx("strong", { children: title }),
|
|
33
|
-
/* @__PURE__ */ jsxs("span", { className: "scms-admin-bar__meta", children: [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
dirtyCount > 0 ? `${dirtyCount} unsaved` : "clean",
|
|
38
|
-
lastPublishSha ? ` \xB7 published ${lastPublishSha.slice(0, 7)}` : ""
|
|
39
|
-
] })
|
|
30
|
+
dirtyCount > 0 ? /* @__PURE__ */ jsxs("span", { className: "scms-admin-bar__meta", children: [
|
|
31
|
+
dirtyCount,
|
|
32
|
+
" unsaved"
|
|
33
|
+
] }) : null
|
|
40
34
|
] }),
|
|
41
35
|
/* @__PURE__ */ jsxs("div", { className: "scms-admin-bar__actions", children: [
|
|
42
36
|
hasPageSettings ? /* @__PURE__ */ jsx(
|
|
@@ -45,7 +39,6 @@ function AdminBar({ title = "Content CMS" }) {
|
|
|
45
39
|
type: "button",
|
|
46
40
|
className: `scms-btn ${pageSettingsOpen ? "scms-btn--primary" : "scms-btn--ghost"}`,
|
|
47
41
|
onClick: () => setPageSettingsOpen((open) => !open),
|
|
48
|
-
title: "Edit title, description, favicon and SEO for pages",
|
|
49
42
|
children: "Page settings"
|
|
50
43
|
}
|
|
51
44
|
) : null,
|
|
@@ -76,7 +69,7 @@ function AdminBar({ title = "Content CMS" }) {
|
|
|
76
69
|
className: "scms-btn scms-btn--primary",
|
|
77
70
|
disabled: !publishEnabled || busy,
|
|
78
71
|
onClick: () => void publish(),
|
|
79
|
-
title: !publishEnabled ? "Publish adapter is not configured" :
|
|
72
|
+
title: !publishEnabled ? "Publish adapter is not configured" : void 0,
|
|
80
73
|
children: publishing ? "Building\u2026" : "Publish"
|
|
81
74
|
}
|
|
82
75
|
),
|
|
@@ -84,8 +77,7 @@ function AdminBar({ title = "Content CMS" }) {
|
|
|
84
77
|
] })
|
|
85
78
|
] }),
|
|
86
79
|
pageSettingsOpen ? /* @__PURE__ */ jsx(PageSettingsPanel, { open: pageSettingsOpen, onClose: () => setPageSettingsOpen(false) }) : null,
|
|
87
|
-
lastError ? /* @__PURE__ */ jsx("p", { className: "scms-admin-bar__error", children: lastError }) : null
|
|
88
|
-
/* @__PURE__ */ jsx("p", { className: "scms-admin-bar__hint", children: "Save writes JSON on disk. Publish rebuilds the site in the background \u2014 the live site stays up until the new build is ready; a failed build rolls back." })
|
|
80
|
+
lastError ? /* @__PURE__ */ jsx("p", { className: "scms-admin-bar__error", children: lastError }) : null
|
|
89
81
|
] });
|
|
90
82
|
}
|
|
91
83
|
export {
|
package/dist/admin-bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/admin-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\n\nimport { useContentCms } from \"./context\";\nimport { getDocument
|
|
1
|
+
{"version":3,"sources":["../src/admin-bar.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\n\nimport { useContentCms } from \"./context\";\nimport { getDocument } from \"./define\";\nimport { PageSettingsPanel } from \"./page-settings\";\n\nexport type AdminBarProps = {\n /** Optional brand label shown on the left. */\n title?: string;\n};\n\n/**\n * Floating toolbar for edit mode. Hides itself when `editMode` is false.\n */\nexport function AdminBar({ title = \"Content CMS\" }: AdminBarProps) {\n const {\n config,\n editMode,\n publishEnabled,\n dirtyCount,\n saving,\n publishing,\n lastError,\n saveDrafts,\n publish,\n discardDrafts,\n } = useContentCms();\n const [pageSettingsOpen, setPageSettingsOpen] = useState(false);\n\n if (!editMode) return null;\n\n const busy = saving || publishing;\n const logoutPath = config.logoutPath ?? \"/api/content/auth/logout\";\n const seoDocumentName = config.seoDocument ?? \"seo\";\n const hasPageSettings =\n Boolean(getDocument(config, seoDocumentName)) && (config.pages?.length ?? 0) > 0;\n\n return (\n <div className=\"scms-admin-bar\" role=\"region\" aria-label=\"Content editor toolbar\">\n <div className=\"scms-admin-bar__main\">\n <div className=\"scms-admin-bar__brand\">\n <strong>{title}</strong>\n {dirtyCount > 0 ? (\n <span className=\"scms-admin-bar__meta\">\n {dirtyCount} unsaved\n </span>\n ) : null}\n </div>\n <div className=\"scms-admin-bar__actions\">\n {hasPageSettings ? (\n <button\n type=\"button\"\n className={`scms-btn ${pageSettingsOpen ? \"scms-btn--primary\" : \"scms-btn--ghost\"}`}\n onClick={() => setPageSettingsOpen((open) => !open)}\n >\n Page settings\n </button>\n ) : null}\n <button\n type=\"button\"\n className=\"scms-btn scms-btn--ghost\"\n disabled={dirtyCount === 0 || busy}\n onClick={() => discardDrafts()}\n >\n Discard\n </button>\n <button\n type=\"button\"\n className=\"scms-btn scms-btn--ghost\"\n disabled={dirtyCount === 0 || busy}\n onClick={() => void saveDrafts()}\n >\n {saving ? \"Saving…\" : \"Save draft\"}\n </button>\n <button\n type=\"button\"\n className=\"scms-btn scms-btn--primary\"\n disabled={!publishEnabled || busy}\n onClick={() => void publish()}\n title={!publishEnabled ? \"Publish adapter is not configured\" : undefined}\n >\n {publishing ? \"Building…\" : \"Publish\"}\n </button>\n <a className=\"scms-btn scms-btn--ghost\" href={logoutPath}>\n Log out\n </a>\n </div>\n </div>\n {pageSettingsOpen ? (\n <PageSettingsPanel open={pageSettingsOpen} onClose={() => setPageSettingsOpen(false)} />\n ) : null}\n {lastError ? <p className=\"scms-admin-bar__error\">{lastError}</p> : null}\n </div>\n );\n}\n"],"mappings":";AA2CU,cAEE,YAFF;AAzCV,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,y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;AAAA;AAAA,QACxB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,UAAU,CAAC,kBAAkB;AAAA,YAC7B,SAAS,MAAM,KAAK,QAAQ;AAAA,YAC5B,OAAO,CAAC,iBAAiB,sCAAsC;AAAA,YAE9D,uBAAa,mBAAc;AAAA;AAAA,QAC9B;AAAA,QACA,oBAAC,OAAE,WAAU,4BAA2B,MAAM,YAAY,qBAE1D;AAAA,SACF;AAAA,OACF;AAAA,IACC,mBACC,oBAAC,qBAAkB,MAAM,kBAAkB,SAAS,MAAM,oBAAoB,KAAK,GAAG,IACpF;AAAA,IACH,YAAY,oBAAC,OAAE,WAAU,yBAAyB,qBAAU,IAAO;AAAA,KACtE;AAEJ;","names":[]}
|
package/dist/styles.css
CHANGED
|
@@ -83,17 +83,12 @@
|
|
|
83
83
|
letter-spacing: 0.02em;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.scms-admin-bar__meta
|
|
87
|
-
.scms-admin-bar__hint {
|
|
86
|
+
.scms-admin-bar__meta {
|
|
88
87
|
color: var(--scms-muted);
|
|
89
88
|
font-size: 12px;
|
|
90
89
|
margin: 0;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
.scms-admin-bar__hint {
|
|
94
|
-
margin-top: 8px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
92
|
.scms-admin-bar__error {
|
|
98
93
|
margin: 8px 0 0;
|
|
99
94
|
color: var(--scms-danger);
|
|
@@ -232,7 +227,7 @@
|
|
|
232
227
|
}
|
|
233
228
|
|
|
234
229
|
body:has(.scms-admin-bar) {
|
|
235
|
-
scroll-padding-top:
|
|
230
|
+
scroll-padding-top: 64px;
|
|
236
231
|
}
|
|
237
232
|
|
|
238
233
|
.scms-visually-hidden {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vedyua/cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Universal inline content editor for static JSON sites (Next.js)",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup && cp src/styles.css dist/styles.css",
|
|
34
34
|
"dev": "tsup --watch --onSuccess \"cp src/styles.css dist/styles.css\"",
|
|
35
|
+
"playground": "vite --config preview/vite.config.ts",
|
|
35
36
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
36
37
|
"lint": "tsc -p tsconfig.json --noEmit",
|
|
37
38
|
"prepare": "npm run build",
|
|
@@ -49,10 +50,12 @@
|
|
|
49
50
|
"@types/node": "^24.12.3",
|
|
50
51
|
"@types/react": "^19.2.14",
|
|
51
52
|
"@types/react-dom": "^19.2.3",
|
|
53
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
52
54
|
"react": "^19.2.6",
|
|
53
55
|
"react-dom": "^19.2.6",
|
|
54
56
|
"tsup": "^8.5.0",
|
|
55
|
-
"typescript": "~6.0.2"
|
|
57
|
+
"typescript": "~6.0.2",
|
|
58
|
+
"vite": "^7.2.4"
|
|
56
59
|
},
|
|
57
60
|
"keywords": [
|
|
58
61
|
"cms",
|