diff --git a/source/_posts/typescript.md b/source/_posts/typescript.md index d864b41..340a5e2 100644 --- a/source/_posts/typescript.md +++ b/source/_posts/typescript.md @@ -11,6 +11,7 @@ intro: | A TypeScript cheat sheet with the most important concepts, functions, methods, and more. A complete quick reference for beginners. plugins: - copyCode + - runCode --- ## Getting Started @@ -293,11 +294,7 @@ class Greeter { ```ts function enumerable(value: boolean) { - return function ( - target: any, - propertyKey: string, - descriptor: PropertyDescriptor - ) { + return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { descriptor.enumerable = value; }; } diff --git a/themes/coo/layout/_partial/scripts.ejs b/themes/coo/layout/_partial/scripts.ejs index 9fa81dc..fa560d0 100644 --- a/themes/coo/layout/_partial/scripts.ejs +++ b/themes/coo/layout/_partial/scripts.ejs @@ -81,6 +81,11 @@ const code_Blocks = document.querySelectorAll('pre > code'); const runInnerHTML = ''; code_Blocks.forEach(function (codeBlock) { + let content = codeBlock.textContent; + let language = [...codeBlock.classList].filter(c => c.startsWith("language-"))[0].replace("language-", ""); + + if (language === 'shell') return; + // Create a run button element const runButton = document.createElement('button'); runButton.className = 'bg-emerald-500 p-2 text-white fadeIn shadow-xl rounded flex items-center absolute top-12 right-2'; @@ -93,9 +98,11 @@ // Add click event listener to run button runButton.addEventListener('click', () => { - let content = codeBlock.textContent; - let language = [...codeBlock.classList].filter(c => c.startsWith("language-"))[0].replace("language-", ""); - const editorId = ['javascript', 'python'].includes(language) + if (language === 'ts') { + language = 'typescript'; + } + + const editorId = ['javascript', 'typescript', 'python'].includes(language) ? 'script' : ['scss'].includes(language) ? 'style' @@ -145,7 +152,7 @@ } } - if (language === 'scss') { + if (['scss', 'typescript'].includes(language)) { config = { ...baseConfig, tools: {