@yassidev/nuxt-directus 0.0.6 → 0.0.8
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.d.mts +1 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +21 -12
- package/dist/runtime/client.d.ts +0 -1
- package/dist/runtime/client.js +1 -1
- package/dist/runtime/composables/graphql.d.ts +1 -1
- package/dist/runtime/composables/rest.d.ts +1 -1
- package/dist/runtime/constants.d.ts +1 -0
- package/dist/runtime/constants.js +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -570,7 +570,6 @@ interface ModuleOptions {
|
|
|
570
570
|
alias?: string;
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
|
-
declare const NAME = "directus";
|
|
574
573
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
575
574
|
|
|
576
|
-
export {
|
|
575
|
+
export { _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import { defineNuxtModule, useLogger, updateRuntimeConfig, hasNuxtModule, create
|
|
|
2
2
|
import { generateDirectusTypes } from 'directus-sdk-typegen';
|
|
3
3
|
import { fetchTranslations, syncTranslations } from '../dist/runtime/server.js';
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { NAME } from '../dist/runtime/constants.js';
|
|
6
|
+
import { join } from 'node:path';
|
|
5
7
|
|
|
6
8
|
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
7
9
|
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
@@ -91,7 +93,6 @@ function createDefu(merger) {
|
|
|
91
93
|
}
|
|
92
94
|
const defu = createDefu();
|
|
93
95
|
|
|
94
|
-
const NAME = "directus";
|
|
95
96
|
const module = defineNuxtModule({
|
|
96
97
|
meta: { name: NAME },
|
|
97
98
|
setup(options, nuxt) {
|
|
@@ -183,30 +184,38 @@ function setupI18n(config, nuxt, logger) {
|
|
|
183
184
|
accessToken: config.accessToken,
|
|
184
185
|
i18nPrefix: config.i18n.prefix
|
|
185
186
|
};
|
|
187
|
+
const path = "directus/locales";
|
|
188
|
+
const dirPath = resolve(nuxt.options.buildDir, path);
|
|
189
|
+
nuxt.options.watch.push(join(dirPath, "**"));
|
|
190
|
+
nuxt.options.vite.server = defu(nuxt.options.vite.server, {
|
|
191
|
+
watch: {
|
|
192
|
+
ignored: [`!${join(dirPath, "**")}`]
|
|
193
|
+
}
|
|
194
|
+
});
|
|
186
195
|
codes.map((code) => {
|
|
187
196
|
const { dst } = addTemplate({
|
|
188
197
|
write: true,
|
|
189
|
-
filename:
|
|
198
|
+
filename: `${path}/${code}.json`,
|
|
190
199
|
getContents: () => fetchTranslations(code, runtimeConfig).then((translations) => {
|
|
191
200
|
return JSON.stringify(Object.fromEntries(translations.map((translation) => [translation.key, translation.value])), null, 2);
|
|
192
201
|
})
|
|
193
202
|
});
|
|
194
|
-
nuxt.hook("builder:watch", async (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
203
|
+
nuxt.hook("builder:watch", async (_, filePath) => {
|
|
204
|
+
console.log("filePath", filePath, dst);
|
|
205
|
+
if (filePath !== dst) return;
|
|
206
|
+
const translations = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
207
|
+
const done = await syncTranslations(code, translations, runtimeConfig);
|
|
208
|
+
if (!done) return;
|
|
209
|
+
logger.info(`Synced translations for locale: ${code}`);
|
|
201
210
|
});
|
|
202
211
|
});
|
|
203
212
|
}
|
|
204
213
|
nuxt.hook("i18n:registerModule", (register) => {
|
|
205
214
|
const locales = codes.map((code) => ({
|
|
206
215
|
code,
|
|
207
|
-
file: "index
|
|
216
|
+
file: resolve("./runtime/lang/index")
|
|
208
217
|
}));
|
|
209
|
-
register({ langDir:
|
|
218
|
+
register({ langDir: "", locales });
|
|
210
219
|
logger.success("Locales have been registered: " + codes.join(", "));
|
|
211
220
|
});
|
|
212
221
|
}
|
|
@@ -243,4 +252,4 @@ function setupImage(config, nuxt, logger) {
|
|
|
243
252
|
logger.info(`Image alias has been registered: ${config.image.alias} -> ${config.url}`);
|
|
244
253
|
}
|
|
245
254
|
|
|
246
|
-
export {
|
|
255
|
+
export { module as default };
|
package/dist/runtime/client.d.ts
CHANGED
package/dist/runtime/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use directus (rest)
|
|
3
3
|
*/
|
|
4
|
-
export declare function useDirectus(): import("@directus/sdk").DirectusClient<
|
|
4
|
+
export declare function useDirectus(): import("@directus/sdk").DirectusClient<Schema> & import("@directus/sdk").GraphqlClient<Schema>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use directus (rest)
|
|
3
3
|
*/
|
|
4
|
-
export declare function useDirectus(): import("@directus/sdk").DirectusClient<
|
|
4
|
+
export declare function useDirectus(): import("@directus/sdk").DirectusClient<Schema> & import("@directus/sdk").RestClient<Schema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NAME = "directus";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const NAME = "directus";
|
package/dist/types.d.mts
CHANGED