Display notes
This commit is contained in:
parent
09d18c1d02
commit
bcc6f8e29f
@ -1,13 +1,3 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-app>
|
<nuxt />
|
||||||
<v-main>
|
|
||||||
<nuxt />
|
|
||||||
</v-main>
|
|
||||||
</v-app>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -2,18 +2,20 @@
|
|||||||
<div>
|
<div>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="text-blue-200">
|
<li
|
||||||
<router-link class="underline" to="/signin"
|
v-for="link in links"
|
||||||
>Sign In</router-link
|
:key="link.name"
|
||||||
|
class="text-blue-200"
|
||||||
|
>
|
||||||
|
<router-link
|
||||||
|
v-if="link.url"
|
||||||
|
:to="link.url"
|
||||||
|
class="underline"
|
||||||
|
>{{ link.name }}</router-link
|
||||||
>
|
>
|
||||||
</li>
|
<button v-else class="underline" @click="link.action">
|
||||||
<li class="text-blue-200">
|
{{ link.name }}
|
||||||
<router-link class="underline" to="/register"
|
</button>
|
||||||
>Register</router-link
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<li class="text-blue-200">
|
|
||||||
<button class="underline" @click="logout">Sign Out</button>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@ -28,6 +30,14 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
|
data: () => ({
|
||||||
|
links: [
|
||||||
|
{ url: '/signin', name: 'Sign In' },
|
||||||
|
{ url: '/register', name: 'Register' },
|
||||||
|
{ url: '/notes', name: 'Notes' },
|
||||||
|
{ action: 'logout', name: 'Sign Out' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
options: {
|
options: {
|
||||||
auth: false, // FIXME: auth: 'guest'
|
auth: false, // FIXME: auth: 'guest'
|
||||||
},
|
},
|
||||||
|
|||||||
51
frontend/pages/notes/_uuid.vue
Normal file
51
frontend/pages/notes/_uuid.vue
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div>{{ uuid }}</div>
|
||||||
|
<div v-if="note">{{ note }}</div>
|
||||||
|
<!-- html is sanitized -->
|
||||||
|
<!-- eslint-disable-next-line -->
|
||||||
|
<div class="container mx-auto" id="note" v-html="html"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState, mapActions } from 'vuex'
|
||||||
|
import renderMarkdown from '@/utils/markdown'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Note',
|
||||||
|
data: () => ({
|
||||||
|
note: {},
|
||||||
|
html: '',
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapState('notes', ['notes', 'isInitialized']),
|
||||||
|
uuid() {
|
||||||
|
return this.$route.params.uuid
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (!this.isInitialized) {
|
||||||
|
this.load().then(() => {
|
||||||
|
this.note = this.notes.find((e) => e.uuid === this.uuid)
|
||||||
|
this.render()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.note = this.notes.find((e) => e.uuid === this.uuid)
|
||||||
|
this.render()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions('notes', ['load']),
|
||||||
|
render() {
|
||||||
|
this.html = renderMarkdown(this.note.content).contents
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#note h1 {
|
||||||
|
@apply text-5xl font-bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -10,7 +10,9 @@
|
|||||||
/>
|
/>
|
||||||
<div v-for="note in notes" :key="note.uuid">
|
<div v-for="note in notes" :key="note.uuid">
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<h2 class="text-lg">{{ note.title }}</h2>
|
<router-link :to="'/notes/' + note.uuid" class="text-lg">{{
|
||||||
|
note.title
|
||||||
|
}}</router-link>
|
||||||
<div class="py-2">
|
<div class="py-2">
|
||||||
<span
|
<span
|
||||||
v-for="(tag, index) in note.tags"
|
v-for="(tag, index) in note.tags"
|
||||||
@ -24,9 +24,8 @@ export const mutations = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async load({ commit }) {
|
load({ commit }) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 600))
|
return this.$axios.get('/notes').then(({ data }) => {
|
||||||
this.$axios.get('/notes').then(({ data }) => {
|
|
||||||
commit('set', data)
|
commit('set', data)
|
||||||
commit('setInitialized')
|
commit('setInitialized')
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user