Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

render markdown, strip html tags in indexing #1148

Merged
merged 5 commits into from
Aug 18, 2021
Merged

render markdown, strip html tags in indexing #1148

merged 5 commits into from
Aug 18, 2021

Conversation

samthor
Copy link
Contributor

@samthor samthor commented Aug 12, 2021

Fixes #917
Fixes #924

I know @devnook tried to solve this in #923. I disagree with @robdodson 's comment, I think we should break-word just in case.

Fixes a minor display issue too; if we don't have content on page (which happens for some of the structural pages), fall back to the meta description.

@netlify
Copy link

netlify bot commented Aug 12, 2021

✔️ Deploy Preview for developer-chrome-com ready!

🔨 Explore the source changes: b7961c1

🔍 Inspect the deploy log: https://app.netlify.com/sites/developer-chrome-com/deploys/611c8faee0716900088c3411

😎 Browse the preview: https://deploy-preview-1148--developer-chrome-com.netlify.app

@samthor samthor requested review from devnook and removed request for robdodson and MichaelSolati August 12, 2021 05:33
@google-cla google-cla bot added the cla: yes label Aug 12, 2021
@pullapprove pullapprove bot requested a review from MichaelSolati August 12, 2021 05:33
@samthor samthor changed the title Strip indexing render markdown, strip html tags in indexing Aug 12, 2021
@robdodson
Copy link
Contributor

I know @devnook tried to solve this in #923. I disagree with @robdodson 's comment, I think we should break-word just in case.

What case are you worried about? One that I could think of is if someone tries to have a reallyLongMethodName but I think our site's code style may already cause that to break (I think ... would be good to test).

@robdodson
Copy link
Contributor

robdodson commented Aug 12, 2021

Visual comparison with and without break-all.

With break-all every word near the right-hand edge will get broken in a weird way.

Screen Shot 2021-08-12 at 4 11 29 PM

If you remove the style then the words wrap naturally

Screen Shot 2021-08-12 at 4 12 55 PM

@samthor
Copy link
Contributor Author

samthor commented Aug 12, 2021

You're demoing break-all? The break-word option, despite its confusing name, avoids breaking words where possible. It only breaks words too long to render at once. The example on MDN is good for this: with break-word, the first two words remain on their own lines, it's only the third really huge word that's split up.

@robdodson
Copy link
Contributor

ah sorry, I didn't notice that you said break-word. I thought you were saying you disagreed with my comment not to use break-all in Ewa's PR. Yeah, break-word is fine.

Object.defineProperty(algoliaCollectionItem, 'content', {
get() {
// Strip HTML tags and limit to a sensible size for indexing.
const text = striptags(item.templateContent ?? '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this already rendered content, e.g. with shortcodes rendered in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes - templateContent is itself a getter which renders the final page content but only when 11ty is rendering pages. If we get it here, we crash.

@robdodson
Copy link
Contributor

@samthor any idea why the linter is failing? it seems to be missing a module

@samthor
Copy link
Contributor Author

samthor commented Aug 18, 2021

I expanded the typechecking a tiny bit. I've fixed the other types issues in an extra commit here.

@samthor samthor merged commit b2a1d5a into main Aug 18, 2021
@samthor samthor deleted the strip-indexing branch August 18, 2021 07:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search results show raw content of {% Img %} shortcode Search results are overflowing.
3 participants