@bieberkit/plugin-pages 0.0.0-stage → 0.6.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/CHANGELOG.md +70 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +30 -2
- package/dist/admin/components/DraftForm.js +185 -0
- package/dist/admin/components/PublicComments.js +109 -0
- package/dist/admin/components/PublicationPicker.js +85 -0
- package/dist/admin/index.d.ts +27 -0
- package/dist/admin/index.js +46 -0
- package/dist/admin/lib/publications.js +133 -0
- package/dist/admin/lib/taxonomy-part.d.ts +34 -0
- package/dist/admin/lib/taxonomy-part.js +58 -0
- package/dist/admin/lib/taxonomy.js +62 -0
- package/dist/admin/messages/en.js +63 -0
- package/dist/admin/messages/vi.js +63 -0
- package/dist/admin/messages/zh.js +63 -0
- package/dist/admin/pages/PublicationsPage.js +151 -0
- package/dist/admin/pages/TaxonomyPage.js +216 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +1571 -0
- package/package.json +124 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { listPublications, publicationsKey } from "../lib/publications.js";
|
|
2
|
+
import { useAdminClient, useText } from "@bieberkit/admin-antd";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { Alert, Pagination, Select, Space } from "antd";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/admin/components/PublicationPicker.tsx
|
|
8
|
+
/**
|
|
9
|
+
* BieberKit
|
|
10
|
+
*
|
|
11
|
+
* @file plugins/pages/src/admin/components/PublicationPicker.tsx
|
|
12
|
+
* @description Picks publication identities by title from the editorial list.
|
|
13
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
14
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
15
|
+
* @license Apache-2.0
|
|
16
|
+
*
|
|
17
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License.
|
|
19
|
+
* You may obtain a copy of the License at
|
|
20
|
+
*
|
|
21
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
+
* See the License for the specific language governing permissions and
|
|
27
|
+
* limitations under the License.
|
|
28
|
+
*
|
|
29
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
30
|
+
*/
|
|
31
|
+
function PublicationPicker(props) {
|
|
32
|
+
const client = useAdminClient();
|
|
33
|
+
const text = useText();
|
|
34
|
+
const [page, setPage] = useState(1);
|
|
35
|
+
const [known, setKnown] = useState(props.initial);
|
|
36
|
+
const { value, onChange } = props;
|
|
37
|
+
const query = useQuery({
|
|
38
|
+
queryKey: [...publicationsKey, page],
|
|
39
|
+
queryFn: () => listPublications(client, page)
|
|
40
|
+
});
|
|
41
|
+
const rows = query.data?.data ?? [];
|
|
42
|
+
const choices = new Map([...known, ...rows].map((item) => [item.id, item]));
|
|
43
|
+
const options = [.../* @__PURE__ */ new Set([...value ?? [], ...rows.map(({ id }) => id)])].map((id) => {
|
|
44
|
+
const row = choices.get(id);
|
|
45
|
+
return {
|
|
46
|
+
value: id,
|
|
47
|
+
label: row === void 0 ? id : text("pages." + row.kind) + " · " + (row.title ?? text("pages.untitled"))
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return /* @__PURE__ */ jsxs(Space, {
|
|
51
|
+
orientation: "vertical",
|
|
52
|
+
style: { width: "100%" },
|
|
53
|
+
children: [
|
|
54
|
+
query.error && /* @__PURE__ */ jsx(Alert, {
|
|
55
|
+
type: "error",
|
|
56
|
+
title: query.error.message,
|
|
57
|
+
showIcon: true
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsx(Select, {
|
|
60
|
+
...props.id === void 0 ? {} : { id: props.id },
|
|
61
|
+
style: { width: "100%" },
|
|
62
|
+
mode: "multiple",
|
|
63
|
+
maxCount: 200,
|
|
64
|
+
showSearch: { optionFilterProp: "label" },
|
|
65
|
+
loading: query.isPending,
|
|
66
|
+
value: value ?? [],
|
|
67
|
+
options,
|
|
68
|
+
onChange: (ids) => {
|
|
69
|
+
setKnown(ids.flatMap((id) => choices.get(id) ?? []));
|
|
70
|
+
onChange?.(ids);
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx(Pagination, {
|
|
74
|
+
size: "small",
|
|
75
|
+
current: page,
|
|
76
|
+
total: query.data?.total ?? 0,
|
|
77
|
+
pageSize: 50,
|
|
78
|
+
showSizeChanger: false,
|
|
79
|
+
hideOnSinglePage: true,
|
|
80
|
+
onChange: setPage
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export { PublicationPicker };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BieberKit
|
|
3
|
+
*
|
|
4
|
+
* @file plugins/pages/src/admin/index.ts
|
|
5
|
+
* @description Publishes the localized editor to the admin shell.
|
|
6
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
7
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*
|
|
22
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23
|
+
*/
|
|
24
|
+
import { TaxonomyAdminPart, taxonomyAdmin } from "./lib/taxonomy-part.js";
|
|
25
|
+
import { AdminPart, AdminView } from "@bieberkit/admin-core";
|
|
26
|
+
declare const part: AdminPart<AdminView>;
|
|
27
|
+
export { type TaxonomyAdminPart, part as default, taxonomyAdmin };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { taxonomyAdmin } from "./lib/taxonomy-part.js";
|
|
2
|
+
import { defineAdminPlugin } from "@bieberkit/admin-core";
|
|
3
|
+
// src/admin/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* BieberKit
|
|
6
|
+
*
|
|
7
|
+
* @file plugins/pages/src/admin/index.ts
|
|
8
|
+
* @description Publishes the localized editor to the admin shell.
|
|
9
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
10
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
11
|
+
* @license Apache-2.0
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*
|
|
25
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
26
|
+
*/
|
|
27
|
+
const part = defineAdminPlugin({
|
|
28
|
+
name: "@bieberkit/plugin-pages",
|
|
29
|
+
menu: [{
|
|
30
|
+
page: "/publications",
|
|
31
|
+
group: "content",
|
|
32
|
+
permission: "pages.read"
|
|
33
|
+
}],
|
|
34
|
+
pages: [{
|
|
35
|
+
path: "/publications",
|
|
36
|
+
title: "pages.title",
|
|
37
|
+
permission: "pages.read",
|
|
38
|
+
load: () => import("./pages/PublicationsPage.js")
|
|
39
|
+
}],
|
|
40
|
+
messages: {
|
|
41
|
+
en: async () => ({ default: (await import("./messages/en.js")).en }),
|
|
42
|
+
vi: async () => ({ default: (await import("./messages/vi.js")).vi }),
|
|
43
|
+
zh: async () => ({ default: (await import("./messages/zh.js")).zh })
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export { part as default, taxonomyAdmin };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { AdminApiError } from "@bieberkit/admin-core";
|
|
2
|
+
// src/admin/lib/publications.ts
|
|
3
|
+
/**
|
|
4
|
+
* BieberKit
|
|
5
|
+
*
|
|
6
|
+
* @file plugins/pages/src/admin/lib/publications.ts
|
|
7
|
+
* @description Reads and writes publications through the admin API.
|
|
8
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
9
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
10
|
+
* @license Apache-2.0
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
*/
|
|
26
|
+
const API = "/api/v1/pages/publications";
|
|
27
|
+
const publicationsKey = ["site-publications"];
|
|
28
|
+
const valueOf = (input, key) => typeof input === "object" && input !== null ? Reflect.get(input, key) : void 0;
|
|
29
|
+
const textOf = (input) => typeof input === "string" ? input : void 0;
|
|
30
|
+
function readSummary(input) {
|
|
31
|
+
const id = textOf(valueOf(input, "id"));
|
|
32
|
+
const kind = valueOf(input, "kind");
|
|
33
|
+
const title = textOf(valueOf(input, "title"));
|
|
34
|
+
if (id === void 0 || kind !== "page" && kind !== "article") return void 0;
|
|
35
|
+
return title === void 0 ? {
|
|
36
|
+
id,
|
|
37
|
+
kind
|
|
38
|
+
} : {
|
|
39
|
+
id,
|
|
40
|
+
kind,
|
|
41
|
+
title
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function readDraft(input) {
|
|
45
|
+
const title = textOf(valueOf(input, "title"));
|
|
46
|
+
if (title === void 0) return void 0;
|
|
47
|
+
const slug = textOf(valueOf(input, "slug"));
|
|
48
|
+
const excerpt = textOf(valueOf(input, "excerpt"));
|
|
49
|
+
return {
|
|
50
|
+
title,
|
|
51
|
+
document: valueOf(input, "document"),
|
|
52
|
+
...slug === void 0 ? {} : { slug },
|
|
53
|
+
...excerpt === void 0 ? {} : { excerpt }
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function listPublications(client, page) {
|
|
57
|
+
const result = await client.request("GET", API + "?page=" + String(page));
|
|
58
|
+
const items = valueOf(result, "data");
|
|
59
|
+
const total = valueOf(result, "total");
|
|
60
|
+
const data = Array.isArray(items) ? items.map(readSummary).filter((item) => item !== void 0) : [];
|
|
61
|
+
return {
|
|
62
|
+
data,
|
|
63
|
+
total: typeof total === "number" ? total : data.length
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function newPublication(client, kind) {
|
|
67
|
+
return textOf(valueOf(valueOf(await client.request("POST", API, { body: { kind } }), "data"), "id"));
|
|
68
|
+
}
|
|
69
|
+
function draftsApi(client, id, locale) {
|
|
70
|
+
const root = API + "/" + encodeURIComponent(id);
|
|
71
|
+
const language = encodeURIComponent(locale);
|
|
72
|
+
const draft = root + "/drafts/" + language;
|
|
73
|
+
return {
|
|
74
|
+
async get() {
|
|
75
|
+
try {
|
|
76
|
+
return readDraft(valueOf(await client.request("GET", draft), "data")) ?? null;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof AdminApiError && error.status === 404) return null;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async save(body) {
|
|
83
|
+
return readDraft(valueOf(await client.request("PUT", draft, { body }), "data"));
|
|
84
|
+
},
|
|
85
|
+
async publish() {
|
|
86
|
+
return textOf(valueOf(valueOf(await client.request("POST", root + "/publish/" + language), "data"), "slug"));
|
|
87
|
+
},
|
|
88
|
+
async preview() {
|
|
89
|
+
const result = await client.request("POST", root + "/preview/" + language);
|
|
90
|
+
const address = textOf(valueOf(valueOf(result, "data"), "url"));
|
|
91
|
+
const url = address === void 0 ? null : URL.parse(address);
|
|
92
|
+
if (url?.protocol === "https:" || url?.protocol === "http:") return url.href;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function articleCommentsKey(id, locale) {
|
|
97
|
+
return [
|
|
98
|
+
...publicationsKey,
|
|
99
|
+
"comments",
|
|
100
|
+
id,
|
|
101
|
+
locale
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
function articleCommentsApi(client, id, locale) {
|
|
105
|
+
const url = API + "/" + encodeURIComponent(id) + "/comments/" + encodeURIComponent(locale);
|
|
106
|
+
return {
|
|
107
|
+
async get() {
|
|
108
|
+
try {
|
|
109
|
+
const items = valueOf(await client.request("GET", url), "data");
|
|
110
|
+
return Array.isArray(items) ? items.flatMap((item) => {
|
|
111
|
+
const key = textOf(valueOf(item, "id"));
|
|
112
|
+
const body = textOf(valueOf(item, "body"));
|
|
113
|
+
const name = textOf(valueOf(item, "name"));
|
|
114
|
+
if (key === void 0 || body === void 0) return [];
|
|
115
|
+
return [name === void 0 ? {
|
|
116
|
+
id: key,
|
|
117
|
+
body
|
|
118
|
+
} : {
|
|
119
|
+
id: key,
|
|
120
|
+
body,
|
|
121
|
+
name
|
|
122
|
+
}];
|
|
123
|
+
}) : [];
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (error instanceof AdminApiError && error.status === 404) return null;
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
save: (body) => client.request("POST", url, { body }),
|
|
130
|
+
remove: (comment) => client.request("DELETE", url + "/" + encodeURIComponent(comment))
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export { articleCommentsApi, articleCommentsKey, draftsApi, listPublications, newPublication, publicationsKey };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BieberKit
|
|
3
|
+
*
|
|
4
|
+
* @file plugins/pages/src/admin/lib/taxonomy-part.ts
|
|
5
|
+
* @description Declares the shared taxonomy admin screens and their localized menu entries.
|
|
6
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
7
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*
|
|
22
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23
|
+
*/
|
|
24
|
+
import { AdminPart, AdminView, Locale } from "@bieberkit/admin-core";
|
|
25
|
+
export type TaxonomyAdminPart = AdminPart<AdminView>;
|
|
26
|
+
interface Labels {
|
|
27
|
+
readonly title: string;
|
|
28
|
+
readonly term: string;
|
|
29
|
+
readonly read: string;
|
|
30
|
+
readonly manage: string;
|
|
31
|
+
}
|
|
32
|
+
/** Declares the admin entry of a publication taxonomy. */
|
|
33
|
+
export declare function taxonomyAdmin(module: "categories" | "tags", labels: Readonly<Record<Locale, Labels>>): TaxonomyAdminPart;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineAdminPlugin } from "@bieberkit/admin-core";
|
|
2
|
+
// src/admin/lib/taxonomy-part.ts
|
|
3
|
+
/**
|
|
4
|
+
* BieberKit
|
|
5
|
+
*
|
|
6
|
+
* @file plugins/pages/src/admin/lib/taxonomy-part.ts
|
|
7
|
+
* @description Declares the shared taxonomy admin screens and their localized menu entries.
|
|
8
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
9
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
10
|
+
* @license Apache-2.0
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
*/
|
|
26
|
+
/** Declares the admin entry of a publication taxonomy. */
|
|
27
|
+
function taxonomyAdmin(module, labels) {
|
|
28
|
+
const path = "/" + module;
|
|
29
|
+
const permission = module + ".read";
|
|
30
|
+
const manage = module + ".manage";
|
|
31
|
+
const title = module + ".title";
|
|
32
|
+
const messages = (language) => Promise.resolve({ default: {
|
|
33
|
+
[title]: labels[language].title,
|
|
34
|
+
[module + ".term"]: labels[language].term,
|
|
35
|
+
[module + ".codes.permission." + permission]: labels[language].read,
|
|
36
|
+
[module + ".codes.permission." + manage]: labels[language].manage
|
|
37
|
+
} });
|
|
38
|
+
return defineAdminPlugin({
|
|
39
|
+
name: "@bieberkit/plugin-" + module,
|
|
40
|
+
menu: [{
|
|
41
|
+
page: path,
|
|
42
|
+
group: "content",
|
|
43
|
+
permission
|
|
44
|
+
}],
|
|
45
|
+
pages: [{
|
|
46
|
+
path,
|
|
47
|
+
title,
|
|
48
|
+
permission,
|
|
49
|
+
load: async () => ({ default: (await import("../pages/TaxonomyPage.js")).taxonomyPage(module) })
|
|
50
|
+
}],
|
|
51
|
+
messages: {
|
|
52
|
+
en: () => messages("en"),
|
|
53
|
+
vi: () => messages("vi"),
|
|
54
|
+
zh: () => messages("zh")
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export { taxonomyAdmin };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/admin/lib/taxonomy.ts
|
|
2
|
+
/**
|
|
3
|
+
* BieberKit
|
|
4
|
+
*
|
|
5
|
+
* @file plugins/pages/src/admin/lib/taxonomy.ts
|
|
6
|
+
* @description Reads taxonomy records and their saved publication choices for the admin.
|
|
7
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
8
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
9
|
+
* @license Apache-2.0
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
const record = (value) => typeof value === "object" && value !== null;
|
|
26
|
+
function publicationOf(value) {
|
|
27
|
+
if (!record(value)) return [];
|
|
28
|
+
const { publicationId, kind, title } = value;
|
|
29
|
+
if (typeof publicationId !== "string" || kind !== "page" && kind !== "article") return [];
|
|
30
|
+
return [{
|
|
31
|
+
id: publicationId,
|
|
32
|
+
kind,
|
|
33
|
+
...typeof title === "string" ? { title } : {}
|
|
34
|
+
}];
|
|
35
|
+
}
|
|
36
|
+
function termOf(value) {
|
|
37
|
+
if (!record(value)) return void 0;
|
|
38
|
+
const { id, name, slug, version, publications } = value;
|
|
39
|
+
if (typeof id !== "string" || typeof name !== "string" || typeof slug !== "string" || typeof version !== "number") return void 0;
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
name,
|
|
43
|
+
slug,
|
|
44
|
+
version,
|
|
45
|
+
publications: Array.isArray(publications) ? publications.flatMap(publicationOf) : []
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function readTerm(response) {
|
|
49
|
+
return record(response) ? termOf(response["data"]) : void 0;
|
|
50
|
+
}
|
|
51
|
+
function readTerms(response) {
|
|
52
|
+
if (!record(response) || !Array.isArray(response["data"])) return {
|
|
53
|
+
data: [],
|
|
54
|
+
total: 0
|
|
55
|
+
};
|
|
56
|
+
const data = response["data"].map(termOf).filter((row) => row !== void 0);
|
|
57
|
+
return {
|
|
58
|
+
data,
|
|
59
|
+
total: typeof response["total"] === "number" ? response["total"] : data.length
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export { readTerm, readTerms };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/admin/messages/en.ts
|
|
2
|
+
/**
|
|
3
|
+
* BieberKit
|
|
4
|
+
*
|
|
5
|
+
* @file plugins/pages/src/admin/messages/en.ts
|
|
6
|
+
* @description Labels for the pages admin screen in en.
|
|
7
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
8
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
9
|
+
* @license Apache-2.0
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
const en = {
|
|
26
|
+
"pages.title": "Publications",
|
|
27
|
+
"pages.page": "Page",
|
|
28
|
+
"pages.article": "Article",
|
|
29
|
+
"pages.createPage": "New page",
|
|
30
|
+
"pages.createArticle": "New article",
|
|
31
|
+
"pages.name": "Title",
|
|
32
|
+
"pages.locale": "Locale",
|
|
33
|
+
"pages.slug": "Slug",
|
|
34
|
+
"pages.excerpt": "Excerpt",
|
|
35
|
+
"pages.content": "Content",
|
|
36
|
+
"pages.load": "Load translation",
|
|
37
|
+
"pages.save": "Save draft",
|
|
38
|
+
"pages.discard": "Discard changes",
|
|
39
|
+
"pages.publish": "Publish",
|
|
40
|
+
"pages.preview": "Create preview link",
|
|
41
|
+
"pages.openPreview": "Open preview",
|
|
42
|
+
"pages.empty": "No publications",
|
|
43
|
+
"pages.untitled": "Untitled",
|
|
44
|
+
"pages.saved": "Draft saved",
|
|
45
|
+
"pages.published": "Published",
|
|
46
|
+
"pages.edit": "Edit",
|
|
47
|
+
"pages.choose": "Choose a publication",
|
|
48
|
+
"pages.retry": "Try again",
|
|
49
|
+
"pages.codes.permission.pages.read": "Read publications",
|
|
50
|
+
"pages.codes.permission.pages.manage": "Edit publications",
|
|
51
|
+
"pages.codes.permission.pages.publish": "Publish pages and articles",
|
|
52
|
+
"pages.comments": "Public comments",
|
|
53
|
+
"pages.commentsAfterPublish": "Publish the article before adding public comments.",
|
|
54
|
+
"pages.commentName": "Display name",
|
|
55
|
+
"pages.commentBody": "Comment",
|
|
56
|
+
"pages.commentAdd": "Add public comment",
|
|
57
|
+
"pages.commentRemove": "Remove public comment",
|
|
58
|
+
"pages.commentConfirm": "Remove this public comment?",
|
|
59
|
+
"pages.taxonomyName": "Name",
|
|
60
|
+
"pages.taxonomyView": "View",
|
|
61
|
+
"pages.taxonomyEmpty": "No publications assigned."
|
|
62
|
+
};
|
|
63
|
+
export { en };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/admin/messages/vi.ts
|
|
2
|
+
/**
|
|
3
|
+
* BieberKit
|
|
4
|
+
*
|
|
5
|
+
* @file plugins/pages/src/admin/messages/vi.ts
|
|
6
|
+
* @description Labels for the pages admin screen in vi.
|
|
7
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
8
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
9
|
+
* @license Apache-2.0
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
const vi = {
|
|
26
|
+
"pages.title": "Xuất bản nội dung",
|
|
27
|
+
"pages.page": "Trang",
|
|
28
|
+
"pages.article": "Bài viết",
|
|
29
|
+
"pages.createPage": "Trang mới",
|
|
30
|
+
"pages.createArticle": "Bài viết mới",
|
|
31
|
+
"pages.name": "Tiêu đề",
|
|
32
|
+
"pages.locale": "Ngôn ngữ",
|
|
33
|
+
"pages.slug": "Slug",
|
|
34
|
+
"pages.excerpt": "Tóm tắt",
|
|
35
|
+
"pages.content": "Nội dung",
|
|
36
|
+
"pages.load": "Mở bản dịch",
|
|
37
|
+
"pages.save": "Lưu bản nháp",
|
|
38
|
+
"pages.discard": "Bỏ thay đổi",
|
|
39
|
+
"pages.publish": "Xuất bản",
|
|
40
|
+
"pages.preview": "Tạo liên kết xem trước",
|
|
41
|
+
"pages.openPreview": "Mở bản xem trước",
|
|
42
|
+
"pages.empty": "Chưa có nội dung",
|
|
43
|
+
"pages.untitled": "Chưa có tiêu đề",
|
|
44
|
+
"pages.saved": "Đã lưu bản nháp",
|
|
45
|
+
"pages.published": "Đã xuất bản",
|
|
46
|
+
"pages.edit": "Sửa",
|
|
47
|
+
"pages.choose": "Chọn nội dung để chỉnh sửa",
|
|
48
|
+
"pages.retry": "Thử lại",
|
|
49
|
+
"pages.codes.permission.pages.read": "Xem nội dung",
|
|
50
|
+
"pages.codes.permission.pages.manage": "Sửa nội dung",
|
|
51
|
+
"pages.codes.permission.pages.publish": "Xuất bản trang và bài viết",
|
|
52
|
+
"pages.comments": "Bình luận công khai",
|
|
53
|
+
"pages.commentsAfterPublish": "Xuất bản bài viết trước khi thêm bình luận công khai.",
|
|
54
|
+
"pages.commentName": "Tên hiển thị",
|
|
55
|
+
"pages.commentBody": "Bình luận",
|
|
56
|
+
"pages.commentAdd": "Thêm bình luận công khai",
|
|
57
|
+
"pages.commentRemove": "Xóa bình luận công khai",
|
|
58
|
+
"pages.commentConfirm": "Xóa bình luận công khai này?",
|
|
59
|
+
"pages.taxonomyName": "Tên",
|
|
60
|
+
"pages.taxonomyView": "Xem",
|
|
61
|
+
"pages.taxonomyEmpty": "Chưa gắn nội dung nào."
|
|
62
|
+
};
|
|
63
|
+
export { vi };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/admin/messages/zh.ts
|
|
2
|
+
/**
|
|
3
|
+
* BieberKit
|
|
4
|
+
*
|
|
5
|
+
* @file plugins/pages/src/admin/messages/zh.ts
|
|
6
|
+
* @description Labels for the pages admin screen in zh.
|
|
7
|
+
* @author Bieber Kieu <kieutrongthien@gmail.com>
|
|
8
|
+
* @copyright Copyright (c) 2026 Bieber Kieu
|
|
9
|
+
* @license Apache-2.0
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
const zh = {
|
|
26
|
+
"pages.title": "内容发布",
|
|
27
|
+
"pages.page": "页面",
|
|
28
|
+
"pages.article": "文章",
|
|
29
|
+
"pages.createPage": "新建页面",
|
|
30
|
+
"pages.createArticle": "新建文章",
|
|
31
|
+
"pages.name": "标题",
|
|
32
|
+
"pages.locale": "语言",
|
|
33
|
+
"pages.slug": "路径名",
|
|
34
|
+
"pages.excerpt": "摘要",
|
|
35
|
+
"pages.content": "内容",
|
|
36
|
+
"pages.load": "打开译文",
|
|
37
|
+
"pages.save": "保存草稿",
|
|
38
|
+
"pages.discard": "放弃更改",
|
|
39
|
+
"pages.publish": "发布",
|
|
40
|
+
"pages.preview": "创建预览链接",
|
|
41
|
+
"pages.openPreview": "打开预览",
|
|
42
|
+
"pages.empty": "暂无内容",
|
|
43
|
+
"pages.untitled": "未命名",
|
|
44
|
+
"pages.saved": "草稿已保存",
|
|
45
|
+
"pages.published": "已发布",
|
|
46
|
+
"pages.edit": "编辑",
|
|
47
|
+
"pages.choose": "选择要编辑的内容",
|
|
48
|
+
"pages.retry": "重试",
|
|
49
|
+
"pages.codes.permission.pages.read": "查看内容",
|
|
50
|
+
"pages.codes.permission.pages.manage": "编辑内容",
|
|
51
|
+
"pages.codes.permission.pages.publish": "发布页面和文章",
|
|
52
|
+
"pages.comments": "公开评论",
|
|
53
|
+
"pages.commentsAfterPublish": "请先发布文章,再添加公开评论。",
|
|
54
|
+
"pages.commentName": "显示名称",
|
|
55
|
+
"pages.commentBody": "评论",
|
|
56
|
+
"pages.commentAdd": "添加公开评论",
|
|
57
|
+
"pages.commentRemove": "删除公开评论",
|
|
58
|
+
"pages.commentConfirm": "是否删除此公开评论?",
|
|
59
|
+
"pages.taxonomyName": "名称",
|
|
60
|
+
"pages.taxonomyView": "查看",
|
|
61
|
+
"pages.taxonomyEmpty": "尚未关联任何内容。"
|
|
62
|
+
};
|
|
63
|
+
export { zh };
|