-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
297ac7b
commit 7e692f2
Showing
7 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
import {ref} from "vue"; | ||
import axios from "axios"; | ||
|
||
export default function usePosts() { | ||
export default function usePosts(slug) { | ||
const posts = ref([]); | ||
const post = ref({}); | ||
|
||
const fetchPosts = async () => { | ||
let response = await axios.get('/api/posts'); | ||
|
||
posts.value = response.data.data | ||
} | ||
|
||
const fetchPost = async () => { | ||
let response = await axios.get(`/api/posts/${slug}`); | ||
|
||
post.value = response.data.data | ||
} | ||
|
||
return { | ||
posts, | ||
fetchPosts | ||
post, | ||
fetchPosts, | ||
fetchPost | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup> | ||
import usePosts from "../api/usePosts.js"; | ||
import { onMounted } from "vue"; | ||
const props = defineProps({ | ||
slug: { | ||
type: String, | ||
required: true | ||
} | ||
}) | ||
const {post, fetchPost} = usePosts(props.slug) | ||
onMounted(fetchPost) | ||
</script> | ||
|
||
<template> | ||
<h1 class="block text-center text-4xl sm:text-6xl leading-10 font-extrabold tracking-tight text-gray-900"> | ||
{{ post.title }} | ||
</h1> | ||
<div class="prose lg:prose-xl mt-16 text-gray-500" v-html="post.body"></div> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ export default { | |
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
plugins: [ | ||
require('@tailwindcss/typography'), | ||
], | ||
} | ||
|