@easy-cms/nuxt 0.2.0 → 0.4.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.
package/dist/module.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  importConfig
11
11
  } from "@easy-cms/core";
12
12
  import {
13
+ addImports,
13
14
  addServerHandler,
14
15
  addServerImports,
15
16
  addServerPlugin,
@@ -90,6 +91,7 @@ declare module '${SERVER}' {
90
91
  { name: "useEasyCMS", from: SERVER },
91
92
  { name: "useEasyCMSUser", from: SERVER }
92
93
  ]);
94
+ addImports({ name: "useLivePreview", from: resolveRuntime("./runtime/live-preview.js") });
93
95
  addServerHandler({ route: apiPath, handler: HANDLER });
94
96
  addServerHandler({ route: `${apiPath}/**`, handler: HANDLER });
95
97
  addServerPlugin(resolveRuntime("./runtime/plugin.js"));
@@ -0,0 +1,15 @@
1
+ import { LivePreviewOptions } from '@easy-cms/core/live-preview';
2
+ import { Ref } from 'vue';
3
+
4
+ /**
5
+ * Live preview for a page: while the page is shown in the admin's preview, `data` is replaced
6
+ * with the document being edited on every change, unsaved. Elsewhere it does nothing.
7
+ *
8
+ * ```ts
9
+ * const { data: post } = await useFetch(`/api/posts/${slug}`)
10
+ * useLivePreview(post)
11
+ * ```
12
+ */
13
+ declare function useLivePreview<T>(data: Ref<T>, options?: LivePreviewOptions): void;
14
+
15
+ export { useLivePreview };
@@ -0,0 +1,14 @@
1
+ import { subscribeLivePreview } from "@easy-cms/core/live-preview";
2
+ import { onBeforeUnmount, onMounted } from "vue";
3
+ function useLivePreview(data, options = {}) {
4
+ let stop;
5
+ onMounted(() => {
6
+ stop = subscribeLivePreview((doc) => {
7
+ data.value = doc;
8
+ }, options);
9
+ });
10
+ onBeforeUnmount(() => stop?.());
11
+ }
12
+ export {
13
+ useLivePreview
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/nuxt",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Nuxt module for Easy CMS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,18 +20,19 @@
20
20
  "dependencies": {
21
21
  "@nuxt/kit": "^4.5.2",
22
22
  "h3": "^1.15.11",
23
- "@easy-cms/admin": "^0.2.0"
23
+ "@easy-cms/admin": "^0.4.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "nuxt": "^4.0.0",
27
- "@easy-cms/core": "^0.2.0"
27
+ "@easy-cms/core": "^0.4.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@nuxt/schema": "^4.5.2",
31
31
  "@nuxt/test-utils": "^4.3.2",
32
32
  "nuxt": "^4.5.2",
33
- "@easy-cms/core": "^0.2.0",
34
- "@easy-cms/db-sqlite": "^0.2.0"
33
+ "vue": "^3.5.0",
34
+ "@easy-cms/core": "^0.4.0",
35
+ "@easy-cms/db-sqlite": "^0.4.0"
35
36
  },
36
37
  "publishConfig": {
37
38
  "access": "public"