fix: gönderi bağlantılarının açılabilir hale getir
This commit is contained in:
parent
8ab7fa45b5
commit
504788e991
|
@ -2,19 +2,17 @@
|
||||||
import { render, getCollection, type CollectionEntry } from "astro:content";
|
import { render, getCollection, type CollectionEntry } from "astro:content";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: CollectionEntry<"blog">;
|
post: CollectionEntry<"posts">;
|
||||||
componentType: "short" | "long" | "full";
|
componentType: "short" | "long" | "full";
|
||||||
}
|
}
|
||||||
|
|
||||||
const { post, componentType } = Astro.props;
|
const { post, componentType } = Astro.props;
|
||||||
|
|
||||||
const categories = await getCollection("categories");
|
|
||||||
|
|
||||||
const categoryTitles = await Promise.all(
|
const categoryTitles = await Promise.all(
|
||||||
post.data.categories.map(async (c) => await getEntry("categories", c.id))
|
post.data.categories.map(async (c) => await getEntry("categories", c.id))
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(categoryTitles);
|
const parentCategory = categoryTitles.find((c) => !Boolean(c?.data.parent?.id));
|
||||||
|
|
||||||
// default options for the post component
|
// default options for the post component
|
||||||
const deafultOptions = {
|
const deafultOptions = {
|
||||||
|
@ -55,7 +53,7 @@ const postDateFormatted = post.data.date.toLocaleDateString("tr-TR", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create post link
|
// Create post link
|
||||||
const postLink = `/${post.data.category}/${post.slug}`;
|
const postLink = `/${parentCategory?.data.slug}/${post.data.slug}`;
|
||||||
|
|
||||||
// Create post content as an astro component
|
// Create post content as an astro component
|
||||||
const { Content } = await render(post);
|
const { Content } = await render(post);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection, getEntry } from "astro:content";
|
||||||
|
|
||||||
import Footer from "@/components/Footer.astro";
|
import Footer from "@/components/Footer.astro";
|
||||||
import Header from "@/components/Header.astro";
|
import Header from "@/components/Header.astro";
|
||||||
|
@ -8,7 +8,6 @@ import Post from "@/components/Post.astro";
|
||||||
import EmojiReactionForm from "@/components/EmojiReactionForm.astro";
|
import EmojiReactionForm from "@/components/EmojiReactionForm.astro";
|
||||||
import CommentForm from "@/components/CommentForm.astro";
|
import CommentForm from "@/components/CommentForm.astro";
|
||||||
import HorizontalLine from "@/components/HorizontalLine.astro";
|
import HorizontalLine from "@/components/HorizontalLine.astro";
|
||||||
import BookReview from "@/components/BookReview.astro";
|
|
||||||
|
|
||||||
const { entry } = Astro.props;
|
const { entry } = Astro.props;
|
||||||
|
|
||||||
|
@ -17,33 +16,37 @@ const URL = Astro.url;
|
||||||
const backendHost = import.meta.env.PUBLIC_BACKEND_HOST;
|
const backendHost = import.meta.env.PUBLIC_BACKEND_HOST;
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const blogEntries = await getCollection("blog");
|
const posts = await getCollection("posts");
|
||||||
const allReviews = await getCollection("bookReview");
|
|
||||||
|
|
||||||
const allPosts = [...allReviews, ...blogEntries].filter(
|
return await Promise.all(
|
||||||
(post) => !post.data.draft
|
posts.map(async (entry) => {
|
||||||
|
const categoryTitles = await Promise.all(
|
||||||
|
entry.data.categories.map(
|
||||||
|
async (c) => await getEntry("categories", c.id)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return allPosts.map((entry) => ({
|
const parentCategory = categoryTitles.find(
|
||||||
params: { category: entry.data.category, slug: entry.slug },
|
(c) => !Boolean(c?.data.parent?.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
params: { category: parentCategory?.data.slug, slug: entry.data.slug },
|
||||||
props: { entry },
|
props: { entry },
|
||||||
}));
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
title="log101"
|
title="log101"
|
||||||
ogTitle={entry.data.title}
|
ogTitle={entry.data.title.rendered}
|
||||||
ogDescription={entry.data.summary}
|
ogDescription={entry.data.excerpt.rendered}
|
||||||
ogURL={URL.toString()}>
|
ogURL={URL.toString()}>
|
||||||
<Header />
|
<Header />
|
||||||
{
|
|
||||||
entry.collection === "blog" ? (
|
|
||||||
<Post post={entry} componentType="full" />
|
<Post post={entry} componentType="full" />
|
||||||
) : (
|
|
||||||
<BookReview post={entry} componentType="full" />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
<EmojiReactionForm entryId={entry.id} />
|
<EmojiReactionForm entryId={entry.id} />
|
||||||
|
|
||||||
<section class="comments">
|
<section class="comments">
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<meta name="robots" content="noindex" />
|
|
||||||
<link href="/admin/config.yml" type="text/yaml" rel="cms-config-url" />
|
|
||||||
<title>Content Manager</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<!-- Include the script that builds the page and powers Decap CMS -->
|
|
||||||
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -5,23 +5,15 @@ 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 { Picture } from "astro:assets";
|
|
||||||
|
|
||||||
const allTeknikPosts = await getCollection("blog");
|
const posts = await getCollection("posts");
|
||||||
const allReviews = await getCollection("bookReview");
|
|
||||||
const allWpPosts = await getCollection("posts");
|
|
||||||
|
|
||||||
const allPosts = [...allReviews, ...allTeknikPosts].filter(
|
|
||||||
(post) => !post.data.draft
|
|
||||||
);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="log101">
|
<Layout title="log101">
|
||||||
<Header />
|
<Header />
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
{
|
{
|
||||||
allWpPosts
|
posts
|
||||||
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
||||||
.map((p) => <Post post={p} componentType="short" />)
|
.map((p) => <Post post={p} componentType="short" />)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user