mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-17 21:53:32 +09:00
ContentParser && Tabs Updated
This commit is contained in:
@@ -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;
|
||||
---
|
||||
|
||||
@@ -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] }),
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user