druxt 0.19.0 → 0.19.3
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/druxt.esm.js +33 -17
- package/dist/druxt.ssr.js +32 -16
- package/package.json +1 -2
- package/{stories → templates/stories}/README.stories.mdx +0 -0
- package/{dist/components/DruxtDebug.stories.mjs → templates/stories/druxt-debug.stories.js} +7 -3
- package/{dist/components/DruxtModule.stories.mdx → templates/stories/druxt-module.stories.mdx} +2 -2
package/dist/druxt.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
|
|
3
|
-
import { join, resolve } from 'path';
|
|
3
|
+
import { join, resolve, normalize } from 'path';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { stringify } from 'querystring';
|
|
6
6
|
import consola from 'consola';
|
|
@@ -251,7 +251,7 @@ class DruxtClient {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
var name = "druxt";
|
|
254
|
-
var version = "0.19.
|
|
254
|
+
var version = "0.19.3";
|
|
255
255
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
256
256
|
var keywords = [
|
|
257
257
|
"cms",
|
|
@@ -285,7 +285,6 @@ var main = "dist/druxt.ssr.js";
|
|
|
285
285
|
var module = "dist/druxt.esm.js";
|
|
286
286
|
var files = [
|
|
287
287
|
"dist",
|
|
288
|
-
"stories",
|
|
289
288
|
"templates"
|
|
290
289
|
];
|
|
291
290
|
var dependencies = {
|
|
@@ -340,6 +339,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
340
339
|
...moduleOptions,
|
|
341
340
|
...(this.options || {}).druxt
|
|
342
341
|
};
|
|
342
|
+
this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
|
|
343
|
+
this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
|
|
343
344
|
const druxt = new DruxtClient(options.baseUrl, {
|
|
344
345
|
...options,
|
|
345
346
|
proxy: { ...options.proxy || {}, api: false }
|
|
@@ -348,11 +349,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
348
349
|
const proxies = {};
|
|
349
350
|
if ((options.proxy || {}).api) {
|
|
350
351
|
proxies[options.endpoint] = options.baseUrl;
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
352
|
+
const languageResourceType = "configurable_language--configurable_language";
|
|
353
|
+
if ((await druxt.getIndex(languageResourceType) || {}).href) {
|
|
354
|
+
const query = new DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
|
|
355
|
+
const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
|
|
356
|
+
for (const langcode of languages) {
|
|
357
|
+
proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
|
|
358
|
+
}
|
|
356
359
|
}
|
|
357
360
|
proxies["/router/translate-path"] = options.baseUrl;
|
|
358
361
|
}
|
|
@@ -363,13 +366,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
363
366
|
if (this.options.proxy) {
|
|
364
367
|
if (Array.isArray(this.options.proxy)) {
|
|
365
368
|
this.options.proxy = [
|
|
366
|
-
...
|
|
367
|
-
...
|
|
369
|
+
...this.options.proxy,
|
|
370
|
+
...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
|
|
368
371
|
];
|
|
369
372
|
} else {
|
|
370
373
|
this.options.proxy = {
|
|
371
|
-
...
|
|
372
|
-
...
|
|
374
|
+
...this.options.proxy,
|
|
375
|
+
...proxies
|
|
373
376
|
};
|
|
374
377
|
}
|
|
375
378
|
} else {
|
|
@@ -396,10 +399,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
396
399
|
const extendPlugins = this.options.extendPlugins;
|
|
397
400
|
this.options.extendPlugins = (plugins) => {
|
|
398
401
|
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
|
|
399
|
-
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
|
|
402
|
+
const axiosIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/axios.js`));
|
|
400
403
|
const axiosPlugin = plugins[axiosIndex];
|
|
401
404
|
plugins.splice(axiosIndex, 1);
|
|
402
|
-
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
|
|
405
|
+
const druxtIndex = plugins.findIndex(({ src }) => src === normalize(`${this.options.buildDir}/druxt.js`));
|
|
403
406
|
const druxtPlugin = plugins[druxtIndex];
|
|
404
407
|
plugins.splice(druxtIndex, 1);
|
|
405
408
|
plugins = [axiosPlugin, druxtPlugin, ...plugins];
|
|
@@ -414,10 +417,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
414
417
|
this.options.components = (_a = this.options.components) != null ? _a : true;
|
|
415
418
|
this.options.cli.badgeMessages.push(`${chalk.blue.bold("Druxt")} @ v${meta.version}`);
|
|
416
419
|
this.options.cli.badgeMessages.push(`${chalk.bold("API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
|
|
420
|
+
const self = this;
|
|
417
421
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
422
|
+
self.addTemplate({
|
|
423
|
+
src: resolve(__dirname, "../templates/stories/README.stories.mdx"),
|
|
424
|
+
fileName: "stories/druxt-README.stories.mdx"
|
|
425
|
+
});
|
|
426
|
+
stories.push(resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
|
|
427
|
+
self.addTemplate({
|
|
428
|
+
src: resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
|
|
429
|
+
fileName: "stories/druxt-module.stories.mdx"
|
|
430
|
+
});
|
|
431
|
+
stories.push(resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
|
|
432
|
+
self.addTemplate({
|
|
433
|
+
src: resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
|
|
434
|
+
fileName: "stories/druxt-debug.stories.js"
|
|
435
|
+
});
|
|
436
|
+
stories.push(resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
|
|
421
437
|
});
|
|
422
438
|
};
|
|
423
439
|
|
package/dist/druxt.ssr.js
CHANGED
|
@@ -264,7 +264,7 @@ class DruxtClient {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
var name = "druxt";
|
|
267
|
-
var version = "0.19.
|
|
267
|
+
var version = "0.19.3";
|
|
268
268
|
var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
|
|
269
269
|
var keywords = [
|
|
270
270
|
"cms",
|
|
@@ -298,7 +298,6 @@ var main = "dist/druxt.ssr.js";
|
|
|
298
298
|
var module$1 = "dist/druxt.esm.js";
|
|
299
299
|
var files = [
|
|
300
300
|
"dist",
|
|
301
|
-
"stories",
|
|
302
301
|
"templates"
|
|
303
302
|
];
|
|
304
303
|
var dependencies = {
|
|
@@ -353,6 +352,8 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
353
352
|
...moduleOptions,
|
|
354
353
|
...(this.options || {}).druxt
|
|
355
354
|
};
|
|
355
|
+
this.options.baseUrl = options.baseUrl = options.baseUrl.endsWith("/") ? options.baseUrl.slice(0, -1) : options.baseUrl;
|
|
356
|
+
this.options.endpoint = options.endpoint = options.endpoint.startsWith("/") ? options.endpoint : `/${options.endpoint}`;
|
|
356
357
|
const druxt = new DruxtClient(options.baseUrl, {
|
|
357
358
|
...options,
|
|
358
359
|
proxy: { ...options.proxy || {}, api: false }
|
|
@@ -361,11 +362,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
361
362
|
const proxies = {};
|
|
362
363
|
if ((options.proxy || {}).api) {
|
|
363
364
|
proxies[options.endpoint] = options.baseUrl;
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
const languageResourceType = "configurable_language--configurable_language";
|
|
366
|
+
if ((await druxt.getIndex(languageResourceType) || {}).href) {
|
|
367
|
+
const query = new drupalJsonapiParams.DrupalJsonApiParams().addFields(languageResourceType, ["drupal_internal__id"]);
|
|
368
|
+
const languages = (await druxt.getCollectionAll(languageResourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(((o || {}).attributes || {}).drupal_internal__id)).map((o) => o.attributes.drupal_internal__id);
|
|
369
|
+
for (const langcode of languages) {
|
|
370
|
+
proxies[`/${langcode}${options.endpoint}`] = options.baseUrl;
|
|
371
|
+
}
|
|
369
372
|
}
|
|
370
373
|
proxies["/router/translate-path"] = options.baseUrl;
|
|
371
374
|
}
|
|
@@ -376,13 +379,13 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
376
379
|
if (this.options.proxy) {
|
|
377
380
|
if (Array.isArray(this.options.proxy)) {
|
|
378
381
|
this.options.proxy = [
|
|
379
|
-
...
|
|
380
|
-
...
|
|
382
|
+
...this.options.proxy,
|
|
383
|
+
...Object.keys(proxies).map((path) => `${options.baseUrl}${path}`)
|
|
381
384
|
];
|
|
382
385
|
} else {
|
|
383
386
|
this.options.proxy = {
|
|
384
|
-
...
|
|
385
|
-
...
|
|
387
|
+
...this.options.proxy,
|
|
388
|
+
...proxies
|
|
386
389
|
};
|
|
387
390
|
}
|
|
388
391
|
} else {
|
|
@@ -409,10 +412,10 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
409
412
|
const extendPlugins = this.options.extendPlugins;
|
|
410
413
|
this.options.extendPlugins = (plugins) => {
|
|
411
414
|
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins;
|
|
412
|
-
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`);
|
|
415
|
+
const axiosIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/axios.js`));
|
|
413
416
|
const axiosPlugin = plugins[axiosIndex];
|
|
414
417
|
plugins.splice(axiosIndex, 1);
|
|
415
|
-
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`);
|
|
418
|
+
const druxtIndex = plugins.findIndex(({ src }) => src === path.normalize(`${this.options.buildDir}/druxt.js`));
|
|
416
419
|
const druxtPlugin = plugins[druxtIndex];
|
|
417
420
|
plugins.splice(druxtIndex, 1);
|
|
418
421
|
plugins = [axiosPlugin, druxtPlugin, ...plugins];
|
|
@@ -427,10 +430,23 @@ const DruxtNuxtModule = async function(moduleOptions = {}) {
|
|
|
427
430
|
this.options.components = (_a = this.options.components) != null ? _a : true;
|
|
428
431
|
this.options.cli.badgeMessages.push(`${chalk__default["default"].blue.bold("Druxt")} @ v${meta.version}`);
|
|
429
432
|
this.options.cli.badgeMessages.push(`${chalk__default["default"].bold("API:")} ${chalk__default["default"].blue.underline(options.baseUrl + options.endpoint)}`);
|
|
433
|
+
const self = this;
|
|
430
434
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
435
|
+
self.addTemplate({
|
|
436
|
+
src: path.resolve(__dirname, "../templates/stories/README.stories.mdx"),
|
|
437
|
+
fileName: "stories/druxt-README.stories.mdx"
|
|
438
|
+
});
|
|
439
|
+
stories.push(path.resolve(self.options.buildDir, "./stories/druxt-README.stories.mdx"));
|
|
440
|
+
self.addTemplate({
|
|
441
|
+
src: path.resolve(__dirname, "../templates/stories/druxt-module.stories.mdx"),
|
|
442
|
+
fileName: "stories/druxt-module.stories.mdx"
|
|
443
|
+
});
|
|
444
|
+
stories.push(path.resolve(self.options.buildDir, "./stories/druxt-module.stories.mdx"));
|
|
445
|
+
self.addTemplate({
|
|
446
|
+
src: path.resolve(__dirname, "../templates/stories/druxt-debug.stories.js"),
|
|
447
|
+
fileName: "stories/druxt-debug.stories.js"
|
|
448
|
+
});
|
|
449
|
+
stories.push(path.resolve(self.options.buildDir, "./stories/druxt-debug.stories.js"));
|
|
434
450
|
});
|
|
435
451
|
};
|
|
436
452
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"module": "dist/druxt.esm.js",
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
37
|
-
"stories",
|
|
38
37
|
"templates"
|
|
39
38
|
],
|
|
40
39
|
"dependencies": {
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import DruxtDebug from '
|
|
1
|
+
import DruxtDebug from 'druxt/dist/components/DruxtDebug.vue'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'Druxt/DruxtDebug',
|
|
@@ -27,7 +27,9 @@ Json.args = {
|
|
|
27
27
|
}
|
|
28
28
|
Json.parameters = {
|
|
29
29
|
docs: {
|
|
30
|
-
|
|
30
|
+
description: {
|
|
31
|
+
story: 'The **json** prop takes any data and runs it through a basic JSON formatter for improved readability.',
|
|
32
|
+
},
|
|
31
33
|
source: {
|
|
32
34
|
code: '<DruxtDebug :json="entity" open>Debug information</DruxtDebug>'
|
|
33
35
|
},
|
|
@@ -40,7 +42,9 @@ Summary.args = {
|
|
|
40
42
|
}
|
|
41
43
|
Summary.parameters = {
|
|
42
44
|
docs: {
|
|
43
|
-
|
|
45
|
+
description: {
|
|
46
|
+
story: 'The **summary** prop can be used to provide a quick explanation of the debug component.',
|
|
47
|
+
},
|
|
44
48
|
source: {
|
|
45
49
|
code: `<DruxtDebug summary="${Summary.args.sumary}">Debug information</DruxtDebug>`
|
|
46
50
|
},
|
package/{dist/components/DruxtModule.stories.mdx → templates/stories/druxt-module.stories.mdx}
RENAMED
|
@@ -102,7 +102,7 @@ Druxt module.
|
|
|
102
102
|
import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
103
103
|
export default {
|
|
104
104
|
name: 'MyModule',
|
|
105
|
-
extends: DruxtModule
|
|
105
|
+
extends: DruxtModule,
|
|
106
106
|
druxt: {
|
|
107
107
|
async fetchConfig() {
|
|
108
108
|
// Load configuration data here.
|
|
@@ -113,7 +113,7 @@ export default {
|
|
|
113
113
|
// Build nested arrays of component options based on the context.
|
|
114
114
|
componentOptions: (context) => ([['default']]),
|
|
115
115
|
// Map props data from the context.
|
|
116
|
-
propsData: (context) => ({
|
|
116
|
+
propsData: (context) => ({}),
|
|
117
117
|
// Build slots render arrays.
|
|
118
118
|
slots(h) {
|
|
119
119
|
return {
|