Skip to content
Snippets Groups Projects
Commit 2b455066 authored by Petr Kalashnikov's avatar Petr Kalashnikov
Browse files

Fjerne tomme blokker med forklaringer med titler

parent 911b2d48
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@
<DefElement v-for="(element, index) in article.body.etymology" :dictionary="dictionary" :key="index" :body='element' @article-click="article_link_click" />
</ul>
</section>
<section class="definitions">
<section class="definitions" v-if="has_content">
<h3>{{def_label}}</h3>
<ol>
<Definition v-for="definition in article.body.definitions" :dictionary="dictionary" :level="1" :key="definition.id" :body='definition' @article-click="article_link_click" />
......@@ -55,6 +55,20 @@ function find_sub_articles(definition) {
return sub_art_list
}
function find_content(definition) {
let content_list = []
let sub_definitions = definition.elements.filter(el => el.type_ == 'definition')
sub_definitions.forEach((subdef, i) => {
content_list = content_list.concat(find_content(subdef))
})
let content_nodes = definition.elements.filter(el => ['explanation', 'example', 'compound_list'].includes(el.type_))
content_list = content_list.concat(content_nodes)
return content_list
}
export default {
name: 'Article',
props: {
......@@ -78,6 +92,9 @@ export default {
},
sub_articles: function() {
return this.article.body.definitions.reduce((acc, val) => acc.concat(find_sub_articles(val)), []).sort((s1, s2) => s1.lemmas[0].localeCompare(s2.lemmas[0]))
},
has_content: function() {
return this.article.body.definitions.reduce((acc, val) => acc.concat(find_content(val)), []).length > 0
}
},
components: {
......@@ -189,4 +206,4 @@ ul li.definition {
vertical-align: sub;
}
</style>
</style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment