spaceless

This commit is contained in:
Avris 2020-09-23 23:00:01 +02:00
parent 42cc597618
commit 847dc5d3c8
2 changed files with 29 additions and 4 deletions

View File

@ -8,10 +8,12 @@
<a v-if="author.mail" :href="'mailto:' + author.mail" target="_blank" rel="noopener"><Icon v="envelope"/></a>)
<template v-for="(link, area, index) in author.areas">
<nuxt-link v-if="link && link.indexOf('/') === 0" :to="link">{{ area }}</nuxt-link>
<a v-else-if="link" :href="link" target="_blank" rel="noopener">{{ area }}</a>
<span v-else>{{ area }}</span>
<span v-if="index < Object.keys(author.areas).length - 1">, </span>
<Spaceless>
<nuxt-link v-if="link && link.indexOf('/') === 0" :to="link">{{ area }}</nuxt-link>
<a v-else-if="link" :href="link" target="_blank" rel="noopener">{{ area }}</a>
<span v-else>{{ area }}</span>
<span v-if="index < Object.keys(author.areas).length - 1">, </span>
</Spaceless>
</template>
</li>
</ul>

23
components/Spaceless.vue Normal file
View File

@ -0,0 +1,23 @@
<template>
<span><slot></slot></span>
</template>
<script>
export default {
mounted() {
this.removeWhitespaces(this.$el);
},
methods: {
removeWhitespaces(parent) {
for (let child of parent.childNodes) {
if (child.nodeName === '#text' && child.textContent.trim() === '') {
parent.removeChild(child);
}
for (let grandchild of child.childNodes) {
this.removeWhitespaces(grandchild);
}
}
}
},
}
</script>