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

feat: use doc's title or id as default when link name is not provided #1117

Closed
wants to merge 3 commits into from
Closed

feat: use doc's title or id as default when link name is not provided #1117

wants to merge 3 commits into from

Conversation

gianlucadonato
Copy link
Contributor

🚀 Feature

Use the doc's title or id as default when a link name in the markdown is not provided.

For example, when we have a link like [](foo.md) it would be nice if Docusaurus could read the title of the document 'foo.md' and generate automatically a link to [Foo Title](foo.md).

How it currently works

Example:

docs/doc1.md:

---
id: doc1
title: Document 1
---

docs/doc2.md:

---
id: doc2
title: Document 2
---
- [Custom Link Name](doc1.md)
- [](doc1.md)

At the moment, in docs/doc2.md the link with empty name is omitted:

Output:

How it would work

In docs/doc2.md the link with empty name is replaced with the doc1's title (if exists) or it's id:

Output:

Have you read the Contributing Guidelines on issues?

Yes.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 16, 2018
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 5e9ddf4

https://deploy-preview-1117--docusaurus-preview.netlify.com

@JoelMarcey
Copy link
Contributor

@gianlucadonato Hi! Thank you very much for the PR. However, doesn't this go against general markdown behavior. e.g., normally would create a hidden link. That may be what someone wants. That said, an argument could be made for what you want to do here for being able to update titles more easily.

Anyway, I am happy to hear arguments for this the way you do it. Or maybe we can come up with a special syntax for what you want to do.

I am going to close this, but please reopen to discuss more if you would like and we can consider the options to get this merged.

Thanks!

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.

4 participants