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

Markdown is retained in page descriptions #1739

Closed
duckdotapk opened this issue Aug 3, 2019 · 4 comments
Closed

Markdown is retained in page descriptions #1739

duckdotapk opened this issue Aug 3, 2019 · 4 comments
Labels
status: needs more information There is not enough information to take action on the issue.

Comments

@duckdotapk
Copy link

duckdotapk commented Aug 3, 2019

🐛 Bug Report

The og:description meta tag will contain raw markdown if the sentence it's derived from contains any.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

Create a page wherein the first sentence contains markdown. Here's an example from my site:

---
id: hack-support
title: Hack Support
---

**This hack is [always enabled](all-hacks.md#always-enabled-hacks) when using the Mod Launcher.**

Expected behavior

I believe that Docusaurus should strip markdown out of page descriptions when generating them.

Actual Behavior

When this page is generated (via yarn start or yarn build), the og:description field will contain similar markdown to the original file (with links resolved) as showcased below:

<meta property="og:description" content="**This hack is [always enabled](/docs/lucasmodlauncher/hacks/all-hacks#always-enabled-hacks) when using the Mod Launcher.**"/>

I initially noticed this when I shared one of the pages with this issue via Discord and the embed contained markdown:

actual behaviour showcase

Reproducible Demo

I initialised a brand new site with npx docusaurus-init and uploaded it here to demonstrate this issue.

I decided to use a new site for this as the example documents doc1.md and doc2.md both contain markdown within their first sentence which is sufficent for demonstrating it.

To replicate it yourself, simply run yarn start to start the site or yarn build to build the site and inspect the page's HTML (example from doc1):

<meta property="og:description" content="Check the [documentation](https://docusaurus.io) for how to use Docusaurus."/>
@endiliey
Copy link
Contributor

endiliey commented Aug 4, 2019

Its intended since 1.x. We dont render the html part because #1066

If we strip it out, its hard to tell which to remove

**This hack is [always enabled](/docs/lucasmodlauncher/hacks/all-hacks#always-enabled-hacks) when using the Mod Launcher.**"

or

This hack is always enabled when using the Mod Launcher

or

This hack is [always enabled](/docs/lucasmodlauncher/hacks/all-hacks#always-enabled-hacks) when using the Mod Launcher

There are many edge cases that can even cause more headache

@endiliey endiliey added the status: needs more information There is not enough information to take action on the issue. label Aug 4, 2019
@duckdotapk
Copy link
Author

duckdotapk commented Aug 4, 2019

My proposal is basically to render the description separately from the rest of the page and in that process remove any markdown that isn't actually text displayed to the end user such as the brackets and URL for the link markdown.

Basically like how it would ultimately be displayed on the page minus any hyperlinks or formatting.

Edit: While there probably is some edge cases with this, I think if possible it would probably be a better way to handle it in most situations.

Though the proposal that other fella made on having a description field next to the pages URL and title would also probably be a sufficent and arguably better solution (since you could customise it to not be exactly the same as the first sentence).

@duckdotapk
Copy link
Author

My last response was written on a phone so I wasn't able to be as detailed but to be clear I mean like the first example you gave, so this:

**This hack is [always enabled](all-hacks.md#always-enabled-hacks) when using the Mod Launcher.**

Would resolve as this:

This hack is always enabled when using the Mod Launcher.

@endiliey
Copy link
Contributor

endiliey commented Aug 5, 2019

A better solution is to allow description frontmatter like in v2. If not defined, we still go with current behavior

To be honest as a user i’d prefer rendering the markdown as the meta description. I might be wrong but this meta description has been like this since a year ago.

I will close this issue as wontfix. We will accept PR on the description as frontmatter though

@endiliey endiliey closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more information There is not enough information to take action on the issue.
Projects
None yet
Development

No branches or pull requests

2 participants