<template>
  <div id="tag">
      <div class="meal" v-for="meal in meals">
        <h3>{{meal.category}}</h3>
        <p>{{meal.title}}</p>
      </div>
  </div>
</template>

<script>
export default {
  name: 'mensa',
  data () {
    return {
      meals: []
    }
  },
  watch: {$route: 'loadMeals'},
  created () {
    this.loadMeals()
  },
  methods: {
    loadMeals () {
      fetch(`/static/${this.$route.params.mensa}.${this.$route.params.tag}.json`)
      .then(res => res.json())
      .then(menu => { this.meals = menu.meals })
    }
  }
}
</script>

<style>
.meal{
  margin: 2em 0;
}

.meal>h3{
  margin-bottom:0em;
}

.meal>p{
  margin-top: 0.4em;
}
</style>
