Skip to content

Added custom code based slugger for making <details> blocks linkable#3352

Closed
yathomasi wants to merge 7 commits into
masterfrom
details-block-linkable-custom
Closed

Added custom code based slugger for making <details> blocks linkable#3352
yathomasi wants to merge 7 commits into
masterfrom
details-block-linkable-custom

Conversation

@yathomasi
Copy link
Copy Markdown
Contributor

@yathomasi yathomasi commented Mar 11, 2022

This is another solution for making a unique link for the <details> block. This uses custom Slugger to provide the custom code/word to make the hash link unique and eliminates the possibility of links pointing to another place if we perform some page updates.

Some considerations with this methods are:

  • the code must be provided in case of duplicates titles otherwise development will show an error and the build also fails
  • Also, there is also an optional props position for the position of the code in the hash link (which is "end" by default, also accepts "start")

For an example implementation, I have updated docs/start/data-and-model-versioning which had two <details> components with the title Expand to see what happens under the hood. so I have updated one with code and also used optional positoin to place the code at the start of the hash id.

Screen Shot 2022-03-11 at 19 52 14

The generated link will be /doc/start/data-and-model-versioning#storing-and-sharing-Expand-to-see-what-happens-under-the-hood.

Note: This preview deployment may fail since I have not updated all the docs <details> block having the same title.

Continue on PR #3329

@shcheklein shcheklein temporarily deployed to dvc-org-details-block-l-yu5rco March 11, 2022 14:11 Inactive
Copy link
Copy Markdown
Contributor

@rogermparent rogermparent left a comment

Choose a reason for hiding this comment

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

I'm not too enthusiastic about this one, if a manual id is going to be provided then I imagine it should entirely take the place of the generated slug; a completely manual id gives the same benefits as a combined slug with simpler code and the added benefit of being able to change the details block's text without breaking existing links to it.

@yathomasi
Copy link
Copy Markdown
Contributor Author

I'm not too enthusiastic about this one, if a manual id is going to be provided then I imagine it should entirely take the place of the generated slug; a completely manual id gives the same benefits as a combined slug with simpler code and the added benefit of being able to change the details block's text without breaking existing links to it.

Or I think we can do it this way:

if we add position prop then it will be added to the respective position i.e start or end otherwise code will be taken entirely for id.

@rogermparent
Copy link
Copy Markdown
Contributor

if we add position prop then it will be added to the respective position i.e start or end otherwise code will be taken entirely for id.

It would be an improvement, but I don't see any use case for a code+content-derived id that isn't already solved by a code-only id.

Base automatically changed from details-block-linkable to master March 22, 2022 05:09
@yathomasi
Copy link
Copy Markdown
Contributor Author

close in favor of #3329.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants