feat: Wp koleksiyonlarını ekle
This commit is contained in:
parent
42fcfde81d
commit
1732030bf0
6525
package-lock.json
generated
Normal file
6525
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -11,8 +11,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@astrojs/check": "0.9.4",
|
||||
"@astrojs/tailwind": "6.0.0",
|
||||
"astro": "5.3.0",
|
||||
"@astrojs/tailwind": "^6.0.2",
|
||||
"astro": "^5.13.7",
|
||||
"dewp": "^0.0.6",
|
||||
"htmx.org": "^1.9.12",
|
||||
"remark-toc": "^9.0.0",
|
||||
"tailwindcss": "^3.4.3",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import { render, getCollection, type CollectionEntry } from "astro:content";
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<"blog">;
|
||||
|
@ -8,6 +8,14 @@ interface Props {
|
|||
|
||||
const { post, componentType } = Astro.props;
|
||||
|
||||
const categories = await getCollection("categories");
|
||||
|
||||
const categoryTitles = await Promise.all(
|
||||
post.data.categories.map(async (c) => await getEntry("categories", c.id))
|
||||
);
|
||||
|
||||
console.log(categoryTitles);
|
||||
|
||||
// default options for the post component
|
||||
const deafultOptions = {
|
||||
showTags: false,
|
||||
|
@ -50,13 +58,12 @@ const postDateFormatted = post.data.date.toLocaleDateString("tr-TR", {
|
|||
const postLink = `/${post.data.category}/${post.slug}`;
|
||||
|
||||
// Create post content as an astro component
|
||||
const { Content } = await post.render();
|
||||
|
||||
const copyPost = post;
|
||||
const { Content } = await render(post);
|
||||
|
||||
import { Image } from "astro:assets";
|
||||
import questionMark from "@/images/questionMark.svg";
|
||||
import calendar from "@/images/calendar.svg";
|
||||
import { getEntry } from "astro:content";
|
||||
---
|
||||
|
||||
<style>
|
||||
|
@ -72,9 +79,9 @@ import calendar from "@/images/calendar.svg";
|
|||
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="tracking-wide text-slate-700">{post.data.subcategory}</p>
|
||||
<p class="tracking-wide text-slate-700">{categoryTitles[0]?.data.name}</p>
|
||||
<a class="no-underline text-inherit" href={postLink}>
|
||||
<h4 class="text-3xl font-normal">{post.data.title}</h4>
|
||||
<h4 class="text-3xl font-normal">{post.data.title.rendered}</h4>
|
||||
</a>
|
||||
<div class="flex flex-row gap-2">
|
||||
{
|
||||
|
@ -100,7 +107,7 @@ import calendar from "@/images/calendar.svg";
|
|||
</div>
|
||||
{
|
||||
(options.shortSummary || options.longSummary) && (
|
||||
<p class="post-summary">{post.data.summary}</p>
|
||||
<p class="post-summary" set:html={post.data.excerpt.rendered} />
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { z, defineCollection } from "astro:content";
|
||||
import { wpCollections } from "dewp/loaders";
|
||||
|
||||
export const CATEGORIES = ["fikir", "teknik", "edebiyat", "ansiklopedi"];
|
||||
|
||||
|
@ -35,4 +36,5 @@ const bookReviewCollection = defineCollection({
|
|||
export const collections = {
|
||||
blog: blogCollection,
|
||||
bookReview: bookReviewCollection,
|
||||
...wpCollections({ endpoint: "https://wp.log101.dev/wp-json/" }),
|
||||
};
|
||||
|
|
|
@ -6,9 +6,11 @@ import Layout from "@/layouts/Layout.astro";
|
|||
import { getCollection } from "astro:content";
|
||||
import Post from "@/components/Post.astro";
|
||||
import BookReview from "@/components/BookReview.astro";
|
||||
import { Picture } from "astro:assets";
|
||||
|
||||
const allTeknikPosts = await getCollection("blog");
|
||||
const allReviews = await getCollection("bookReview");
|
||||
const allWpPosts = await getCollection("posts");
|
||||
|
||||
const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
||||
(post) => !post.data.draft
|
||||
|
@ -19,16 +21,9 @@ const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
|||
<Header />
|
||||
<div class="posts">
|
||||
{
|
||||
allPosts
|
||||
allWpPosts
|
||||
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
||||
.map((p) => {
|
||||
if (p.collection == "blog") {
|
||||
return <Post post={p} componentType="short" />;
|
||||
} else {
|
||||
p.collection == "bookReview";
|
||||
return <BookReview post={p} componentType="short" />;
|
||||
}
|
||||
})
|
||||
.map((p) => <Post post={p} componentType="short" />
|
||||
}
|
||||
</div>
|
||||
<a class="text-inherit" href="/posts/1">Tüm Yayınlar</a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user