mirror of
https://github.com/StepanovPlaton/AboutMe.git
synced 2026-04-04 04:40:51 +04:00
New page
This commit is contained in:
@@ -7,7 +7,10 @@ import { LinkPresets } from "@constants/link-presets";
|
||||
import { url } from "@utils/url";
|
||||
import GridLayout from "@layouts/grid.astro";
|
||||
import { siteConfig } from "@/config";
|
||||
|
||||
import PostPage from "@components/postPage.astro";
|
||||
import { PAGE_SIZE } from "@constants/constants";
|
||||
import { getSortedPosts } from "@utils/content";
|
||||
import Pagination from "@components/pagination.astro";
|
||||
|
||||
// Получаем все ссылки из navbar, включая основные и с подразделами
|
||||
const allLinks: NavbarLink[] = [];
|
||||
@@ -25,23 +28,34 @@ navbarConfig.links.forEach(link => {
|
||||
}
|
||||
});
|
||||
|
||||
// Добавляем ссылку на новости/ленту постов
|
||||
const newsLink: NavbarLink = {
|
||||
name: "Новости",
|
||||
url: "/news/",
|
||||
icon: "material-symbols:article",
|
||||
description: "Лента постов и статей",
|
||||
};
|
||||
|
||||
// Вставляем ссылку на новости в начало списка
|
||||
allLinks.unshift(newsLink);
|
||||
|
||||
const pageTitle = siteConfig.title;
|
||||
const pageDescription = siteConfig.subtitle || "";
|
||||
|
||||
const allBlogPosts = await getSortedPosts();
|
||||
const firstPagePosts = allBlogPosts.slice(0, PAGE_SIZE);
|
||||
const totalPages = Math.ceil(allBlogPosts.length / PAGE_SIZE);
|
||||
|
||||
const page = {
|
||||
currentPage: 1,
|
||||
lastPage: totalPages,
|
||||
size: PAGE_SIZE,
|
||||
total: allBlogPosts.length,
|
||||
data: firstPagePosts.map((post, index) => ({
|
||||
...post,
|
||||
index: index + 1,
|
||||
})),
|
||||
url: {
|
||||
current: "/",
|
||||
prev: undefined,
|
||||
next: totalPages > 1 ? url("/news/2/") : undefined,
|
||||
},
|
||||
};
|
||||
const len = page.data.length;
|
||||
|
||||
---
|
||||
|
||||
<GridLayout title={pageTitle} description={pageDescription}>
|
||||
<div class="flex w-full rounded-(--radius-large) overflow-hidden relative min-h-32">
|
||||
<div class="flex w-full rounded-(--radius-large) overflow-hidden relative min-h-32 mb-3">
|
||||
<div class="card-base z-10 px-9 py-6 relative w-full">
|
||||
<!-- Заголовок -->
|
||||
<header class="mb-8">
|
||||
@@ -84,6 +98,10 @@ const pageDescription = siteConfig.subtitle || "";
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<PostPage page={page}></PostPage>
|
||||
{totalPages > 1 && (
|
||||
<Pagination class="mx-auto onload-animation-up" page={page} style={`animation-delay: ${(len)*50}ms`} basePath="/news"></Pagination>
|
||||
)}
|
||||
</GridLayout>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -27,10 +27,12 @@ const stats = getProjectStats();
|
||||
const featuredProjects = getFeaturedProjects();
|
||||
const allTechStack = getAllTechStack();
|
||||
|
||||
// 获取所有分类
|
||||
const categories = [
|
||||
...new Set(projectsData.map((project) => project.category)),
|
||||
];
|
||||
// 定义分类顺序
|
||||
const categoryOrder = ["actual", "history", "other"];
|
||||
|
||||
// 获取所有分类并按指定顺序排序
|
||||
const allCategories = [...new Set(projectsData.map((project) => project.category))];
|
||||
const categories = categoryOrder.filter(cat => allCategories.includes(cat));
|
||||
|
||||
// 按分类获取项目
|
||||
const projectsByCategory = categories.reduce(
|
||||
|
||||
35
src/pages/worth-mentioning.astro
Normal file
35
src/pages/worth-mentioning.astro
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
|
||||
|
||||
import { getEntry, render } from "astro:content";
|
||||
|
||||
import { LinkPresets } from "@constants/link-presets";
|
||||
import { LinkPreset } from "@/types/config";
|
||||
import Markdown from "@components/common/markdown.astro";
|
||||
import GridLayout from "@layouts/grid.astro";
|
||||
import BackwardButton from "@components/backwardButton.astro";
|
||||
|
||||
|
||||
const pageTitle = LinkPresets[LinkPreset.WorthMentioning].name;
|
||||
const pageDescription = LinkPresets[LinkPreset.WorthMentioning].description;
|
||||
|
||||
const worthMentioningPost = await getEntry("spec", "worth-mentioning");
|
||||
|
||||
if (!worthMentioningPost) {
|
||||
throw new Error("Worth mentioning page content not found");
|
||||
}
|
||||
|
||||
const { Content } = await render(worthMentioningPost);
|
||||
---
|
||||
|
||||
<GridLayout title={pageTitle} description={pageDescription}>
|
||||
<div class="flex w-full rounded-(--radius-large) overflow-hidden relative min-h-32">
|
||||
<div class="card-base z-10 px-9 py-6 relative w-full ">
|
||||
<BackwardButton currentPath={Astro.url.pathname} />
|
||||
<Markdown class="mt-2">
|
||||
<Content />
|
||||
</Markdown>
|
||||
</div>
|
||||
</div>
|
||||
</GridLayout>
|
||||
Reference in New Issue
Block a user