@3sln/deck 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3sln/deck",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A Vite plugin for building scalable, zero-config, Markdown-based component playgrounds and documentation sites.",
5
5
  "type": "module",
6
6
  "author": "Ray Stubbs",
package/src/deck-demo.js CHANGED
@@ -8,6 +8,33 @@ import {stylesheet as highlightStylesheet, highlight} from './highlight.js';
8
8
 
9
9
  const {reconcile, h, div, button, pre, code, span, label, input, p} = dodo;
10
10
 
11
+ function getLanguageFromPath(path) {
12
+ if (!path) return 'plaintext';
13
+ const extension = path.split('.').pop().toLowerCase();
14
+ switch (extension) {
15
+ case 'js':
16
+ case 'mjs':
17
+ return 'javascript';
18
+ case 'cljs':
19
+ case 'clj':
20
+ case 'cljd':
21
+ return 'clojure';
22
+ case 'css':
23
+ return 'css';
24
+ case 'html':
25
+ case 'xml':
26
+ return 'xml';
27
+ case 'md':
28
+ return 'markdown';
29
+ case 'json':
30
+ return 'json';
31
+ case 'sh':
32
+ return 'bash';
33
+ default:
34
+ return 'plaintext';
35
+ }
36
+ }
37
+
11
38
  const {ObservableSubject, watch, zip, map, dedup} = reactiveFactory({dodo});
12
39
  const {withContainerSize} = resizeFactory({dodo});
13
40
 
@@ -132,6 +159,8 @@ function propertyControl(engine, name) {
132
159
  function createEngine(src, canonicalSrc) {
133
160
  const abortController = new AbortController();
134
161
  const sourceCode$ = new ObservableSubject('Loading...');
162
+ const textSrc = canonicalSrc || src;
163
+ const lang = getLanguageFromPath(textSrc);
135
164
 
136
165
  const demoState = new DemoState({
137
166
  activePanelIds: {},
@@ -160,7 +189,7 @@ function createEngine(src, canonicalSrc) {
160
189
  reconcile(container, [
161
190
  watch(sourceCode$, text =>
162
191
  pre(
163
- code({className: 'language-javascript'}, text).on({
192
+ code({className: `language-${lang}`}, text).on({
164
193
  $update: el => {
165
194
  delete el.dataset.highlighted;
166
195
  highlight(el);
package/src/highlight.js CHANGED
@@ -3,6 +3,7 @@ import javascript from 'highlight.js/lib/languages/javascript';
3
3
  import xml from 'highlight.js/lib/languages/xml';
4
4
  import clojure from 'highlight.js/lib/languages/clojure';
5
5
  import css from 'highlight.js/lib/languages/css';
6
+ import json from 'highlight.js/lib/languages/json';
6
7
  import githubStyle from 'highlight.js/styles/github.css?inline';
7
8
  import githubDarkStyle from 'highlight.js/styles/github-dark.css?inline';
8
9
  import {css as createSheet} from '@3sln/bones/style';
@@ -11,6 +12,7 @@ hljs.registerLanguage('javascript', javascript);
11
12
  hljs.registerLanguage('xml', xml); // For HTML
12
13
  hljs.registerLanguage('css', css);
13
14
  hljs.registerLanguage('clojure', clojure);
15
+ hljs.registerLanguage('json', json);
14
16
 
15
17
  export const stylesheet = createSheet`
16
18
  /* Light Theme */
package/src/main.js CHANGED
@@ -321,7 +321,6 @@ export async function renderDeck({target, initialCardsData, pinnedCardPaths}) {
321
321
 
322
322
  const syncNav = () => {
323
323
  const {q, c} = history.getQueryParams();
324
- console.log('q', q);
325
324
  engine.dispatch(new SelectCard(c));
326
325
  engine.dispatch(new SetSearchQuery(q));
327
326
  };