Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: truncate blogpost properly with truncate-html #880

Merged
merged 4 commits into from
Aug 2, 2018

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

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.

None yet

4 participants