34 lines
991 B
TypeScript
34 lines
991 B
TypeScript
import { App, Collection, FieldTypes, Policies } from "sealious";
|
|
import { CRUDRoles } from "../policy-types/roles.js";
|
|
import assert from "assert";
|
|
import TheApp from "../app.js";
|
|
|
|
export default class Pages extends Collection {
|
|
fields = {
|
|
url: new FieldTypes.Text().setRequired(true),
|
|
content: new FieldTypes.JDD().setRequired(true),
|
|
domain: new FieldTypes.Text(),
|
|
title: new FieldTypes.Text(),
|
|
heading: new FieldTypes.Text(),
|
|
description: new FieldTypes.Text(),
|
|
imageForMetadata: new FieldTypes.Image(),
|
|
hideNavigation: new FieldTypes.Boolean(),
|
|
};
|
|
policies = CRUDRoles(["pages"], { show: new Policies.Public() });
|
|
|
|
async init(app: App, name: string) {
|
|
assert(app instanceof TheApp);
|
|
await super.init(app, name);
|
|
app.on("started", async () => {
|
|
const all_pages = await app.collections.pages.suList().fetch();
|
|
if (all_pages.empty) {
|
|
await app.collections.pages.suCreate({
|
|
url: "/",
|
|
content: [],
|
|
title: "Homepage",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|