Skip to content

fix: truncate blogpost properly with truncate-html#880

Merged
endiliey merged 4 commits intofacebook:masterfrom
endiliey:truncate
Aug 2, 2018
Merged

fix: truncate blogpost properly with truncate-html#880
endiliey merged 4 commits intofacebook:masterfrom
endiliey:truncate

Conversation

@endiliey
Copy link
Contributor

@endiliey endiliey commented Aug 1, 2018

Motivation

Fix #719

Instead of naively cutting down markdown at certain length and then render it to HTML, we render markdown to HTML first and then truncate it (keeping html tag safe) using https://www.npmjs.com/package/truncate-html

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Consider this blogpost file

---
title: Docusaurus
author: Endilie
authorURL: https://github.com/endiliey
authorFBID: 100000251103620
authorTwitter: endiliey
---

Hi, this is just a test blog post. Please be a nice person. Hehehehehe

[Docusaurus](https://github.com/facebook/Docusaurus)
[Prettier](https://github.com/prettier/prettier)
[Jest](https://github.com/facebook/jest)
[ReasonML](https://github.com/reasonml)
[Reason React](https://github.com/reasonml/reason-react)

Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum 
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum 

Before
Notice how the URL got cut naively, resulting on broken link like below
[ReasonML](<a href="https://github.com/reaso">https://github.com/reaso</a>
before

After
Notice how the URL is preserved
<a href="https://github.com/reasonml">ReasonML</a> <a href="https://github.com/reasonml/reason-react">Reason React</a>

after

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Aug 1, 2018

Deploy preview for docusaurus-preview ready!

Built with commit 6bc6d95

https://deploy-preview-880--docusaurus-preview.netlify.com

@endiliey endiliey requested review from JoelMarcey and yangshun August 1, 2018 13:38
Copy link
Contributor

@JoelMarcey JoelMarcey left a comment

Choose a reason for hiding this comment

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

@JoelMarcey
Copy link
Contributor

I have a slight concern that the project hasn't been updated in 4 months, but if this works for now, then I think it can solve some headaches.

@endiliey
Copy link
Contributor Author

endiliey commented Aug 1, 2018

@JoelMarcey i'm betting on the package 6,937 downloads per week credibility 👍

Edit: Either way, i think at least it is better than previous logic (see above test plan). If it needs an update then we can consider forking it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants