Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#417): add default region with prefix fix #418

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions components/druxt/block-region/BannerTop.vue

This file was deleted.

46 changes: 46 additions & 0 deletions components/druxt/block-region/Default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div>
<template v-for="key of Object.keys($scopedSlots)">
<slot v-if="isVisible(key)" :name="key" />
</template>
</div>
</template>

<script>
import { mapState } from 'vuex'
import { DruxtBlocksRegionMixin } from 'druxt-blocks'

export default {
mixins: [DruxtBlocksRegionMixin],

computed: {
...mapState({
route: (state) => state.druxtRouter.route,
}),
},

methods: {
isVisible(key) {
const block = this.blocks.find((o) => o.attributes.drupal_internal__id === key) || {}
// Request path visibility conditions.
if (((block.attributes || {}).visibility || {}).request_path) {
let visible = false
const { negate } = block.attributes.visibility.request_path
const pages = block.attributes.visibility.request_path.pages.split(/\r?\n/).filter(i => i)
const route = this.route
// Remove the language prefix from the resolved path.
// @see https://github.com/druxt/demo.druxtjs.org/issues/417
route.resolvedPath = route.resolvedPath.replace('/en', '')
if (pages.includes('<front>') && (route.isHomePath || (!route.isHomePath && negate))) {
visible = true
}
if (pages.includes(route.resolvedPath) || (!pages.includes(route.resolvedPath) && negate)) {
visible = true
}
return visible
}
return false
}
}
}
</script>