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

Use standard markdown syntax for doccards #215

Open
matevz opened this issue Sep 1, 2022 · 1 comment
Open

Use standard markdown syntax for doccards #215

matevz opened this issue Sep 1, 2022 · 1 comment
Labels
p:2 Low priority

Comments

@matevz
Copy link
Member

matevz commented Sep 1, 2022

Currently, in order to use doccards you need to write a .mdx file, import and use DocCard or DocCardList react components along with our findSidebarItem in docUtils.js. This is quite some boilerplate code for oasis-core, oasis-sdk and other repositories which in general only include plain markdown files. Since there is no standard markdown syntax for doccards, we should still strive to use standard markdown so it is valid outside of docusaurus.

I suggest we use standard markdown syntax for doccards and then wrap it with actual components using remark as follows.

Single-line doccard:

@[doccard](../../some/file.md)

would be transformed into

<DocCard item={findSidebarItem("/general/some/file")} />

And for doccard list:

@doccardlist:

- ../../some/file1.md
- ../some/file2.md
- some/file3.md

would be transformed into:

<DocCardList items=[{
  findSidebarItem('/general/some/file1'),
  findSidebarItem('/general/network/some/file2'),
  findSidebarItem('/general/network/settings/some/file3'),
]} />

Potential issues:

  • if the doccard syntax above appears inside .md file (and not .mdx), will docusaurus want to compile <DocCardList> syntax inside "plain" .md file?
  • the @[doccard](some/link) will show doccard as text on the link. If there are multiple doccards one after another, that will be pretty nondescriptive

Alternatives:

  • Instead of using doccard literal, perhaps just placing @ in front of the link is sufficient? Or some other magic symbol, like ! or =? e.g. =[../../some/file.md]=
  • Maybe we could unify doccard and doccard list, so that if there is a single item, use doccard and for more items, doccardlist? Is there a way to set the number of doccards per row?
  • Check vuepress1&2, if they provide any better markdown syntax for doccards.
@matevz matevz added the p:2 Low priority label Sep 1, 2022
@matevz
Copy link
Member Author

matevz commented Oct 3, 2022

Perhaps we could simply do the following:

  • if only a link exists in the whole paragraph without a full stop, for example
[Run validator node](../node/run-your-node/validator-node.md)

[Consensus layer](https://github.com/oasisprotocol/oasis-core/main/blob/docs/consensus/README.md)

[Oasis Team](https://oasisprotocol.org/about-us)

A doc card is created for each paragraph. In the example above, two doc IDs and one external link (with "Oasis Team" doc card label taken from the link).

  • if a bullet list exists where each entry is a simple link without children (to avoid transforming TOCs to doccards), for example:
# See Also

- [Run validator node](../node/run-your-node/validator-node.md)
- [Consensus layer](https://github.com/oasisprotocol/oasis-core/main/blob/docs/consensus/README.md)
- [Oasis Team](https://oasisprotocol.org/about-us)

A doc card list is generated.

Pros:

  • visible on github and other editors as normal links

Cons:

  • no obvious way of saying not to render links as doc cards. Does this pose an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p:2 Low priority
Projects
None yet
Development

No branches or pull requests

1 participant