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: remark excerpt add halfChop option #6992

Merged

Conversation

youngboy
Copy link
Contributor

@youngboy youngboy commented Aug 3, 2018

Default prune won't work for non-english text. Add halfChop (default to true) option, set it to false so that non-english blogs will make it fallback to lodash truncate.

I think this resolve #6916

default prune won't work for non english text
@KyleAMathews
Copy link
Contributor

KyleAMathews commented Aug 3, 2018

Deploy preview for using-postcss-sass failed.

Built with commit c029622

https://app.netlify.com/sites/using-postcss-sass/deploys/5b687303e39e7c5e43b60c8a

@gatsbybot
Copy link
Collaborator

gatsbybot commented Aug 3, 2018

Deploy preview for using-drupal ready!

Built with commit c029622

https://deploy-preview-6992--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Aug 3, 2018

Deploy preview for gatsbygram failed.

Built with commit c029622

https://app.netlify.com/sites/gatsbygram/deploys/5b687302e39e7c5e43b60c81

@pieh
Copy link
Contributor

pieh commented Aug 6, 2018

Could we detect this automatically? that prune is failing and automatically switch to truncate?

If not then this looks good, not sure about halfChop name - is this reference to something that I don't understand? :) Please document this option in readme, and possibly add to troubleshooting section for "excerpts for non-latin languages" or something like that?

@youngboy
Copy link
Contributor Author

youngboy commented Aug 6, 2018

@pieh So sorry about confusing name halfChop, I 'borrow' this from underscore.string's readme

prune(string, length, pruneString) => string

Elegant version of truncate. Makes sure the pruned string does not exceed the original length. Avoid half-chopped words when truncating.

How about just rename it to truncate ?

For detect failing case automatically, I think there is no straightforward way.

@pieh
Copy link
Contributor

pieh commented Aug 6, 2018

How about just rename it to truncate ?
Let's go with that. Most important parts is to add docs for this

@KyleAMathews
Copy link
Contributor

Deploy preview for gatsbyjs failed.

Built with commit c029622

https://app.netlify.com/sites/gatsbyjs/deploys/5b687301e39e7c5e43b60c7e

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Just some wording nitpicking


### Excerpts for non-latin languages

By default, excerpts is avoid half-chopped words when truncating content.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like this:

By default, excerpt uses underscore.string/prune which doesn't handle non-latin characters (esamattis/underscore.string#418).

If that is the case, you can set truncate option on excerpt field, like:

and your query after that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 👍, updated.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Aug 17, 2018

Deploy preview for using-contentful failed.

Built with commit 48427c2

https://app.netlify.com/sites/using-contentful/deploys/5b769c00c6aed639492db91c

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Thanks

@pieh pieh merged commit 4386750 into gatsbyjs:master Aug 17, 2018
@gatsbot
Copy link

gatsbot bot commented Aug 17, 2018

Fails
🚫

Danger failed to run /app/danger-0.8y4mpmx3t26.ts.

Error VMError

Cannot find module '../utils/testable-schedule'
VMError: Cannot find module '../utils/testable-schedule'
    at _require (/app/node_modules/vm2/lib/sandbox.js:246:25)
    at Object.<anonymous> (/app/danger-0.8y4mpmx3t26.ts:4:29)
    at NodeVM.run (/app/node_modules/vm2/lib/main.js:427:27)
    at Object.<anonymous> (/app/node_modules/danger/distribution/runner/runners/vm2.js:100:37)
    at step (/app/node_modules/danger/distribution/runner/runners/vm2.js:43:23)
    at Object.next (/app/node_modules/danger/distribution/runner/runners/vm2.js:24:53)
    at /app/node_modules/danger/distribution/runner/runners/vm2.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/danger/distribution/runner/runners/vm2.js:14:12)
    at Object.exports.runDangerfileEnvironment (/app/node_modules/danger/distribution/runner/runners/vm2.js:83:121)

Dangerfile

----------------------------^

Generated by 🚫 dangerJS

porfirioribeiro pushed a commit to porfirioribeiro/gatsby that referenced this pull request Aug 22, 2018
* fix: remark excerpt add halfChop option

default prune won't work for non english text

* remark: renamed prune option, added docs

* transformer-remark readme wording changes

* Update README.md
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.

[gatsby-transformer-remark] excerpt not working for non-English content
4 participants