MCPcopy Create free account
hub / github.com/decaporg/decap-cms / commentToNote

Function commentToNote

packages/decap-cms-lib-util/src/notesFormat.ts:102–128  ·  view source on GitHub ↗
(comment: CommentData)

Source from the content-addressed store, hash-verified

100}
101
102export function commentToNote(comment: CommentData): Note {
103 if (!comment || !comment.body) {
104 throw new Error('Invalid comment structure');
105 }
106
107 const { content, resolved, author, authorId } = parseNoteBody(comment.body);
108
109 if (!content) {
110 throw new Error('Empty note content');
111 }
112
113 return {
114 id: comment.id.toString(),
115 // Falls back to the account that posted, for a comment typed on the host
116 // and for any note with no recorded author.
117 author: author || comment.user?.login || 'Unknown',
118 authorId,
119 // Only when the posting account IS the note's author — a recorded author
120 // means someone posted on their behalf, and its avatar would mislabel the
121 // note. The pane shows initials instead.
122 avatarUrl: authorId ? undefined : comment.user?.avatar_url || undefined,
123 timestamp: comment.created_at,
124 content,
125 resolved,
126 entrySlug: '',
127 };
128}
129
130export function commentsToNotes(
131 comments: CommentData[],

Callers 2

parseCommentToNoteMethod · 0.90

Calls 2

parseNoteBodyFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected