<template> <article v-show="article.lemmas.length"> <Header :lemmas="article.lemmas" /> <section v-if="article.body.pronunciation.length"> <h3>Uttale</h3> <ul> <DefElement v-for="(element, index) in article.body.pronunciation" :key="index" :body='element' @article-click="article_link_click" /> </ul> </section> <section v-if="article.body.etymology"> <h3>Etymologi</h3> <ul> <DefElement v-for="(element, index) in article.body.etymology" :key="index" :body='element' @article-click="article_link_click" /> </ul> </section> <section> <h3>Definisjoner</h3> <ol> <Definition v-for="definition in definitions" :key="definition.id" :body='definition' @article-click="article_link_click" /> </ol> </section> </article> </template> <script> //import axios from "axios"; import DefElement from './DefElement.vue' import Definition from './Definition.vue' import Header from './Header.vue' export default { name: 'Article', props: { article: Object }, components: { DefElement, Definition, Header }, computed: { definitions: function() { let defs = this.article.body.definitions if (defs.length == 1) { let types = defs[0].elements.reduce((acc, toAdd)=>acc.add(toAdd.type_), new Set()) if (types.size == 1 && types.has('definition')) { return defs[0].elements } } return defs } }, methods: { article_link_click: function(item) { this.$emit('article-click', item) } } } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style> article { margin-top: 30px; } h3 { margin: 40px 0 0; } a { //color: #42b983; } ol > li { padding-bottom: 2em; } ol > li:only-child { list-style: none; } ul { padding-top: 8px; } ul li { list-style:none; } li ul .definition ul { padding-left: 6px; } ul li.definition { list-style: disc; } </style>