docu v 1.11.0
This commit is contained in:
@@ -12,18 +12,20 @@ import matter from "gray-matter";
|
||||
|
||||
// custom components imports
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import Pre from "@/components/markdown/pre";
|
||||
import Note from "@/components/markdown/note";
|
||||
import { Stepper, StepperItem } from "@/components/markdown/stepper";
|
||||
import Image from "@/components/markdown/image";
|
||||
import Link from "@/components/markdown/link";
|
||||
import Outlet from "@/components/markdown/outlet";
|
||||
import Youtube from "@/components/markdown/youtube";
|
||||
import Tooltip from "@/components/markdown/tooltips";
|
||||
import Card from "@/components/markdown/card";
|
||||
import Button from "@/components/markdown/button";
|
||||
import Accordion from "@/components/markdown/accordion";
|
||||
import CardGroup from "@/components/markdown/cardgroup";
|
||||
import Pre from "@/components/markdown/PreMdx";
|
||||
import Note from "@/components/markdown/NoteMdx";
|
||||
import { Stepper, StepperItem } from "@/components/markdown/StepperMdx";
|
||||
import Image from "@/components/markdown/ImageMdx";
|
||||
import Link from "@/components/markdown/LinkMdx";
|
||||
import Outlet from "@/components/markdown/OutletMdx";
|
||||
import Youtube from "@/components/markdown/YoutubeMdx";
|
||||
import Tooltip from "@/components/markdown/TooltipsMdx";
|
||||
import Card from "@/components/markdown/CardMdx";
|
||||
import Button from "@/components/markdown/ButtonMdx";
|
||||
import Accordion from "@/components/markdown/AccordionMdx";
|
||||
import CardGroup from "@/components/markdown/CardGroupMdx";
|
||||
import Kbd from "@/components/markdown/KeyboardMdx";
|
||||
import { Release, Changes } from "@/components/markdown/ReleaseMdx";
|
||||
|
||||
// add custom components
|
||||
const components = {
|
||||
@@ -44,6 +46,9 @@ const components = {
|
||||
Button,
|
||||
Accordion,
|
||||
CardGroup,
|
||||
Kbd,
|
||||
Release,
|
||||
Changes,
|
||||
};
|
||||
|
||||
// can be used for other pages like blogs, Guides etc
|
||||
@@ -177,13 +182,15 @@ const postProcess = () => (tree: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
export type Author = {
|
||||
avatar?: string;
|
||||
handle: string;
|
||||
username: string;
|
||||
handleUrl: string;
|
||||
};
|
||||
// export type Author = {
|
||||
// avatar?: string;
|
||||
// handle: string;
|
||||
// username: string;
|
||||
// handleUrl: string;
|
||||
// };
|
||||
|
||||
// Blog related types and functions have been removed
|
||||
/*
|
||||
export type BlogMdxFrontmatter = BaseMdxFrontmatter & {
|
||||
date: string;
|
||||
authors: Author[];
|
||||
@@ -197,20 +204,26 @@ export async function getAllBlogStaticPaths() {
|
||||
return res.map((file) => file.split(".")[0]);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllBlogs() {
|
||||
const blogFolder = path.join(process.cwd(), "/contents/blogs/");
|
||||
const files = await fs.readdir(blogFolder);
|
||||
const uncheckedRes = await Promise.all(
|
||||
files.map(async (file) => {
|
||||
if (!file.endsWith(".mdx")) return undefined;
|
||||
const filepath = path.join(process.cwd(), `/contents/blogs/${file}`);
|
||||
const rawMdx = await fs.readFile(filepath, "utf-8");
|
||||
return {
|
||||
...justGetFrontmatterFromMD<BlogMdxFrontmatter>(rawMdx),
|
||||
slug: file.split(".")[0],
|
||||
};
|
||||
try {
|
||||
const filepath = path.join(process.cwd(), `/contents/blogs/${file}`);
|
||||
const rawMdx = await fs.readFile(filepath, "utf-8");
|
||||
return {
|
||||
...justGetFrontmatterFromMD<BlogMdxFrontmatter>(rawMdx),
|
||||
slug: file.split(".")[0],
|
||||
};
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
);
|
||||
return uncheckedRes.filter((it) => !!it) as (BlogMdxFrontmatter & {
|
||||
@@ -219,11 +232,13 @@ export async function getAllBlogs() {
|
||||
}
|
||||
|
||||
export async function getBlogForSlug(slug: string) {
|
||||
const blogFile = path.join(process.cwd(), "/contents/blogs/", `${slug}.mdx`);
|
||||
try {
|
||||
const blogFile = path.join(process.cwd(), "/contents/blogs/", `${slug}.mdx`);
|
||||
const rawMdx = await fs.readFile(blogFile, "utf-8");
|
||||
return await parseMdx<BlogMdxFrontmatter>(rawMdx);
|
||||
} catch {
|
||||
return undefined;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
9
lib/toc.ts
Normal file
9
lib/toc.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface TocItem {
|
||||
level: number;
|
||||
text: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export interface MobTocProps {
|
||||
tocs: TocItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user