mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
Using metadata to store html comment
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
const TurndownService = require('turndown');
|
||||
const { merge } = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
RootMutation: {
|
||||
createComment: {
|
||||
async pre(_, { input }, _context, _info) {
|
||||
// Saving the HTML comment as Markdown
|
||||
const ts = new TurndownService();
|
||||
input.body = ts.turndown(input.body);
|
||||
input.metadata = merge(
|
||||
{},
|
||||
{
|
||||
htmlBody: input.htmlBody,
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const marked = require('marked');
|
||||
|
||||
module.exports = {
|
||||
Comment: {
|
||||
body: comment => marked(comment.body),
|
||||
htmlBody: comment => comment.metadata.htmlBody,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user