diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2020-01-28 12:18:47 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2020-01-28 12:18:47 +0100 |
commit | 74ee8edb555ef128112378f828c636bc04533b31 (patch) | |
tree | fe4a09d720f9437bc0dc418180c9cf11f4d0a14b /lib/Post.ts | |
parent | 9f75ff1d2d5ebf34c040474e836e125f80253365 (diff) | |
download | kronikarz-74ee8edb555ef128112378f828c636bc04533b31.tar.gz kronikarz-74ee8edb555ef128112378f828c636bc04533b31.zip |
Fix remove attributes
Diffstat (limited to 'lib/Post.ts')
-rw-r--r-- | lib/Post.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Post.ts b/lib/Post.ts index 27a6cb9..f99ef83 100644 --- a/lib/Post.ts +++ b/lib/Post.ts @@ -38,13 +38,16 @@ export default class Post { getMeta(): Meta { const { attributes } = this.post; const author: string = attributes.author; - delete attributes.author; + if (!author) throw 'Error while parsing the author'; const title: string = attributes.title; - delete attributes.title; + if (!title) throw 'Error while parsing the title'; + const additionalMeta = Object.keys(attributes) + .filter((key) => key != 'title' && key != 'author') + .reduce((acc, key) => ({ ...acc, [key]: attributes[key] }), {}); return { author, title, - additionalMeta: attributes, + additionalMeta, }; } |