Skip to content

Commit

Permalink
feat(#427): add multilingual content support
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed May 24, 2022
1 parent 12ced4f commit f21b691
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 181 deletions.
22 changes: 0 additions & 22 deletions components/druxt/block-region/BannerTop.vue

This file was deleted.

13 changes: 2 additions & 11 deletions components/druxt/block-region/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

<b-collapse id="nav-collapse" class="ml-auto" is-nav>
<b-navbar-nav class="ml-auto">
<b-nav-item>
<b-button v-b-toggle.search><BIconSearch /></b-button>
</b-nav-item>
<DruxtBlockLanguageBlock />
<b-nav-item v-b-toggle.search>Search</b-nav-item>
</b-navbar-nav>

<!-- Main menu -->
Expand All @@ -23,11 +22,3 @@
</b-collapse>
</b-container>
</template>

<script>
import { BIconSearch } from 'bootstrap-vue'
export default {
components: { BIconSearch },
}
</script>
46 changes: 46 additions & 0 deletions components/druxt/block/LanguageBlock.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<b-nav-item-dropdown
v-if="!$fetchState.pending"
:text="selected"
>
<b-dropdown-item
v-for="language of languages.filter((o) => o.attributes.drupal_internal__id !== 'und')"
:key="language.attributes.drupal_internal__id"
:to="`/${language.attributes.drupal_internal__id}`"
>
{{ language.attributes.label }}
</b-dropdown-item>
</b-nav-item-dropdown>

<span v-else />
</template>

<script>
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { DruxtBlocksBlockMixin } from 'druxt-blocks'
export default {
mixins: [DruxtBlocksBlockMixin],
data: () => ({
languages: [],
}),
async fetch() {
const resourceType = 'configurable_language--configurable_language'
const query = new DrupalJsonApiParams()
.addFilter('drupal_internal__id', ['zxx'], 'NOT IN')
.addFields(resourceType, ['drupal_internal__id', 'label', 'langcode'])
this.languages = (await this.$store.dispatch('druxt/getCollection', {
type: resourceType,
query
})).data
},
computed: {
selected: ({ $route, languages }) => ($route.meta || {}).langcode
? (languages.find((o) => o.attributes.drupal_internal__id === $route.meta.langcode).attributes || {}).label || ''
: ((languages.find((o) => o.attributes.drupal_internal__id === ((languages.find((o) => o.attributes.drupal_internal__id === 'und') || {}).attributes || {}).langcode) || {}).attributes || {}).label || '',
}
}
</script>
10 changes: 2 additions & 8 deletions components/druxt/breadcrumb/Default.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<template>
<b-breadcrumb :items="items" />
<b-breadcrumb :items="crumbs" />
</template>

<script>
import { DruxtBreadcrumbMixin } from 'druxt-breadcrumb'
export default {
mixins: [DruxtBreadcrumbMixin],
computed: {
items() {
return (this.crumbs || []).filter((item) => item.to !== '/')
},
},
mixins: [DruxtBreadcrumbMixin]
}
</script>
3 changes: 1 addition & 2 deletions components/druxt/entity/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export default {
}),
computed: {
/* @todo - Implement proper multilingual support */
to: ({ entity }) => `/en${entity.attributes.path.alias}`,
to: ({ entity }) => `/${entity.attributes.path.langcode}${entity.attributes.path.alias}`,
},
druxt: {
Expand Down
3 changes: 1 addition & 2 deletions components/druxt/entity/Teaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export default {
}),
computed: {
/* @todo - Implement proper multilingual support */
to: ({ entity }) => `/en${entity.attributes.path.alias}`,
to: ({ entity }) => `/${entity.attributes.path.langcode}${entity.attributes.path.alias}`,
},
druxt: {
Expand Down
5 changes: 0 additions & 5 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ export default {
},
},

proxy: {
'/en/jsonapi': baseUrl,
'/es/jsonapi': baseUrl,
},

// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
extend(config) {
Expand Down
Loading

0 comments on commit f21b691

Please sign in to comment.