feat(docs): add technical features documentation and apply consistent formatting
Added a detailed technical features section to the documentation, covering key functionalities of Memegoat. Improved consistency in formatting across documentation and source files.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import { use, useEffect, useId, useState } from 'react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { use, useEffect, useId, useState } from "react";
|
||||
import { useTheme } from "next-themes";
|
||||
|
||||
export function Mermaid({ chart }: { chart: string }) {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
@@ -16,7 +16,10 @@ export function Mermaid({ chart }: { chart: string }) {
|
||||
|
||||
const cache = new Map<string, Promise<unknown>>();
|
||||
|
||||
function cachePromise<T>(key: string, setPromise: () => Promise<T>): Promise<T> {
|
||||
function cachePromise<T>(
|
||||
key: string,
|
||||
setPromise: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
const cached = cache.get(key);
|
||||
if (cached) return cached as Promise<T>;
|
||||
|
||||
@@ -28,19 +31,21 @@ function cachePromise<T>(key: string, setPromise: () => Promise<T>): Promise<T>
|
||||
function MermaidContent({ chart }: { chart: string }) {
|
||||
const id = useId();
|
||||
const { resolvedTheme } = useTheme();
|
||||
const { default: mermaid } = use(cachePromise('mermaid', () => import('mermaid')));
|
||||
const { default: mermaid } = use(
|
||||
cachePromise("mermaid", () => import("mermaid")),
|
||||
);
|
||||
|
||||
mermaid.initialize({
|
||||
startOnLoad: false,
|
||||
securityLevel: 'loose',
|
||||
fontFamily: 'inherit',
|
||||
themeCSS: 'margin: 1.5rem auto 0;',
|
||||
theme: resolvedTheme === 'dark' ? 'dark' : 'default',
|
||||
securityLevel: "loose",
|
||||
fontFamily: "inherit",
|
||||
themeCSS: "margin: 1.5rem auto 0;",
|
||||
theme: resolvedTheme === "dark" ? "dark" : "default",
|
||||
});
|
||||
|
||||
const { svg, bindFunctions } = use(
|
||||
cachePromise(`${chart}-${resolvedTheme}`, () => {
|
||||
return mermaid.render(id, chart.replaceAll('\\n', '\n'));
|
||||
return mermaid.render(id, chart.replaceAll("\\n", "\n"));
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -53,4 +58,4 @@ function MermaidContent({ chart }: { chart: string }) {
|
||||
dangerouslySetInnerHTML={{ __html: svg }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user