Skip to content

scaffold blogpost content page#24

Merged
rccsousa merged 11 commits intomainfrom
rs/scaffold-blogpost-page
Sep 23, 2024
Merged

scaffold blogpost content page#24
rccsousa merged 11 commits intomainfrom
rs/scaffold-blogpost-page

Conversation

@rccsousa
Copy link
Copy Markdown
Collaborator

Why:

  • blogposts/[slug] was currently just rendering JSON stringified data which was not working as intented.
    How:
  • scaffolded content page, pulling data and rendering it through several components and blocks

Before:
before
After (to be styled):
after

- replaced slate editor;
- publishing now pushes and generates changes directly to html as
  'content_html'
- updated graphQL schemas to reflect this change
- created estimateReadTime function;
- added richText renderer;
- added several components for each block;
- added DOMpurify to sanitize HTML to prevent potential XSS
  vulnerabilities
- changed to isomorphic-dompurify package, which contains wrappers to
  enable DOMPurify on server
- $slug var was missing
@rccsousa rccsousa requested a review from davelange September 20, 2024 17:05
@rccsousa rccsousa marked this pull request as ready for review September 20, 2024 17:05
// TODO: Extend to format talks-and-roundtables to Talks & Roundtables
// TODO: Extend to fromat case-studies to Case Studies

return text.charAt(0).toLowerCase() + text.slice(1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for, to turn the word into lower case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a converter to convert what ArchiveButton receives and make a compatible key of collections

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as just text.toLowerCase() though

@@ -0,0 +1,7 @@
export function estimateReadTime(text: string): string {
const WPM = 250
const wordCount = text.split(/\s+/).length
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this could be kept on the CMS, through an onUpdate hook or something. Because splitting a string might be costly when the string is an entire blogpost. But it's ok for now 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted! will make this an issue

@rccsousa rccsousa merged commit 6ce106b into main Sep 23, 2024
@rccsousa rccsousa deleted the rs/scaffold-blogpost-page branch September 23, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants