Socket
Socket
Sign inDemoInstall

druxt-site

Package Overview
Dependencies
103
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.3.0

214

dist/druxt-site.esm.js

@@ -0,12 +1,28 @@

import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
import { DruxtComponentMixin } from 'druxt';
import { mapActions } from 'vuex';
import { resolve } from 'path';
//
/**
* The `<DruxtSite />` Vue.js component.
*
* - Loads available Block regions for the specified theme.
* - Renders Block regions via the `<DruxtBlockRegion />` component.
* - Supports the Druxt slot based themeing system.
*
* @example @lang vue
* <DruxtSite />
* <template>
* <DruxtSite theme="umami" />
* </template>
*
* @example @lang vue
* <Druxt module="site" />
* @example <caption>DruxtSite**Umami**.vue</caption> @lang vue
* <template>
* <div>
* <slot name="header" />
* <slot name="content" />
* <slot name="footer" />
* </div>
* </template>
*
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlockRegion|DruxtBlockRegion}
*/

@@ -16,4 +32,103 @@ var script = {

/**
* Vue.js Mixins.
*
* @see {@link https://druxtjs.org/api/mixins/component|DruxtComponentMixin}
*/
mixins: [DruxtComponentMixin],
/**
* Vue.js Properties.
*/
props: {
/**
* Drupal theme ID.
*
* Used to filter the available regions from the Drupal Blocks JSON:API
* resources.
*
* @type {string}
*/
theme: {
type: String,
required: true
}
},
/**
* Nuxt.js fetch method.
*
* Fetches theme filtered region names from the Block JSON:API resources to be
* used to render the `<DruxtBlockRegion />`'s.
*/
fetch: async function fetch() {
// Fetch all available regions.
var resourceType = 'block--block';
var regions = await this.getResources({
resource: resourceType,
query: new DrupalJsonApiParams()
.addFilter('theme', this.theme)
.addFields(resourceType, ['region']),
}).then(function (resources) { return resources.map(function (resource) { return resource.attributes.region; }).filter(function (v, i, s) { return s.indexOf(v) === i; }); });
this.regions = regions;
// Invoke DruxtComponent mixin.
await DruxtComponentMixin.fetch.call(this);
},
/**
* @property {string[]} regions - An array of unique region names.
*/
data: function () { return ({
regions: []
}); },
methods: Object.assign({}, mapActions({ getResources: 'druxtRouter/getResources' })),
render: function render(h) {
var this$1 = this;
var wrapperData = {
class: this.wrapper.class || undefined,
style: this.wrapper.style || undefined,
props: this.wrapper.propsData,
};
// Return only wrapper if fetch state is still pending.
if (this.$fetchState.pending) {
return h(this.wrapper.component, wrapperData)
}
// Build scoped slots for each region.
var scopedSlots = {};
Object.entries(this.regions).map(function (ref) {
var index = ref[0];
var region = ref[1];
scopedSlots[region] = function (attrs) { return h('DruxtBlockRegion', {
attrs: attrs,
props: {
name: region,
theme: this$1.theme
}
}); };
});
// Build default slot.
scopedSlots.default = function (attrs) { return Object.entries(this$1.regions).map(function (ref) {
var index = ref[0];
var region = ref[1];
return scopedSlots[region](attrs);
}); };
// Return wrapped component.
return h(this.wrapper.component, wrapperData, [
h(this.component.is, {
props: this.component.propsData,
scopedSlots: scopedSlots,
})
])
},
druxt: function (ref) {

@@ -23,3 +138,8 @@ var vm = ref.vm;

return ({
componentOptions: [['default']]
componentOptions: [[vm.theme], ['default']],
propsData: {
theme: vm.theme,
regions: vm.regions
}
});

@@ -108,4 +228,2 @@ }

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c(_vm.component.is,_vm._b({tag:"component"},'component',_vm.component.propsData,false),[_c('Nuxt')],1)};
var __vue_staticRenderFns__ = [];

@@ -119,3 +237,3 @@ /* style */

/* functional template */
var __vue_is_functional_template__ = false;
var __vue_is_functional_template__ = undefined;
/* style inject */

@@ -130,3 +248,3 @@

var __vue_component__ = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
{},
__vue_inject_styles__,

@@ -144,19 +262,10 @@ __vue_script__,

/**
* Nuxt.js module function.
* Nuxt module function to install Druxt Site.
*
* - Adds the DruxtSite component.
* - Adds the core modules for DruxtJS Site:
* - [@nuxtjs/proxy](https://www.npmjs.com/package/@nuxtjs/proxy)
* - [druxt-blocks](http://npmjs.com/package/druxt-blocks)
* - [druxt-breadcrumb](http://npmjs.com/package/druxt-breadcrumb)
* - [druxt-entity](http://npmjs.com/package/druxt-entity)
* - [druxt-menu](http://npmjs.com/package/druxt-menu)
* - [druxt-router](http://npmjs.com/package/druxt-router)
* - [druxt-schema](http://npmjs.com/package/druxt-schema)
* - [druxt-search](http://npmjs.com/package/druxt-search)
* - [druxt-views](http://npmjs.com/package/druxt-views)
* - Adds the core modules for DruxtJS Site.
* - Adds default configuration for @nuxtjs/proxy.
* - Enables Vuex store.
*
* @param {object} moduleOptions - The Nuxt.js module options.
* @param {ModuleOptions} moduleOptions - The Nuxt.js module options.
*/

@@ -210,3 +319,62 @@ var DruxtSiteNuxtModule = function (moduleOptions) {

/**
* Module options object.
*
* @typedef {object} ModuleOptions
* @see {@link ./typedefs/moduleOptions|ModuleOptions}
*/
/**
* Provides Vue.js properties to render Drupal Site components.
*
* @mixin
*
* @example @lang vue
* <template>
* <div>
* <DruxtBlockRegion
* v-for="region of regions"
* :key="region"
* :name="region"
* :theme="theme"
* />
* </div>
* </template>
*
* <script>
* import { DruxtSiteMixin } from 'druxt-site'
*
* export default {
* mixins: [DruxtSiteMixin],
* }
* </script>
*/
var DruxtSiteMixin = {
/**
* Vue.js Properties.
*/
props: {
/**
* The Drupal theme ID.
*
* @type {string}
*/
theme: {
type: String,
required: true,
},
/**
* The Block region names.
*
* @type {string[]},
*/
regions: {
type: Array,
default: []
}
},
};
export default DruxtSiteNuxtModule;
export { __vue_component__ as DruxtSite };
export { __vue_component__ as DruxtSite, DruxtSiteMixin };

2

dist/druxt-site.min.js

@@ -1,1 +0,1 @@

var DruxtSite=function(t,e,n){"use strict";function o(t,e,n,o,i,r,s,d,u,a){"boolean"!=typeof s&&(u=d,d=s,s=!1);var p,c="function"==typeof n?n.options:n;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,i&&(c.functional=!0)),o&&(c._scopeId=o),r?(p=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,u(t)),t&&t._registeredComponents&&t._registeredComponents.add(r)},c._ssrRegister=p):e&&(p=s?function(t){e.call(this,a(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,d(t))}),p)if(c.functional){var x=c.render;c.render=function(t,e){return p.call(e),x(t,e)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,p):[p]}return n}var i=o({render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n(t.component.is,t._b({tag:"component"},"component",t.component.propsData,!1),[n("Nuxt")],1)},staticRenderFns:[]},undefined,{name:"DruxtSite",mixins:[e.DruxtComponentMixin],druxt:function(t){t.vm;return{componentOptions:[["default"]]}}},undefined,false,undefined,!1,void 0,void 0,void 0);return t.DruxtSite=i,t.default=function(t){if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");this.addPlugin({src:n.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-site.js",options:this.options.druxt});var e=["@nuxtjs/proxy","druxt","druxt-blocks","druxt-breadcrumb","druxt-entity","druxt-menu","druxt-router","druxt-schema","druxt-search","druxt-views"];for(var o in e)this.addModule(e[o]);void 0===this.options.proxy&&(this.options.proxy=[this.options.druxt.baseUrl+"/sites/default/files"]),void 0===((this.options.druxt||{}).menu||{}).jsonApiMenuItems&&(this.options.druxt.menu=Object.assign({},this.options.druxt.menu,{jsonApiMenuItems:!0})),this.options.store=!0},t}({},druxt,path);
var DruxtSite=function(t,e,n,r,i){"use strict";function o(t,e,n,r,i,o,s,u,a,d){"boolean"!=typeof s&&(a=u,u=s,s=!1);var p,c="function"==typeof n?n.options:n;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,i&&(c.functional=!0)),r&&(c._scopeId=r),o?(p=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,a(t)),t&&t._registeredComponents&&t._registeredComponents.add(o)},c._ssrRegister=p):e&&(p=s?function(t){e.call(this,d(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,u(t))}),p)if(c.functional){var h=c.render;c.render=function(t,e){return p.call(e),h(t,e)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,p):[p]}return n}var s=o({},undefined,{name:"DruxtSite",mixins:[n.DruxtComponentMixin],props:{theme:{type:String,required:!0}},fetch:async function(){var t="block--block",r=await this.getResources({resource:t,query:(new e.DrupalJsonApiParams).addFilter("theme",this.theme).addFields(t,["region"])}).then((function(t){return t.map((function(t){return t.attributes.region})).filter((function(t,e,n){return n.indexOf(t)===e}))}));this.regions=r,await n.DruxtComponentMixin.fetch.call(this)},data:function(){return{regions:[]}},methods:Object.assign({},r.mapActions({getResources:"druxtRouter/getResources"})),render:function(t){var e=this,n={class:this.wrapper.class||void 0,style:this.wrapper.style||void 0,props:this.wrapper.propsData};if(this.$fetchState.pending)return t(this.wrapper.component,n);var r={};return Object.entries(this.regions).map((function(n){n[0];var i=n[1];r[i]=function(n){return t("DruxtBlockRegion",{attrs:n,props:{name:i,theme:e.theme}})}})),r.default=function(t){return Object.entries(e.regions).map((function(e){e[0];var n=e[1];return r[n](t)}))},t(this.wrapper.component,n,[t(this.component.is,{props:this.component.propsData,scopedSlots:r})])},druxt:function(t){var e=t.vm;return{componentOptions:[[e.theme],["default"]],propsData:{theme:e.theme,regions:e.regions}}}},undefined,undefined,undefined,!1,void 0,void 0,void 0),u={props:{theme:{type:String,required:!0},regions:{type:Array,default:[]}}};return t.DruxtSite=s,t.DruxtSiteMixin=u,t.default=function(t){if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");this.addPlugin({src:i.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-site.js",options:this.options.druxt});var e=["@nuxtjs/proxy","druxt","druxt-blocks","druxt-breadcrumb","druxt-entity","druxt-menu","druxt-router","druxt-schema","druxt-search","druxt-views"];for(var n in e)this.addModule(e[n]);void 0===this.options.proxy&&(this.options.proxy=[this.options.druxt.baseUrl+"/sites/default/files"]),void 0===((this.options.druxt||{}).menu||{}).jsonApiMenuItems&&(this.options.druxt.menu=Object.assign({},this.options.druxt.menu,{jsonApiMenuItems:!0})),this.options.store=!0},t}({},drupalJsonapiParams,druxt,vuex,path);

@@ -1,9 +0,23 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:true});var druxt=require('druxt'),path=require('path');//
/**
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var drupalJsonapiParams=require('drupal-jsonapi-params'),druxt=require('druxt'),vuex=require('vuex'),path=require('path');/**
* The `<DruxtSite />` Vue.js component.
*
* - Loads available Block regions for the specified theme.
* - Renders Block regions via the `<DruxtBlockRegion />` component.
* - Supports the Druxt slot based themeing system.
*
* @example @lang vue
* <DruxtSite />
* <template>
* <DruxtSite theme="umami" />
* </template>
*
* @example @lang vue
* <Druxt module="site" />
* @example <caption>DruxtSite**Umami**.vue</caption> @lang vue
* <template>
* <div>
* <slot name="header" />
* <slot name="content" />
* <slot name="footer" />
* </div>
* </template>
*
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlockRegion|DruxtBlockRegion}
*/

@@ -13,4 +27,103 @@ var script = {

/**
* Vue.js Mixins.
*
* @see {@link https://druxtjs.org/api/mixins/component|DruxtComponentMixin}
*/
mixins: [druxt.DruxtComponentMixin],
/**
* Vue.js Properties.
*/
props: {
/**
* Drupal theme ID.
*
* Used to filter the available regions from the Drupal Blocks JSON:API
* resources.
*
* @type {string}
*/
theme: {
type: String,
required: true
}
},
/**
* Nuxt.js fetch method.
*
* Fetches theme filtered region names from the Block JSON:API resources to be
* used to render the `<DruxtBlockRegion />`'s.
*/
fetch: async function fetch() {
// Fetch all available regions.
var resourceType = 'block--block';
var regions = await this.getResources({
resource: resourceType,
query: new drupalJsonapiParams.DrupalJsonApiParams()
.addFilter('theme', this.theme)
.addFields(resourceType, ['region']),
}).then(function (resources) { return resources.map(function (resource) { return resource.attributes.region; }).filter(function (v, i, s) { return s.indexOf(v) === i; }); });
this.regions = regions;
// Invoke DruxtComponent mixin.
await druxt.DruxtComponentMixin.fetch.call(this);
},
/**
* @property {string[]} regions - An array of unique region names.
*/
data: function () { return ({
regions: []
}); },
methods: Object.assign({}, vuex.mapActions({ getResources: 'druxtRouter/getResources' })),
render: function render(h) {
var this$1 = this;
var wrapperData = {
class: this.wrapper.class || undefined,
style: this.wrapper.style || undefined,
props: this.wrapper.propsData,
};
// Return only wrapper if fetch state is still pending.
if (this.$fetchState.pending) {
return h(this.wrapper.component, wrapperData)
}
// Build scoped slots for each region.
var scopedSlots = {};
Object.entries(this.regions).map(function (ref) {
var index = ref[0];
var region = ref[1];
scopedSlots[region] = function (attrs) { return h('DruxtBlockRegion', {
attrs: attrs,
props: {
name: region,
theme: this$1.theme
}
}); };
});
// Build default slot.
scopedSlots.default = function (attrs) { return Object.entries(this$1.regions).map(function (ref) {
var index = ref[0];
var region = ref[1];
return scopedSlots[region](attrs);
}); };
// Return wrapped component.
return h(this.wrapper.component, wrapperData, [
h(this.component.is, {
props: this.component.propsData,
scopedSlots: scopedSlots,
})
])
},
druxt: function (ref) {

@@ -20,3 +133,8 @@ var vm = ref.vm;

return ({
componentOptions: [['default']]
componentOptions: [[vm.theme], ['default']],
propsData: {
theme: vm.theme,
regions: vm.regions
}
});

@@ -101,4 +219,2 @@ }

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c(_vm.component.is,_vm._b({tag:"component"},'component',_vm.component.propsData,false),[_c('Nuxt')],1)};
var __vue_staticRenderFns__ = [];

@@ -110,5 +226,5 @@ /* style */

/* module identifier */
var __vue_module_identifier__ = "data-v-9f5ed0f2";
var __vue_module_identifier__ = "data-v-7b4eec16";
/* functional template */
var __vue_is_functional_template__ = false;
var __vue_is_functional_template__ = undefined;
/* style inject */

@@ -123,3 +239,3 @@

var __vue_component__ = /*#__PURE__*/normalizeComponent(
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
{},
__vue_inject_styles__,

@@ -135,19 +251,10 @@ __vue_script__,

);/**
* Nuxt.js module function.
* Nuxt module function to install Druxt Site.
*
* - Adds the DruxtSite component.
* - Adds the core modules for DruxtJS Site:
* - [@nuxtjs/proxy](https://www.npmjs.com/package/@nuxtjs/proxy)
* - [druxt-blocks](http://npmjs.com/package/druxt-blocks)
* - [druxt-breadcrumb](http://npmjs.com/package/druxt-breadcrumb)
* - [druxt-entity](http://npmjs.com/package/druxt-entity)
* - [druxt-menu](http://npmjs.com/package/druxt-menu)
* - [druxt-router](http://npmjs.com/package/druxt-router)
* - [druxt-schema](http://npmjs.com/package/druxt-schema)
* - [druxt-search](http://npmjs.com/package/druxt-search)
* - [druxt-views](http://npmjs.com/package/druxt-views)
* - Adds the core modules for DruxtJS Site.
* - Adds default configuration for @nuxtjs/proxy.
* - Enables Vuex store.
*
* @param {object} moduleOptions - The Nuxt.js module options.
* @param {ModuleOptions} moduleOptions - The Nuxt.js module options.
*/

@@ -199,2 +306,59 @@ var DruxtSiteNuxtModule = function (moduleOptions) {

this.options.store = true;
};exports.DruxtSite=__vue_component__;exports.default=DruxtSiteNuxtModule;
};
/**
* Module options object.
*
* @typedef {object} ModuleOptions
* @see {@link ./typedefs/moduleOptions|ModuleOptions}
*//**
* Provides Vue.js properties to render Drupal Site components.
*
* @mixin
*
* @example @lang vue
* <template>
* <div>
* <DruxtBlockRegion
* v-for="region of regions"
* :key="region"
* :name="region"
* :theme="theme"
* />
* </div>
* </template>
*
* <script>
* import { DruxtSiteMixin } from 'druxt-site'
*
* export default {
* mixins: [DruxtSiteMixin],
* }
* </script>
*/
var DruxtSiteMixin = {
/**
* Vue.js Properties.
*/
props: {
/**
* The Drupal theme ID.
*
* @type {string}
*/
theme: {
type: String,
required: true,
},
/**
* The Block region names.
*
* @type {string[]},
*/
regions: {
type: Array,
default: []
}
},
};exports.DruxtSite=__vue_component__;exports.DruxtSiteMixin=DruxtSiteMixin;exports.default=DruxtSiteNuxtModule;
{
"name": "druxt-site",
"version": "0.2.2",
"version": "0.3.0",
"description": "Out of the box decoupled Drupal Site module for DruxtJS.",

@@ -46,25 +46,25 @@ "repository": {

"dependencies": {
"@nuxtjs/proxy": "^2.0.1",
"@nuxtjs/proxy": "^2.1.0",
"druxt": "^0.3.3",
"druxt-blocks": "^0.7.3",
"druxt-breadcrumb": "^0.6.0",
"druxt-entity": "^0.7.1",
"druxt-menu": "^0.5.0",
"druxt-router": "^0.16.0",
"druxt-blocks": "^0.7.4",
"druxt-breadcrumb": "^0.7.0",
"druxt-entity": "^0.8.0",
"druxt-menu": "^0.6.1",
"druxt-router": "^0.17.1",
"druxt-schema": "^0.6.0",
"druxt-search": "^0.1.0",
"druxt-views": "^0.5.0",
"druxt-views": "^0.6.0",
"md5": "^2.2.1",
"vuex": "^3.5.1"
"vuex": "^3.6.0"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@rollup/plugin-alias": "^2.2.0",
"@rollup/plugin-buble": "^0.20.0",
"@rollup/plugin-replace": "^2.2.1",
"@vue/test-utils": "^1.0.5",
"@rollup/plugin-replace": "^2.3.4",
"@vue/test-utils": "^1.1.2",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"bootstrap-vue": "^2.18.1",
"bootstrap-vue": "^2.21.1",
"cross-env": "^6.0.3",

@@ -71,0 +71,0 @@ "eslint": "^6.7.2",

@@ -8,4 +8,10 @@ # DruxtJS Site module

> The DruxtJS Site module provides an out of the box, decoupled Drupal site with minimal setup and configuration.
> The DruxtJS Site module provides an out of the box, decoupled Drupal site experience with minimal setup and configuration.
## Links
- DruxtJS: https://druxtjs.org
- Documentation: https://site.druxtjs.org
- Community Discord server: https://discord.druxtjs.org
## Install

@@ -17,3 +23,3 @@

Add module to `nuxt.config.js`
1. Add module to `nuxt.config.js`

@@ -31,2 +37,10 @@ ```js

2. Add the `DruxtSite` component to your layout:
```vue
<template>
<DruxtSite :theme="theme" >
</template>
```
## Options

@@ -33,0 +47,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc