diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-02-01 16:41:45 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-02-01 16:41:45 -0400 |
commit | 0ad3d3ce23b47eeccd46d063812372de8b9b190b (patch) | |
tree | 393f7f6e5a0ebb0d8a7f1c5b78e6f6a3ae0dc5f8 /src/thing | |
parent | e17bf53b3f17d8d8aa62869d4fc97883acc5c1fa (diff) |
news entry data
Diffstat (limited to 'src/thing')
-rw-r--r-- | src/thing/news-entry.js | 49 |
1 files changed, 49 insertions, 0 deletions
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('<hr class="split">')[0]; + } + } + }, + }; +} |