Skip to content

Commit

Permalink
🐛 Fix: fix typeit shotrcode miss space when build with --minify param
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Apr 20, 2024
1 parent 72bd72f commit bae1678
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,17 +682,18 @@ class FixIt {
const singleLoop = typeitElement.dataset.loop;
// get the content of the typed element
stagingElement.innerHTML = '';
stagingElement.appendChild(typeitElement.querySelector('template').content);
stagingElement.appendChild(typeitElement.querySelector('template').content.cloneNode(true));
// for shortcodes usage
let targetEle = typeitElement.firstElementChild
// for system elements usage
if (typeitElement.firstElementChild.tagName === 'TEMPLATE') {
typeitElement.innerHTML = '';
targetEle = typeitElement
}
const typedContents = stagingElement.querySelector('pre')?.innerHTML || stagingElement.innerHTML
// create a new instance of TypeIt for each element
const instance = new TypeIt(targetEle, {
strings: stagingElement.innerHTML,
strings: typedContents,
speed: speed,
lifeLike: true,
cursorSpeed: cursorSpeed,
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/typeit.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

<div {{ $wrapperAttrs | safeHTMLAttr }}>
{{- printf `<%v %v></%v>` $tag $innerAttrs $tag | safeHTML -}}
<template>{{ printf "%v" $content | safeHTML }}</template>
<template><pre>{{ printf "%v" $content | safeHTML }}</pre></template>
</div>
{{- .Page.Store.Set "hasTyped" true -}}

0 comments on commit bae1678

Please sign in to comment.