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": {
|
"dependencies": {
|
||||||
"@astrojs/check": "0.9.4",
|
"@astrojs/check": "0.9.4",
|
||||||
"@astrojs/tailwind": "6.0.0",
|
"@astrojs/tailwind": "^6.0.2",
|
||||||
"astro": "5.3.0",
|
"astro": "^5.13.7",
|
||||||
|
"dewp": "^0.0.6",
|
||||||
"htmx.org": "^1.9.12",
|
"htmx.org": "^1.9.12",
|
||||||
"remark-toc": "^9.0.0",
|
"remark-toc": "^9.0.0",
|
||||||
"tailwindcss": "^3.4.3",
|
"tailwindcss": "^3.4.3",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
import type { CollectionEntry } from "astro:content";
|
import { render, getCollection, type CollectionEntry } from "astro:content";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: CollectionEntry<"blog">;
|
post: CollectionEntry<"blog">;
|
||||||
|
@ -8,6 +8,14 @@ interface Props {
|
||||||
|
|
||||||
const { post, componentType } = Astro.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
|
// default options for the post component
|
||||||
const deafultOptions = {
|
const deafultOptions = {
|
||||||
showTags: false,
|
showTags: false,
|
||||||
|
@ -50,13 +58,12 @@ const postDateFormatted = post.data.date.toLocaleDateString("tr-TR", {
|
||||||
const postLink = `/${post.data.category}/${post.slug}`;
|
const postLink = `/${post.data.category}/${post.slug}`;
|
||||||
|
|
||||||
// Create post content as an astro component
|
// Create post content as an astro component
|
||||||
const { Content } = await post.render();
|
const { Content } = await render(post);
|
||||||
|
|
||||||
const copyPost = post;
|
|
||||||
|
|
||||||
import { Image } from "astro:assets";
|
import { Image } from "astro:assets";
|
||||||
import questionMark from "@/images/questionMark.svg";
|
import questionMark from "@/images/questionMark.svg";
|
||||||
import calendar from "@/images/calendar.svg";
|
import calendar from "@/images/calendar.svg";
|
||||||
|
import { getEntry } from "astro:content";
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -72,9 +79,9 @@ import calendar from "@/images/calendar.svg";
|
||||||
|
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<div class="flex flex-col gap-2">
|
<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}>
|
<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>
|
</a>
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
{
|
{
|
||||||
|
@ -100,7 +107,7 @@ import calendar from "@/images/calendar.svg";
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
(options.shortSummary || options.longSummary) && (
|
(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 { z, defineCollection } from "astro:content";
|
||||||
|
import { wpCollections } from "dewp/loaders";
|
||||||
|
|
||||||
export const CATEGORIES = ["fikir", "teknik", "edebiyat", "ansiklopedi"];
|
export const CATEGORIES = ["fikir", "teknik", "edebiyat", "ansiklopedi"];
|
||||||
|
|
||||||
|
@ -35,4 +36,5 @@ const bookReviewCollection = defineCollection({
|
||||||
export const collections = {
|
export const collections = {
|
||||||
blog: blogCollection,
|
blog: blogCollection,
|
||||||
bookReview: bookReviewCollection,
|
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 { getCollection } from "astro:content";
|
||||||
import Post from "@/components/Post.astro";
|
import Post from "@/components/Post.astro";
|
||||||
import BookReview from "@/components/BookReview.astro";
|
import BookReview from "@/components/BookReview.astro";
|
||||||
|
import { Picture } from "astro:assets";
|
||||||
|
|
||||||
const allTeknikPosts = await getCollection("blog");
|
const allTeknikPosts = await getCollection("blog");
|
||||||
const allReviews = await getCollection("bookReview");
|
const allReviews = await getCollection("bookReview");
|
||||||
|
const allWpPosts = await getCollection("posts");
|
||||||
|
|
||||||
const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
||||||
(post) => !post.data.draft
|
(post) => !post.data.draft
|
||||||
|
@ -19,16 +21,9 @@ const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
||||||
<Header />
|
<Header />
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
{
|
{
|
||||||
allPosts
|
allWpPosts
|
||||||
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
||||||
.map((p) => {
|
.map((p) => <Post post={p} componentType="short" />
|
||||||
if (p.collection == "blog") {
|
|
||||||
return <Post post={p} componentType="short" />;
|
|
||||||
} else {
|
|
||||||
p.collection == "bookReview";
|
|
||||||
return <BookReview post={p} componentType="short" />;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<a class="text-inherit" href="/posts/1">Tüm Yayınlar</a>
|
<a class="text-inherit" href="/posts/1">Tüm Yayınlar</a>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user