From 0ad3d3ce23b47eeccd46d063812372de8b9b190b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 1 Feb 2022 16:41:45 -0400 Subject: news entry data --- src/thing/news-entry.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/thing/news-entry.js (limited to 'src/thing/news-entry.js') diff --git a/src/thing/news-entry.js b/src/thing/news-entry.js new file mode 100644 index 00000000..2db2f37c --- /dev/null +++ b/src/thing/news-entry.js @@ -0,0 +1,49 @@ +import Thing from './thing.js'; + +import { + isDate, + isDirectory, + isName, +} from './validators.js'; + +export default class NewsEntry extends Thing { + static [Thing.referenceType] = 'news-entry'; + + static propertyDescriptors = { + // Update & expose + + name: { + flags: {update: true, expose: true}, + update: {validate: isName} + }, + + directory: { + flags: {update: true, expose: true}, + update: {validate: isDirectory}, + expose: Thing.directoryExpose + }, + + date: { + flags: {update: true, expose: true}, + update: {validate: isDate} + }, + + content: { + flags: {update: true, expose: true}, + }, + + // Expose only + + contentShort: { + flags: {expose: true}, + + expose: { + dependencies: ['content'], + + compute({ content }) { + return body.split('
')[0]; + } + } + }, + }; +} -- cgit 1.3.0-6-gf8a5