make latest page dynamic
Signed-off-by: nurRiyad <asadnurriyad@gmail.com>
This commit is contained in:
@@ -1,25 +1,38 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const props = defineProps({
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
date: String,
|
||||||
|
author: String,
|
||||||
|
path: String,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white mx-5 my-2 p-5 max-w-[530px] rounded-md shadow-lg group">
|
<div class="bg-white mx-5 my-2 p-5 max-w-[530px] rounded-md shadow-lg group">
|
||||||
<nuxt-link to="/" class="group-hover:text-sky-500">
|
<nuxt-link :to="path" class="group-hover:text-sky-500">
|
||||||
<h4 class="text-xl font-medium py-1">This is latest blog card</h4>
|
<h4 class="text-xl font-medium py-1">{{ title }}</h4>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
<div class="text-xs text-slate-500 pb-3 flex space-x-4">
|
<div class="text-xs text-slate-500 pb-3 flex space-x-4">
|
||||||
<div class="flex items-center space-x-1">
|
<div class="flex items-center space-x-1">
|
||||||
<icon name="material-symbols:av-timer" />
|
<icon name="material-symbols:av-timer" />
|
||||||
<span class=""> Create at 10 Dec 2022 </span>
|
<span class=""> Create {{ date }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-1">
|
<div class="flex items-center space-x-1">
|
||||||
<icon name="mdi:face-man" />
|
<icon name="mdi:face-man" />
|
||||||
<nuxt-link class="hover:underline" to="/">by riyad</nuxt-link>
|
<nuxt-link
|
||||||
|
class="hover:underline"
|
||||||
|
target="_blank"
|
||||||
|
to="https://www.nurriyad.xyz/"
|
||||||
|
>by {{ author }}</nuxt-link
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="pb-2 text-slate-600">
|
<p class="pb-2 text-slate-600">
|
||||||
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Tenetur
|
{{ description }}
|
||||||
reprehenderit sit possimus quibusdam ad facilis, consectetur beatae
|
|
||||||
inventore sunt non.
|
|
||||||
</p>
|
</p>
|
||||||
<nuxt-link class="group-hover:text-sky-500" to="/">
|
<nuxt-link :to="path" class="group-hover:text-sky-500">
|
||||||
<p class="font-medium">
|
<p class="font-medium">
|
||||||
Read More
|
Read More
|
||||||
<span class="hidden group-hover:inline"> ->> </span>
|
<span class="hidden group-hover:inline"> ->> </span>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: "Title of the page"
|
title: "Title of the page"
|
||||||
description: "meta description of the page"
|
description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley"
|
||||||
draft: false
|
draft: false
|
||||||
head: true
|
head: true
|
||||||
author: riyad
|
author: riyad
|
||||||
|
|||||||
@@ -2,7 +2,28 @@
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "list",
|
layout: "list",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data } = await useAsyncData("home", () => queryContent("/").find());
|
const { data } = await useAsyncData("home", () => queryContent("/").find());
|
||||||
|
|
||||||
|
const getRecentContent = computed(() => {
|
||||||
|
const allpost = data.value || [];
|
||||||
|
const alltypes = allpost.map((post) => {
|
||||||
|
return {
|
||||||
|
title: post.title,
|
||||||
|
description: post.description,
|
||||||
|
path: post._path,
|
||||||
|
date: post.date as string,
|
||||||
|
author: post.author,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
alltypes.sort(function (a, b) {
|
||||||
|
const c = new Date(a.date);
|
||||||
|
const d = new Date(b.date);
|
||||||
|
return c < d ? 1 : -1;
|
||||||
|
});
|
||||||
|
return alltypes;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -11,7 +32,15 @@ const { data } = await useAsyncData("home", () => queryContent("/").find());
|
|||||||
LATEST CONTENT
|
LATEST CONTENT
|
||||||
</h1>
|
</h1>
|
||||||
<div class="flex justify-between flex-wrap">
|
<div class="flex justify-between flex-wrap">
|
||||||
<latest-blog-card v-for="n in 20" :key="n" />
|
<template v-for="pp in getRecentContent" :key="pp">
|
||||||
|
<latest-blog-card
|
||||||
|
:title="pp.title"
|
||||||
|
:description="pp.description"
|
||||||
|
:date="pp.date"
|
||||||
|
:author="pp.author"
|
||||||
|
:path="pp.path"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user