@goodfellow-cms/admin 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/dev.d.ts +8 -0
- package/dist/dev.js +60 -0
- package/dist/google-fonts-C1DHu6V8.js +1956 -0
- package/dist/index.d.ts +745 -0
- package/dist/index.js +9712 -0
- package/package.json +79 -3
- package/styles.css +1474 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Goodfellow contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @goodfellow-cms/admin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The admin panel: the visual editor for a site's pages, collections, media, header and footer, and settings, which publishes to the site's repository from the browser.
|
|
4
|
+
|
|
5
|
+
It's built with each site's own config, so the editor always has the site's blocks: `goodfellow build` adds it at `/admin`, and Next.js sites render `GoodfellowAdmin` from `@goodfellow-cms/next` there.
|
|
6
|
+
|
|
7
|
+
[Goodfellow](https://github.com/goodfellow-cms/goodfellow-cms) is a website builder for people who aren't developers, with no server or database: pages are files in your own GitHub or GitLab repository, edited in a visual editor built on [Puck](https://puckeditor.com). To start a new site, run `npm create goodfellow@latest my-site`. See the [documentation](https://goodfellow-cms.github.io/goodfellow-cms/) for everything else.
|
|
8
|
+
|
|
9
|
+
More in the docs: [Edit pages](https://goodfellow-cms.github.io/goodfellow-cms/docs/edit-pages).
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
MIT
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContentStore } from "@goodfellow-cms/core";
|
|
2
|
+
//#region src/dev.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A content store that reads and writes the site's files through
|
|
5
|
+
* `goodfellow dev`. For local development only: it is never part of a built site.
|
|
6
|
+
*/
|
|
7
|
+
export declare function localStore(apiBase?: string): ContentStore;
|
|
8
|
+
//#endregion
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ConflictError, decodeBase64, encodeBase64Bytes } from "@goodfellow-cms/core";
|
|
2
|
+
//#region src/dev.ts
|
|
3
|
+
/**
|
|
4
|
+
* A content store that reads and writes the site's files through
|
|
5
|
+
* `goodfellow dev`. For local development only: it is never part of a built site.
|
|
6
|
+
*/
|
|
7
|
+
function localStore(apiBase = "/__goodfellow/api") {
|
|
8
|
+
/** Calls the development API. A 404 means "no such file" only where `missingIsFine` says so. */
|
|
9
|
+
async function request(path, init = {}, missingIsFine = false) {
|
|
10
|
+
const [endpoint, query] = path.split("?", 2);
|
|
11
|
+
const response = await fetch(`${apiBase}/${endpoint}/${query === void 0 ? "" : `?${query}`}`, {
|
|
12
|
+
...init,
|
|
13
|
+
headers: {
|
|
14
|
+
"x-goodfellow-request": "1",
|
|
15
|
+
...init.headers
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (response.status === 409) throw new ConflictError();
|
|
19
|
+
if (response.status === 404 && !missingIsFine) throw new Error(`The development server's API isn't at ${new URL(apiBase, location.href).href} (it answered 404). Open the admin panel at the address \`goodfellow dev\` printed when it started.`);
|
|
20
|
+
if (!response.ok && response.status !== 404) {
|
|
21
|
+
const body = await response.json().catch(() => ({}));
|
|
22
|
+
throw new Error(body.message ?? `The development server answered ${response.status} (${body.error ?? "error"}).`);
|
|
23
|
+
}
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
async read(path) {
|
|
28
|
+
const response = await request(`file?path=${encodeURIComponent(path)}`, {}, true);
|
|
29
|
+
if (response.status === 404) return void 0;
|
|
30
|
+
return (await response.json()).content;
|
|
31
|
+
},
|
|
32
|
+
async readBytes(path) {
|
|
33
|
+
const response = await request(`file?path=${encodeURIComponent(path)}&as=bytes`, {}, true);
|
|
34
|
+
if (response.status === 404) return void 0;
|
|
35
|
+
return decodeBase64((await response.json()).base64);
|
|
36
|
+
},
|
|
37
|
+
async list(dir) {
|
|
38
|
+
return (await (await request(`files?dir=${encodeURIComponent(dir)}`)).json()).files;
|
|
39
|
+
},
|
|
40
|
+
async revision() {
|
|
41
|
+
return (await (await request("revision")).json()).revision;
|
|
42
|
+
},
|
|
43
|
+
async write(changes, { message, expectedRevision }) {
|
|
44
|
+
return await (await request("write", {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: { "content-type": "application/json" },
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
changes: changes.map((change) => "bytes" in change ? {
|
|
49
|
+
path: change.path,
|
|
50
|
+
base64: encodeBase64Bytes(change.bytes)
|
|
51
|
+
} : change),
|
|
52
|
+
message,
|
|
53
|
+
expectedRevision
|
|
54
|
+
})
|
|
55
|
+
})).json();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { localStore };
|