UNPKG

@indiekit/post-type-like

Version:

Like post type for Indiekit

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