<template>
  <div>
    <span v-for="(g, i) in gotten" :key="`post-${i}`">
      <index :post="g.slug" :index="i" @refresh-blog="get" />
    </span>
  </div>
</template>

<script>
  import index from '../components/index';
  import Cookie from 'js-cookie';

  export default {
    name: 'blog',
    components: { index },
    data () { return { gotten: [] } },
    created: function () { this.get(); },
    // watch: { '$route.params.slug': function (i) { this.get(); } },
    methods: {
      get: function () {
        this.gotten = [];

        axios.get('/api/rpc/site/post/get/all', { params: { kero_token: Cookie.get('kero_token') } }).then(res => {
          res.data.forEach(cb => {
            this.gotten.push({ slug: cb.slug });
          });
        });
      }
    }
  }
</script>

