feat: add support for running sass

This commit is contained in:
Hatem Hosny committed 2025-01-05 02:03:11 +02:00
1 parent d235f88e86
commit e4c785d8dd
2 files changed
+19 -3

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ intro: |
This is a quick reference cheat sheet that lists the most useful features of [SASS](https://sass-lang.com).
plugins:
- copyCode
- runCode
---
## Sass Basics
+18 -3
View File
@@ -95,7 +95,11 @@
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) ? 'script' : 'markup';
const editorId = ['javascript', 'python'].includes(language)
? 'script'
: ['scss'].includes(language)
? 'style'
: 'markup';
const title = codeBlock.closest('.h3-wrap')?.querySelector('h3')?.textContent.replace('#', '') || '';
if (language === 'python') {
@@ -111,7 +115,7 @@
}
}
let config = {
const baseConfig = {
title,
activeEditor: editorId,
[editorId]: {
@@ -122,10 +126,11 @@
status: 'open',
}
}
let config = baseConfig;
if (language === 'markdown') {
config = {
...config,
...baseConfig,
style: {
language: 'css',
content: '@import "github-markdown-css";\n\nbody {\n border: 1px solid #e1e4e8;\n border-radius: 4px;\n padding: 20px;\n margin: 20px !important;\n}\n',
@@ -140,6 +145,16 @@
}
}
if (language === 'scss') {
config = {
...baseConfig,
tools: {
status: 'open',
active: 'compiled',
}
}
}
const plaugroundUrl = livecodes.getPlaygroundUrl({config});
window.open(plaugroundUrl, '_blank');
});