Skip to content

Commit

Permalink
✨ Feat: add data-open attribute for code block
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Jul 16, 2024
1 parent 632243e commit 419ade9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ class FixIt {
$copy.classList.add('copy');
// remove the leading and trailing whitespace of the code string
const code = $code.innerText.trim();
if (this.config.code.maxShownLines < 0 || code.split('\n').length < this.config.code.maxShownLines + 2) {
const forceOpen = $chroma.parentElement.dataset.open ? JSON.parse($chroma.parentElement.dataset.open) : void 0;
if (forceOpen ?? (this.config.code.maxShownLines < 0 || code.split('\n').length < this.config.code.maxShownLines + 2)) {
$chroma.classList.add('open');
}
$copy.title = this.config.code.copyTitle;
Expand Down

0 comments on commit 419ade9

Please sign in to comment.