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";
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<"blog">;
|
||||
post: CollectionEntry<"posts">;
|
||||
componentType: "short" | "long" | "full";
|
||||
}
|
||||
|
||||
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);
|
||||
const parentCategory = categoryTitles.find((c) => !Boolean(c?.data.parent?.id));
|
||||
|
||||
// default options for the post component
|
||||
const deafultOptions = {
|
||||
|
@ -55,7 +53,7 @@ const postDateFormatted = post.data.date.toLocaleDateString("tr-TR", {
|
|||
});
|
||||
|
||||
// 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
|
||||
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 Header from "@/components/Header.astro";
|
||||
|
@ -8,7 +8,6 @@ import Post from "@/components/Post.astro";
|
|||
import EmojiReactionForm from "@/components/EmojiReactionForm.astro";
|
||||
import CommentForm from "@/components/CommentForm.astro";
|
||||
import HorizontalLine from "@/components/HorizontalLine.astro";
|
||||
import BookReview from "@/components/BookReview.astro";
|
||||
|
||||
const { entry } = Astro.props;
|
||||
|
||||
|
@ -17,33 +16,37 @@ const URL = Astro.url;
|
|||
const backendHost = import.meta.env.PUBLIC_BACKEND_HOST;
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection("blog");
|
||||
const allReviews = await getCollection("bookReview");
|
||||
const posts = await getCollection("posts");
|
||||
|
||||
const allPosts = [...allReviews, ...blogEntries].filter(
|
||||
(post) => !post.data.draft
|
||||
return await Promise.all(
|
||||
posts.map(async (entry) => {
|
||||
const categoryTitles = await Promise.all(
|
||||
entry.data.categories.map(
|
||||
async (c) => await getEntry("categories", c.id)
|
||||
)
|
||||
);
|
||||
|
||||
const parentCategory = categoryTitles.find(
|
||||
(c) => !Boolean(c?.data.parent?.id)
|
||||
);
|
||||
|
||||
return {
|
||||
params: { category: parentCategory?.data.slug, slug: entry.data.slug },
|
||||
props: { entry },
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return allPosts.map((entry) => ({
|
||||
params: { category: entry.data.category, slug: entry.slug },
|
||||
props: { entry },
|
||||
}));
|
||||
}
|
||||
---
|
||||
|
||||
<Layout
|
||||
title="log101"
|
||||
ogTitle={entry.data.title}
|
||||
ogDescription={entry.data.summary}
|
||||
ogTitle={entry.data.title.rendered}
|
||||
ogDescription={entry.data.excerpt.rendered}
|
||||
ogURL={URL.toString()}>
|
||||
<Header />
|
||||
{
|
||||
entry.collection === "blog" ? (
|
||||
<Post post={entry} componentType="full" />
|
||||
) : (
|
||||
<BookReview post={entry} componentType="full" />
|
||||
)
|
||||
}
|
||||
<Post post={entry} componentType="full" />
|
||||
|
||||
<EmojiReactionForm entryId={entry.id} />
|
||||
|
||||
<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 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
|
||||
);
|
||||
const posts = await getCollection("posts");
|
||||
---
|
||||
|
||||
<Layout title="log101">
|
||||
<Header />
|
||||
<div class="posts">
|
||||
{
|
||||
allWpPosts
|
||||
posts
|
||||
.sort((p1, p2) => p2.data.date.getTime() - p1.data.date.getTime())
|
||||
.map((p) => <Post post={p} componentType="short" />)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user