@indiekit/post-type-reply
Version:
Reply post type for Indiekit
44 lines (38 loc) • 908 B
JavaScript
import { isRequired } from "@indiekit/util";
const defaults = {
name: "Reply",
fields: {
"in-reply-to": { required: true },
content: { required: true },
category: {},
"post-status": {},
published: { required: true },
visibility: {},
},
};
export default class ReplyPostType {
constructor(options = {}) {
this.name = "Reply post type";
this.options = { ...defaults, ...options };
}
get config() {
return {
name: this.options.name,
h: "entry",
fields: this.options.fields,
};
}
get validationSchemas() {
return {
"in-reply-to": {
errorMessage: (value, { req }) =>
req.__(`posts.error.url.empty`, "https://example.org"),
exists: { if: (value, { req }) => isRequired(req, "in-reply-to") },
isURL: true,
},
};
}
init(Indiekit) {
Indiekit.addPostType("reply", this);
}
}