-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
- Loading branch information
Showing
30 changed files
with
633 additions
and
932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/styles/globals.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
autoprefixer: {}, | ||
}, | ||
}; |
9 changes: 9 additions & 0 deletions
9
examples/mathjax-render-react-example/src/app/api/hello/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { NextResponse } from "next/server"; | ||
|
||
export function GET() { | ||
const data = { | ||
msg: "hello", | ||
}; | ||
|
||
return NextResponse.json(data); | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/mathjax-render-react-example/src/app/api/tex/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NextRequest } from "next/server"; | ||
|
||
import { Tex2SVG } from "mathjax-render"; | ||
|
||
export function GET(req: NextRequest) { | ||
const { searchParams } = new URL(req.url); | ||
const tex = searchParams.get("tex") ?? ""; | ||
const svg = Tex2SVG(tex, true); | ||
|
||
return new Response(svg, { | ||
status: 200, | ||
headers: { "Content-Type": "image/svg+xml" }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from "react"; | ||
|
||
import { Analytics } from "@vercel/analytics/react"; | ||
|
||
import { ThemeProvider } from "@/components/theme-provider"; | ||
|
||
import NextTopLoader from "nextjs-toploader"; | ||
|
||
import "@/styles/globals.css"; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<> | ||
<html lang="en" suppressHydrationWarning> | ||
<head /> | ||
<body> | ||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem> | ||
<NextTopLoader /> | ||
{children} | ||
<Analytics /> | ||
</ThemeProvider> | ||
</body> | ||
</html> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import React, { ChangeEventHandler, useState, useCallback } from "react"; | ||
|
||
import { Textarea } from "@/components/ui/textarea"; | ||
import { Container } from "@components/Container"; | ||
import { MathJaxNode } from "@/components/mathjaxNode"; | ||
|
||
export default function Page() { | ||
const [texValue, setTexValue] = useState(""); | ||
|
||
const handleTextareaChange: ChangeEventHandler<HTMLTextAreaElement> = | ||
useCallback((event) => { | ||
setTexValue(event.target.value); | ||
}, []); | ||
|
||
return ( | ||
<Container> | ||
<div className="flex flex-1 flex-col justify-center items-center gap-y-8"> | ||
<Textarea | ||
className="w-1/2" | ||
rows={8} | ||
cols={8} | ||
value={texValue} | ||
onChange={handleTextareaChange} | ||
/> | ||
<MathJaxNode tex={texValue} display={true}></MathJaxNode> | ||
</div> | ||
</Container> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/mathjax-render-react-example/src/app/reference/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Container } from "@/components/Container"; | ||
import { MathJaxNode } from "@/components/mathjaxNode"; | ||
|
||
import { getTexList } from "@/lib/texList"; | ||
|
||
export default function Page() { | ||
const texList = getTexList(); | ||
|
||
return ( | ||
<Container> | ||
<div className="flex flex-1 flex-col justify-center items-center"> | ||
{texList.map((tex, index) => ( | ||
<div key={index}> | ||
<MathJaxNode tex={tex} display={true}></MathJaxNode> | ||
</div> | ||
))} | ||
</div> | ||
</Container> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
examples/mathjax-render-react-example/src/components/MobileMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
examples/mathjax-render-react-example/src/components/mathjaxNode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import dynamic from "next/dynamic"; | ||
|
||
import { MathJaxNodeProps } from "mathjax-render-react"; | ||
|
||
const MathJaxNode = dynamic( | ||
async () => (await import("mathjax-render-react")).MathJaxNode, | ||
{ | ||
ssr: false, | ||
}, | ||
); | ||
) as unknown as React.FC<MathJaxNodeProps>; | ||
|
||
export { MathJaxNode }; | ||
export default MathJaxNode; |
36 changes: 0 additions & 36 deletions
36
examples/mathjax-render-react-example/src/components/nprogress.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.