@zikojs/astro-notebook 0.1.0 → 0.3.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/Notebook.astro +22 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zikojs/astro-notebook",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "publishConfig": {
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@zikojs/notebook": "0.12.0",
24
+ "@zikojs/notebook": "0.13.0",
25
25
  "ziko": "2.0.0-beta.17.1"
26
26
  },
27
27
  "scripts": {
@@ -1,35 +1,31 @@
1
1
  ---
2
- import type { NotebookCell } from "@zikojs/notebook";
3
- interface Props {
4
- cells : NotebookCell[]
5
- };
6
- const {
7
- cells
8
- } = Astro.props;
9
- const serializedCells = JSON.stringify(cells);
2
+ import type { NotebookOptions } from "@zikojs/notebook";
3
+
4
+ type Props = NotebookOptions;
5
+
6
+ const props: Props = Astro.props;
7
+
8
+ const serializedConfig = JSON.stringify(props)
10
9
  ---
11
10
 
12
11
  <div
13
- data-notebook-wrapper
14
- data-notebook-cells = {serializedCells}
15
- >
16
- </div>
12
+ data-engine = 'zikojs'
13
+ data-notebook-wrapper
14
+ data-notebook-config={serializedConfig}
15
+ ></div>
17
16
 
18
17
  <script>
19
- import { Notebook } from '@zikojs/notebook/no-css';
20
- const notebook_wrapper = document.querySelectorAll('[data-notebook-wrapper]');
21
- notebook_wrapper.forEach(element => {
22
- const target = element as HTMLElement;
23
- const {
24
- notebookCells
25
- } = target.dataset
26
- const cells = notebookCells ? JSON.parse(notebookCells) : []
27
- Notebook({
28
- cells
29
- }).mount(target)
30
- })
18
+ import { Notebook } from "@zikojs/notebook/no-css";
19
+
20
+ document.querySelectorAll<HTMLElement>("[data-notebook-wrapper]").forEach((element) => {
21
+ const config = element.dataset.notebookConfig
22
+ ? JSON.parse(element.dataset.notebookConfig)
23
+ : {};
24
+
25
+ Notebook(config).mount(element);
26
+ });
31
27
  </script>
32
28
 
33
29
  <style is:global>
34
- @import '@zikojs/notebook/style'
35
- </style>
30
+ @import "@zikojs/notebook/style";
31
+ </style>