@b10cks/nuxt 0.9.6 → 0.10.1

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/README.md CHANGED
@@ -0,0 +1,70 @@
1
+ # @b10cks/nuxt
2
+
3
+ Nuxt 4 module for integrating b10cks into your Nuxt applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @b10cks/nuxt @b10cks/vue @b10cks/client
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ Add the module to your `nuxt.config.ts`:
14
+
15
+ ```typescript
16
+ export default defineNuxtConfig({
17
+ modules: ['@b10cks/nuxt'],
18
+ b10cks: {
19
+ accessToken: 'your-access-token',
20
+ apiUrl: 'https://api.b10cks.com/api',
21
+ componentsDir: '~/b10cks', // Optional: custom components directory
22
+ },
23
+ })
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Directives
29
+
30
+ #### `v-editable`
31
+ Mark content as editable within the b10cks editor.
32
+
33
+ ```vue
34
+ <div v-editable="block">
35
+ Content here
36
+ </div>
37
+ ```
38
+
39
+ #### `v-editable-field`
40
+ Mark specific fields within editable blocks.
41
+
42
+ ```vue
43
+ <div v-editable="block">
44
+ <h1 v-editable-field="{ id: block.id, field: 'title' }">Title</h1>
45
+ <p v-editable-field="{ id: block.id, field: 'description' }">Description</p>
46
+ </div>
47
+ ```
48
+
49
+ ### Components
50
+
51
+ #### `B10cksComponent`
52
+ Render b10cks components directly in your Nuxt app.
53
+
54
+ ```vue
55
+ <B10cksComponent :component="componentData" />
56
+ ```
57
+
58
+ ### Custom Components
59
+
60
+ Place your custom b10cks components in the `~/b10cks` directory (or your configured `componentsDir`). They will be auto-imported as global components.
61
+
62
+ ## Configuration
63
+
64
+ - `accessToken` - Your b10cks API access token (required)
65
+ - `apiUrl` - The b10cks API endpoint (default: `https://api.b10cks.com/api`)
66
+ - `componentsDir` - Directory for custom components (default: `~/b10cks`)
67
+
68
+ ## License
69
+
70
+ MIT
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@b10cks/nuxt",
3
3
  "configKey": "b10cks",
4
- "version": "0.9.6",
4
+ "version": "0.10.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineNuxtModule, createResolver, addComponentsDir, addPlugin, addImports } from '@nuxt/kit';
2
2
 
3
- const module = defineNuxtModule({
3
+ const module$1 = defineNuxtModule({
4
4
  meta: {
5
5
  name: "@b10cks/nuxt",
6
6
  configKey: "b10cks"
@@ -23,9 +23,13 @@ const module = defineNuxtModule({
23
23
  apiUrl: options.apiUrl
24
24
  };
25
25
  addPlugin(resolver.resolve("./runtime/plugin"));
26
- addImports({ name: "useB10cksApi", as: "useB10cksApi", from: resolver.resolve("./runtime/composables/useB10cksApi") });
26
+ addImports({
27
+ name: "useB10cksApi",
28
+ as: "useB10cksApi",
29
+ from: resolver.resolve("./runtime/composables/useB10cksApi")
30
+ });
27
31
  nuxt.options.typescript.hoist.push("@b10cks/vue");
28
32
  }
29
33
  });
30
34
 
31
- export { module as default };
35
+ export { module$1 as default };
@@ -1,5 +1,4 @@
1
- import type { IBBaseQueryParams, IBBlock, IBContent, IBContentQueryParams, IBDataEntry, IBDataSource, IBSpace, IBResponse } from '@b10cks/client';
2
- import type { Endpoint } from '@b10cks/client';
1
+ import type { Endpoint, IBBaseQueryParams, IBBlock, IBContent, IBContentQueryParams, IBDataEntry, IBDataSource, IBResponse, IBSpace } from '@b10cks/client';
3
2
  export interface UseB10cksApiOptions<T> {
4
3
  immediate?: boolean;
5
4
  params?: Omit<IBBaseQueryParams, 'token'>;
@@ -33,7 +33,7 @@ export const useB10cksApi = () => {
33
33
  };
34
34
  }
35
35
  function useApiCollection(endpoint, options = {}) {
36
- const { immediate = false, params = {}, transform } = options;
36
+ const { immediate = false, params = {} } = options;
37
37
  const pending = ref(false);
38
38
  const data = ref(null);
39
39
  const error = ref(null);
@@ -41,8 +41,7 @@ export const useB10cksApi = () => {
41
41
  pending.value = true;
42
42
  error.value = null;
43
43
  try {
44
- const results = await $b10cksClient.getAll(endpoint, params);
45
- data.value = transform ? transform(results) : results;
44
+ data.value = await $b10cksClient.getAll(endpoint, params);
46
45
  return data.value;
47
46
  } catch (err) {
48
47
  error.value = err instanceof Error ? err : new Error(String(err));
@@ -63,70 +62,52 @@ export const useB10cksApi = () => {
63
62
  };
64
63
  }
65
64
  const useContent = (full_slug, params = {}, options = {}) => {
66
- return useApiResource(
67
- `contents/${full_slug}`,
68
- {
69
- ...options,
70
- params,
71
- transform: (result) => {
72
- if ("data" in result) {
73
- return result.data;
74
- }
75
- return result;
65
+ return useApiResource(`contents/${full_slug}`, {
66
+ ...options,
67
+ params,
68
+ transform: (result) => {
69
+ if ("data" in result) {
70
+ return result.data;
76
71
  }
72
+ return result;
77
73
  }
78
- );
74
+ });
79
75
  };
80
76
  const useContents = (params = {}, options = {}) => {
81
- return useApiCollection(
82
- "contents",
83
- {
84
- ...options,
85
- params
86
- }
87
- );
77
+ return useApiCollection("contents", {
78
+ ...options,
79
+ params
80
+ });
88
81
  };
89
82
  const useBlocks = (params = {}, options = {}) => {
90
- return useApiCollection(
91
- "blocks",
92
- {
93
- ...options,
94
- params
95
- }
96
- );
83
+ return useApiCollection("blocks", {
84
+ ...options,
85
+ params
86
+ });
97
87
  };
98
88
  const useDataEntries = (source, params = {}, options = {}) => {
99
- return useApiCollection(
100
- `datasources/${source}/entries`,
101
- {
102
- ...options,
103
- params
104
- }
105
- );
89
+ return useApiCollection(`datasources/${source}/entries`, {
90
+ ...options,
91
+ params
92
+ });
106
93
  };
107
94
  const useDataSources = (options = {}) => {
108
- return useApiCollection(
109
- "datasources",
110
- options
111
- );
95
+ return useApiCollection("datasources", options);
112
96
  };
113
97
  const useSpace = (options = {}) => {
114
- return useApiResource(
115
- "spaces/me",
116
- {
117
- ...options,
118
- transform: (result) => {
119
- if ("data" in result) {
120
- return result.data;
121
- }
122
- return result;
98
+ return useApiResource("spaces/me", {
99
+ ...options,
100
+ transform: (result) => {
101
+ if ("data" in result) {
102
+ return result.data;
123
103
  }
104
+ return result;
124
105
  }
125
- );
106
+ });
126
107
  };
127
108
  const cache = useState("redirects");
128
109
  const useRedirects = (options = {}) => {
129
- const { immediate = true, params = {}, transform } = options;
110
+ const { immediate = true, params = {} } = options;
130
111
  const pending = ref(false);
131
112
  const data = ref(cache.value || null);
132
113
  const error = ref(null);
@@ -139,10 +120,7 @@ export const useB10cksApi = () => {
139
120
  try {
140
121
  const results = await $b10cksClient.getAll("redirects", params);
141
122
  const transformed = Object.fromEntries(
142
- results.map(({ source, target, status_code }) => [
143
- source,
144
- { target, status_code }
145
- ])
123
+ results.map(({ source, target, status_code }) => [source, { target, status_code }])
146
124
  );
147
125
  data.value = transformed;
148
126
  cache.value = transformed;
@@ -166,7 +144,12 @@ export const useB10cksApi = () => {
166
144
  };
167
145
  };
168
146
  const configCache = useState("config");
169
- const useB10cksConfig = async ({ slug = "_config", version, language, ...params } = {}) => {
147
+ const useB10cksConfig = async ({
148
+ slug = "_config",
149
+ version,
150
+ language,
151
+ ...params
152
+ } = {}) => {
170
153
  const options = {
171
154
  params: {
172
155
  ...params,
@@ -1,6 +1,7 @@
1
1
  import { ApiClient } from "@b10cks/client";
2
- import { previewBridge, B10cksVue } from "@b10cks/vue";
2
+ import { B10cksVue, previewBridge } from "@b10cks/vue";
3
3
  import { defineNuxtPlugin, useRequestURL, useRuntimeConfig } from "nuxt/app";
4
+ import { useState } from "#app";
4
5
  export default defineNuxtPlugin((nuxtApp) => {
5
6
  const config = useRuntimeConfig();
6
7
  const url = useRequestURL();
@@ -10,11 +11,19 @@ export default defineNuxtPlugin((nuxtApp) => {
10
11
  previewBridge.init();
11
12
  }
12
13
  }
13
- const b10cksClient = new ApiClient({
14
- baseUrl: config.public.b10cks.apiUrl || "https://api.b10cks.com/api",
15
- token: config.public.b10cks.accessToken,
16
- fetchClient: $fetch
17
- }, url);
14
+ const rvState = useState("b10cks_rv", () => 0);
15
+ const b10cksClient = new ApiClient(
16
+ {
17
+ baseUrl: config.public.b10cks.apiUrl || "https://api.b10cks.com/api",
18
+ token: config.public.b10cks.accessToken,
19
+ fetchClient: $fetch,
20
+ getRv: () => rvState.value,
21
+ setRv: (value) => {
22
+ rvState.value = value;
23
+ }
24
+ },
25
+ url
26
+ );
18
27
  return {
19
28
  provide: {
20
29
  b10cksClient
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@b10cks/nuxt",
3
3
  "license": "MIT",
4
- "version": "0.9.6",
4
+ "version": "0.10.1",
5
5
  "author": "Michael Wallner @ Coder's Cantina",
6
6
  "description": "b10cks Nuxt module",
7
7
  "type": "module",
@@ -21,12 +21,12 @@
21
21
  "dist"
22
22
  ],
23
23
  "devDependencies": {
24
- "@nuxt/eslint": "^1.9.0",
25
- "@nuxt/eslint-config": "^1.9.0",
26
- "@nuxt/kit": "^4.0.3",
24
+ "@nuxt/eslint": "^1.10.0",
25
+ "@nuxt/eslint-config": "^1.10.0",
26
+ "@nuxt/kit": "^4.2.1",
27
27
  "@nuxt/module-builder": "^1.0.2",
28
- "@nuxt/schema": "^4.0.3",
29
- "nuxt": "^4.0.3"
28
+ "@nuxt/schema": "^4.2.1",
29
+ "nuxt": "^4.2.1"
30
30
  },
31
31
  "release": {
32
32
  "branches": [
@@ -37,13 +37,13 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@b10cks/client": "^0.9.6",
41
- "@b10cks/vue": "^0.9.6"
40
+ "@b10cks/client": "^0.10.1",
41
+ "@b10cks/vue": "^0.10.1"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "nuxt-module-build prepare && nuxt-module-build build",
45
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts --fix",
46
- "lint:fix": "eslint . --fix",
45
+ "lint": "biome check --apply .",
46
+ "lint:fix": "biome check --apply .",
47
47
  "test": "vitest",
48
48
  "clean": "rm -rf dist"
49
49
  }