ContentParser && Tabs Updated

This commit is contained in:
Al Murad Uzzaman
2025-04-29 11:13:55 +06:00
parent 423ad81a1c
commit 68c865c652
5 changed files with 32 additions and 17 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import config from "@/config/config.json";
const {
theme_switcher,
default_theme,
// default_theme,
}: { theme_switcher: boolean; default_theme: string } = config.settings;
const { className }: { className?: string } = Astro.props;
---
+2 -2
View File
@@ -16,8 +16,8 @@ const Tabs = ({ children }: { children: React.ReactElement }) => {
}, [active]);
const tabLinks = Array.from(
children.props.value.matchAll(
/<div\s+data-name="([^"]+)"[^>]*>(.*?)<\/div>/gs,
(children.props as any).value.matchAll(
/<div\s+data-name="([^"]+)"[^>]*>((?:.|\n)*?)<\/div>/g,
),
(match: RegExpMatchArray) => ({ name: match[1], children: match[0] }),
);
+15 -1
View File
@@ -5,12 +5,26 @@ import {
type CollectionKey,
} from "astro:content";
type PageData = {
title: string;
meta_title?: string;
description?: string;
image?: string;
draft?: boolean;
};
export const getSinglePage = async <C extends CollectionKey>(
collectionName: C
): Promise<CollectionEntry<C>[]> => {
const allPages = await getCollection(collectionName);
const removeIndex = allPages.filter((data) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data) => !data.data.draft);
const removeDrafts = removeIndex.filter((data) => {
const pageData = data.data as PageData;
return pageData.draft !== true;
});
return removeDrafts;
};
---