-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
{{content words}} error with CTA #22095
Comments
Hmm, this is an interesting one. I think it's certainly unexpected that content expands past the However, regarding the CTA, what's the use-case for |
Bulletin /could/ use it to good effect to load a couple paragraphs of content. But it looks like it loads and hides it the full body of the post. But I would see {{content words="x"}} being useful in cases like that - where you want multiple lines of formatted text in a preview, before a 'read more'. The {{excerpt}} is OK for cases like Ruby where just a few un-formatted words are wanted, but it doesn't work in a theme where longer formatted text is wanted. |
I think this may have been done intentionally, with the added intention of deprecating words="" - but I'll need to go and check that In general, the tools for making excerpts are a bit wonky so it might be better to ask the question of what a better tool would look like all-round? |
Issue Summary
Using {{content words="10"}} should probably return 10 words whenever possible. Things get messy if there's no access to the post. [Aside: it's also possible to pass 'characters' and that has exactly the same problems.]
Background: Some themes use the {{content}} helper with words to generate a short preview, for example for an index page.
Steps to Reproduce
Here's the behavior that can occur when the helper is used with words=10 . In my post.hbs, I've added
{{content words="10"}}
Create a post in the editor. Make it 20 words. long.
Expected: See the first 10 words. Actual: First 10 words.
Set post access to members only (don't be a member).
Expected: ? Not sure, honestly? Actual: Entire CTA. This generally breaks the layout, although the theme can avoid it by checking for access before using {{content}}.
Add a public preview line after 20 words. Add some more words after it.
Expected: 10 words. Actual: All 20 words, PLUS the CTA. I can use {{{html}} instead, but it doesn't take a words argument.
Proposal & ideas
If the public preview is longer than the words value, return only the words, no CTA. [We certainly shouldn't return more words than requested.]
If the public preview is longer than the words, truncate it at the listed words, followed by the CTA.
If there is no public preview, then... ?
Would it make sense to add a "noCTA" option that causes {{content}} to write out the smaller of "words" or the public preview if words is set, or the public preview (minus CTA) if words is set, or nothing if there's no preview?
Ghost Version
5.109
Node.js Version
pro, or 20.
How did you install Ghost?
pro, or source code build, or ghost-cli.
Database type
MySQL 8 or SqLite.
Browser & OS version
doesn't matter.
Relevant log / error output
Code of Conduct
The text was updated successfully, but these errors were encountered: