create-refrakt 0.9.5 → 0.9.7

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,7 +1,7 @@
1
1
  {
2
2
  "name": "create-refrakt",
3
3
  "description": "Scaffold a new refrakt.md project",
4
- "version": "0.9.5",
4
+ "version": "0.9.7",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -4,6 +4,8 @@ export default function (eleventyConfig) {
4
4
  eleventyConfig.addPlugin(refraktPlugin, {
5
5
  cssFiles: ['node_modules/@refrakt-md/lumina/index.css'],
6
6
  cssPrefix: '/css',
7
+ behaviorFile: 'node_modules/@refrakt-md/behaviors/dist/index.js',
8
+ jsPrefix: '/js',
7
9
  });
8
10
 
9
11
  eleventyConfig.addPassthroughCopy({
@@ -10,13 +10,23 @@
10
10
  </head>
11
11
  <body>
12
12
  {{ html | safe }}
13
+ <script type="application/json" id="rf-context">{{ contextJson | safe }}</script>
14
+ {% if hasInteractiveRunes %}
13
15
  <script type="module">
14
16
  import { registerElements, RfContext, initRuneBehaviors, initLayoutBehaviors } from '/js/behaviors.js';
15
17
 
16
- RfContext.currentUrl = '{{ url }}';
18
+ const contextEl = document.getElementById('rf-context');
19
+ if (contextEl) {
20
+ try {
21
+ const ctx = JSON.parse(contextEl.textContent || '{}');
22
+ RfContext.pages = ctx.pages;
23
+ RfContext.currentUrl = ctx.currentUrl;
24
+ } catch {}
25
+ }
17
26
  registerElements();
18
27
  initRuneBehaviors();
19
28
  initLayoutBehaviors();
20
29
  </script>
30
+ {% endif %}
21
31
  </body>
22
32
  </html>
@@ -6,7 +6,8 @@ import { loadRunePackage, mergePackages, runes as coreRunes } from '@refrakt-md/
6
6
  import manifest from '@refrakt-md/lumina/manifest';
7
7
  import { layouts } from '@refrakt-md/lumina/layouts';
8
8
  const theme = { manifest, layouts };
9
- import { renderPage, buildRefraktHead } from '@refrakt-md/nuxt';
9
+ import { renderPage, buildRefraktHead, hasInteractiveRunes } from '@refrakt-md/nuxt';
10
+ import { useBehaviors } from '@refrakt-md/nuxt/client';
10
11
  import type { RendererNode } from '@refrakt-md/types';
11
12
  import type { RefraktConfig } from '@refrakt-md/types';
12
13
  import type { Schema } from '@markdoc/markdoc';
@@ -90,6 +91,7 @@ const { data } = await useAsyncData('refrakt-' + route.path, async () => {
90
91
  frontmatter: currentPage.frontmatter,
91
92
  seo: currentPage.seo,
92
93
  }),
94
+ pages,
93
95
  };
94
96
  });
95
97
 
@@ -100,6 +102,11 @@ if (data.value?.seo) {
100
102
  script: data.value.seo.script,
101
103
  });
102
104
  }
105
+
106
+ // Initialize interactive rune behaviors on the client
107
+ if (data.value?.pages) {
108
+ useBehaviors({ pages: data.value.pages, currentUrl: route.path });
109
+ }
103
110
  </script>
104
111
 
105
112
  <template>