Created
May 26, 2021 07:27
-
-
Save leaanthony/35b72537a39b53c6e8c85c0a4615688e to your computer and use it in GitHub Desktop.
Line numbers for Docusaurus 2
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
// Based on https://gist.github.com/uditalias/3969a20ef759bf3a8757499429b30063 | |
// Reduces number gutter and adds border | |
/* Edit the `src/css/custom.css` file and add the following styles */ | |
/* | |
* Reset the line-number counter for each .prism-code scope | |
*/ | |
.prism-code { | |
counter-reset: line-number; | |
} | |
/* | |
* Notice the chained .language-ts class name to .prism-code | |
* You can chain more languages in order to add line numbers | |
*/ | |
.prism-code.language-js .token-line::before, | |
.prism-code.language-ts .token-line::before, | |
.prism-code.language-go .token-line::before { | |
counter-increment: line-number; | |
content: counter(line-number); | |
margin-right: calc(var(--ifm-pre-padding) * 1.5); | |
text-align: right; | |
min-width: 1.5rem; | |
display: inline-block; | |
opacity: .3; | |
position: sticky; | |
left: var(--ifm-pre-padding); | |
border-right: 1px solid; | |
padding-right: 0.5rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment