mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:49:45 +00:00
связывание записей при помощи titel
This commit is contained in:
1 parent
61e0006911
commit
35909dce1f
3 files changed
+46
-23
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import { HashLink } from "react-router-hash-link";
|
||||
|
||||
function Test() {
|
||||
return <>ddddddddddddd</>;
|
||||
}
|
||||
export default Test;
|
||||
|
||||
@@ -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 && (
|
||||
<PageHeader className="header">
|
||||
<h1>{post.title}</h1>
|
||||
</PageHeader>
|
||||
<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 key={index} images={el.value} customPerSlide={4} />;
|
||||
}
|
||||
return <div key={index}>{el.element}</div>;
|
||||
})}
|
||||
{children}
|
||||
</PageContent>
|
||||
</>
|
||||
)}
|
||||
|
||||
<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 <div key={index}>{el.element}</div>;
|
||||
})}
|
||||
{children}
|
||||
</PageContent>
|
||||
|
||||
{isLabBoardPost && <LabBoard />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
Reference in new issue
Block a user