Skip to content

Commit

Permalink
feat: extrace mathjax-render-nextjs package
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
  • Loading branch information
Dup4 committed Jul 8, 2023
1 parent cbf9774 commit d250694
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 66 deletions.
2 changes: 1 addition & 1 deletion examples/mathjax-render-react-example/package.json
Expand Up @@ -15,7 +15,7 @@
"clsx": "^1.2.1",
"lucide-react": "^0.258.0",
"mathjax-render": "workspace:*",
"mathjax-render-react": "workspace:*",
"mathjax-render-nextjs": "workspace:*",
"next": "^13.4.9",
"next-themes": "^0.2.1",
"nextjs-toploader": "^1.4.2",
Expand Down
3 changes: 2 additions & 1 deletion examples/mathjax-render-react-example/src/app/page.tsx
Expand Up @@ -2,9 +2,10 @@

import React, { ChangeEventHandler, useState, useCallback } from "react";

import { MathJaxNode } from "mathjax-render-nextjs";

import { Textarea } from "@/components/ui/textarea";
import { Container } from "@/components/container";
import { MathJaxNode } from "@/components/mathjax-node";

export default function Page() {
const [texValue, setTexValue] = useState("");
Expand Down
@@ -1,5 +1,6 @@
import { MathJaxNode } from "mathjax-render-nextjs";

import { Container } from "@/components/container";
import { MathJaxNode } from "@components/mathjax-node";

import { getTexList } from "@/lib/tex-list";

Expand Down
3 changes: 3 additions & 0 deletions examples/mathjax-render-react-example/tsconfig.json
Expand Up @@ -26,6 +26,9 @@
"mathjax-render": [
"../../packages/mathjax-render/src/node/index.ts"
],
"mathjax-render-nextjs": [
"../../packages/mathjax-render-nextjs/src/index.ts",
]
},
"plugins": [
{
Expand Down
27 changes: 27 additions & 0 deletions packages/mathjax-render-nextjs/build.config.ts
@@ -0,0 +1,27 @@
import { BuildContext, defineBuildConfig } from "unbuild";
import { RollupOptions } from "rollup";

import postcss from "rollup-plugin-postcss";
import camelcase from "camelcase";

export default defineBuildConfig({
entries: ["src/index"],
declaration: true,
clean: true,
rollup: {
emitCJS: true,
},
hooks: {
"rollup:options": (ctx: BuildContext, options: RollupOptions): void => {
options.plugins?.push(
postcss({
inject: true,
use: ["less"],
namedExports(name) {
return camelcase(name);
},
}),
);
},
},
});
61 changes: 61 additions & 0 deletions packages/mathjax-render-nextjs/package.json
@@ -0,0 +1,61 @@
{
"name": "mathjax-render-nextjs",
"version": "0.0.19",
"license": "MIT",
"author": "Dup4 <lyuzhi.pan@gmail.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/Dup4/mathjax-render.git",
"directory": "packages/mathjax-render-nextjs"
},
"bugs": {
"url": "https://github.com/Dup4/mathjax-render/issues"
},
"homepage": "https://github.com/Dup4/mathjax-render/tree/main/packages/mathjax-render-nextjs#readme",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"typesVersions": {
"*": {
"*": [
"./dist/index.d.ts"
]
}
},
"files": [
"src",
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "unbuild --stub",
"test": "vitest",
"lint:build": "tsc --noEmit",
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"next": "^13.4.9",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"dependencies": {
"mathjax-render-react": "workspace:*"
},
"devDependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next": "^13.4.9",
"rollup": "^2.79.1",
"rollup-plugin-postcss": "^4.0.2",
"typescript": "4.7.3"
}
}
1 change: 1 addition & 0 deletions packages/mathjax-render-nextjs/src/index.ts
@@ -0,0 +1 @@
export * from "./mathjax-node";
19 changes: 19 additions & 0 deletions packages/mathjax-render-nextjs/tsconfig.json
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"include": [
"src",
"typings.d.ts",
],
"compilerOptions": {
"jsx": "react",
"lib": [
"DOM"
],
"baseUrl": ".",
"paths": {
"@/*": [
"src/*"
],
},
}
}
1 change: 1 addition & 0 deletions packages/mathjax-render-nextjs/typings.d.ts
@@ -0,0 +1 @@
declare module "*.module.less";
2 changes: 1 addition & 1 deletion packages/mathjax-render-react/src/index.ts
@@ -1 +1 @@
export * from "./mathjaxNode";
export * from "./mathjax-node";
@@ -1,6 +1,6 @@
import React from "react";
import { Options, Tex2SVG } from "mathjax-render/browser";
import style from "./mathjaxNode.module.less";
import style from "./mathjax-node.module.less";

export interface MathJaxNodeProps extends Options {
tex: string;
Expand Down

0 comments on commit d250694

Please sign in to comment.