Skip to content

Commit

Permalink
Preserve paragraphs in comments (#129)
Browse files Browse the repository at this point in the history
* Preserve paragraphs in comments

* Ignore eslint

* Use pre-wrap

* Sanitize new comments
  • Loading branch information
tom-sherman authored Sep 25, 2024
1 parent 14f208f commit 743bcac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async function LiveComment({
<TimeAgo createdAt={comment.createdAt} side="bottom" />
</Link>
</div>
<p>{comment.body}</p>
<p className="whitespace-pre-wrap">{comment.body}</p>
</CommentClientWrapperWithToolbar>

{comment.children?.map((comment) => (
Expand Down
4 changes: 3 additions & 1 deletion packages/frontpage/lib/data/atproto/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ type CommentInput = {

export async function createComment({ parent, post, content }: CommentInput) {
await ensureIsInBeta();
// Collapse newlines into a single \n\n and trim whitespace
const sanitizedContent = content.replace(/\n\n+/g, "\n\n").trim();
const record = {
content,
content: sanitizedContent,
parent: parent
? {
cid: parent.cid,
Expand Down

0 comments on commit 743bcac

Please sign in to comment.