-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove trailing slashes from toc links (#5286)
[Asana task](https://app.asana.com/0/1200099998847559/1206920798931157/f) ## What are you changing in this pull request and why? Trailing slashes are being applied to TOC items which use the LifeCycle component. This update removes the trailing slashes from the TOC links to correctly match the ID of the headers on the page. ## Preview - Verify the `Trigger on job completion` TOC link does not have trailing slashes when clicked, and brings the user to the correct spot on the page: https://docs-getdbt-com-git-fix-click-to-copy-dbt-labs.vercel.app/docs/deploy/deploy-jobs
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Util function to remove trailing dashes from ID attribute on headers | ||
export default function removeTrailingDashes(header) { | ||
// Create copy of header element | ||
const updatedHeader = header; | ||
|
||
// Get id attribute | ||
const thisId = updatedHeader?.getAttribute("id"); | ||
|
||
// If header's id ends with trailing dash, remove dash | ||
if (thisId?.endsWith("-")) { | ||
// Remove `-` from end of ID string | ||
updatedHeader.id = thisId?.substring(0, thisId?.length - 1); | ||
|
||
// Recursively run function to check for another trailing slash | ||
removeTrailingDashes(updatedHeader); | ||
} | ||
|
||
return updatedHeader; | ||
} |