связывание записей при помощи titel

This commit is contained in:
xomimishka committed 2025-05-23 14:03:48 +03:00
1 parent 61e0006911
commit 35909dce1f
3 files changed
+33 -10

No files matched your search

@@ -0,0 +1,7 @@
import { HashLink } from "react-router-hash-link";
function Test() {
return <>ddddddddddddd</>;
}
export default Test;
+13 -10
View File
@@ -7,7 +7,7 @@ import { App } from "@/shared/types/app";
import "./Projects.scss";
import Slider from "../Slider/Slider";
import LabBoard from "@/pages/CustomProjects/LabBoard/LabBoard";
import { getCustomProject } from "./customProjects";
interface WpPostProps {
post: App.WpPostPage;
@@ -18,32 +18,35 @@ export default function WpPost({
post,
children,
}: WpPostProps) {
useResizeObserver({ parentSelector: '.wp-block-pullquote', childSelector: 'blockquote' });
useResizeObserver({ parentSelector: ".wp-block-pullquote", childSelector: "blockquote" });
const isLabBoardPost = post.title === "LabBoard 1.1";
const categories = post.categories ?? [];
const title = post.title;
const customComponent = getCustomProject(title);
return (
<div className={post.categories?.includes('projects') ? "project" : ""}>
{!isLabBoardPost && (
<div className={categories.includes("projects") ? "project" : ""}>
{customComponent ? (
customComponent
) : (
<>
<PageHeader className="header">
<h1>{post.title}</h1>
</PageHeader>
)}
<PageContent className="content">
{Array.isArray(post.content) &&
post.content.map((el, index) => {
if (el.type === "mediablock") {
return <MediaBlock key={index} images={el.value} />;
} else if (el.type === "slider") {
return <Slider images={el.value} customPerSlide={4} />
return <Slider key={index} images={el.value} customPerSlide={4} />;
}
return <div key={index}>{el.element}</div>;
})}
{children}
</PageContent>
{isLabBoardPost && <LabBoard />}
</>
)}
</div>
);
}
+13
View File
@@ -0,0 +1,13 @@
import LabBoard from "@/pages/CustomProjects/LabBoard/LabBoard";
import Test from "@/pages/CustomProjects/LabBoard/test";
import { ReactNode } from "react";
const customProjects: Record<string, ReactNode> = {
labboard: <LabBoard />,
tests: <Test />,
};
export const getCustomProject = (title: string): ReactNode | null => {
const normalizedKey = title.toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9]/g, "");
return customProjects[normalizedKey] || null;
};