mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
♻️ Refactor: refactor code block rendering
This commit is contained in:
+7
-2
@@ -386,8 +386,13 @@ class FixIt {
|
||||
// code title
|
||||
const $title = document.createElement('span');
|
||||
$title.classList.add('code-title');
|
||||
const hlAttrs = this.data[$chroma.parentNode.id];
|
||||
$title.insertAdjacentHTML('afterbegin', `<i class="arrow fa-solid fa-chevron-right fa-fw" aria-hidden="true"></i><span class="title-inner">${hlAttrs?.title ?? ''}</span>`);
|
||||
// insert code title inner
|
||||
$title.insertAdjacentHTML(
|
||||
'afterbegin',
|
||||
$chroma.parentNode.title
|
||||
? `<i class="arrow fa-solid fa-chevron-right fa-fw" aria-hidden="true"></i><span class="title-inner">${$chroma.parentNode.title}</span>`
|
||||
: '<i class="arrow fa-solid fa-chevron-right fa-fw" aria-hidden="true"></i>'
|
||||
);
|
||||
$title.addEventListener('click', () => {
|
||||
$chroma.classList.toggle('open');
|
||||
}, false);
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
{{- $id := dict "Content" .Attributes "Scratch" .Page.Scratch | partial "function/id.html" -}}
|
||||
{{- $codeBlock := transform.Highlight .Inner .Type .Options -}}
|
||||
{{- replace $codeBlock "<div class=\"highlight\">" (printf "<div class=\"highlight\" id=\"%v\">" $id) 1 | safeHTML -}}
|
||||
{{- $result := transform.HighlightCodeBlock . -}}
|
||||
{{- $result.Wrapped -}}
|
||||
|
||||
Reference in New Issue
Block a user