This file contains hidden or 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
| <template> | |
| <div> | |
| <div class="text-4xl font-bold">{{ post.title }}</div> | |
| <div>{{ post.body }}</div> | |
| <div class="italic mt-4"> | |
| Author: <span class="text-red-500">{{ user.name }}</span> | |
| </div> | |
| </div> | |
| </template> |
This file contains hidden or 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
| <template> | |
| <div class="mx-4 rounded bg-gray-400 shadow"> | |
| <div class="p-2"> | |
| <div class="font-bold">Latest Posts</div> | |
| </div> | |
| <div class="bg-white p-2 border-2 border-gray-400 "> | |
| <div v-for="post in recentPosts" :key="post.id"> | |
| <div class="mb-2"> | |
| - | |
| <router-link :key="`/post/${post.id}`" :to="`/post/${post.id}`">{{ |
This file contains hidden or 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
| <template> | |
| <div class="text-4xl font-bold mb-4">My Blog Roll</div> | |
| <div v-for="post in posts" :key="post.id"> | |
| <div class="bg-gray-200 mb-4 shadow p-2 rounded"> | |
| <div class="text-2xl font-semibold"> | |
| <router-link :to="`/post/${post.id}`">{{ post.title }}</router-link> | |
| </div> | |
| <div class="mt-2 bg-gray-400 p-2 text-gray-700 rounded"> | |
| {{ post.body }} | |
| </div> |
This file contains hidden or 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
| import { ref } from "vue"; | |
| export default function usePosts() { | |
| let post = ref({}); | |
| let posts = ref([]); | |
| let user = ref({}); | |
| function fetchPosts() { | |
| fetch(`https://jsonplaceholder.typicode.com/posts`) | |
| .then(response => response.json()) |
This file contains hidden or 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
| import { createRouter, createWebHistory } from "vue-router"; | |
| import Home from "../views/Home.vue"; | |
| import Post from "../components/blog/Post.vue"; | |
| const routes = [ | |
| { | |
| path: "/", | |
| name: "Home", | |
| component: Home | |
| }, | |
| { |
This file contains hidden or 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
| <template> | |
| <div class="bg-gray-500 flex flex-col min-h-screen"> | |
| <Header /><!-- //height 32 --> | |
| <div class="flex-1 flex w-2/3 mx-auto p-4 text-lg bg-white h-full shadow-lg"> | |
| <div class="w-3/5"> | |
| <router-view :key="$route.fullPath" /> | |
| </div> | |
| <div class="w-2/5"> | |
| <LatestPosts /> | |
| </div> |
This file contains hidden or 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
| <template> | |
| <div class="home"> | |
| <BlogRoll /> | |
| </div> | |
| </template> | |
| <script> | |
| import BlogRoll from '@/components/blog/BlogRoll.vue' | |
| export default { | |
| name: "Home", |
This file contains hidden or 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
| <template> | |
| <div class="mx-4 rounded bg-gray-400 shadow"> | |
| <div class="p-2"> | |
| <div class="font-bold">Latest Posts</div> | |
| </div> | |
| <div class="bg-white p-2 border-2 border-gray-400 "> | |
| <div v-for="post in posts" :key="post.id"> | |
| <div class="mb-2">- <router-link :key="`/post/${post.id}`" :to="`/post/${post.id}`">{{ post.title }}</router-link></div> | |
| </div> | |
| </div> |
This file contains hidden or 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
| <template> | |
| <div class="text-4xl font-bold mb-4">My Blog Roll</div> | |
| <div v-for="post in posts" :key="post.id"> | |
| <div class="bg-gray-200 mb-4 shadow p-2 rounded"> | |
| <div class="text-2xl font-semibold"><router-link :to="`/post/${post.id}`">{{ post.title }}</router-link></div> | |
| <div class="mt-2 bg-gray-400 p-2 text-gray-700 rounded">{{ post.body }}</div> | |
| </div> | |
| </div> | |
| </template> |
This file contains hidden or 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
| <template> | |
| <div class="bg-gray-500 flex flex-col min-h-screen"> | |
| <Header /> | |
| <div class="flex-1 flex w-2/3 mx-auto p-4 text-lg bg-white h-full shadow-lg"> | |
| <div class="w-3/5"> | |
| <router-view :key="$route.fullPath" /> | |
| </div> | |
| </div> | |
| </div> | |
| </template> |