hn-vue/mynuxt/pages/index.vue
2021-01-22 15:37:48 +01:00

67 lines
1.3 KiB
Vue

<template>
<div class="container">
<p v-if="$fetchState.pending">En cours de chargement ...</p>
<ul v-else>
<li v-for="link in links" :key="link.id">
<nuxt-link :to="`/links/${link.id}`">{{ link.url }}</nuxt-link>
</li>
</ul>
<p>Valeur: {{ $store.state.counter.value }}</p>
<button @click.prevent="$store.commit('counter/increment')">
Incrémenter
</button>
</div>
</template>
<script>
export default {
async fetch() {
this.links = await fetch(process.env.API_URL + "/api/links").then(r =>
r.json()
);
},
head() {
return {
title: `Derniers liens publiés (${this.links && this.links.length})`
};
},
data() {
return { links: null };
}
};
</script>
<style>
.container {
margin: 0 auto;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.title {
font-family: "Quicksand", "Source Sans Pro", -apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
display: block;
font-weight: 300;
font-size: 100px;
color: #35495e;
letter-spacing: 1px;
}
.subtitle {
font-weight: 300;
font-size: 42px;
color: #526488;
word-spacing: 5px;
padding-bottom: 15px;
}
.links {
padding-top: 15px;
}
</style>