Skip to content

Commit 169fa7d

Browse files
committed
improve
1 parent d479225 commit 169fa7d

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ export const Component = () => {
5252
};
5353
```
5454

55+
#### How to use this on Next.js
56+
57+
```jsx
58+
import dynamic from 'next/dynamic';
59+
const IpynbRenderer = dynamic(() => import('react-ipynb-renderer').then((mod) => mod.IpynbRenderer), {
60+
ssr: false
61+
});
62+
// import ipynb file as json
63+
import ipynb from "./test.ipynb";
64+
65+
export const Component = () => {
66+
return (
67+
<IpynbRenderer
68+
ipynb={ipynb}
69+
/>
70+
);
71+
};
72+
```
73+
5574
### Using react-ipynb-renderer-katex
5675

5776
```jsx

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import {
44
MarkdownOptionsForMathjax,
55
MarkdownForMathjax,
66
} from "./components/MarkdownForMathjax";
7-
import { BaseProps } from "./types";
7+
import {BaseProps, IpynbType} from "./types";
88
import pkg from "../package.json";
99
import { defaultHtmlFilter } from "./filters";
1010
import { Context } from "./context";
1111

1212
console.debug(`react-ipynb-renderer@${pkg.version} is working.`);
1313

14+
export type Ipynb = IpynbType;
15+
1416
export type Props = BaseProps & {
1517
markdownOptions?: MarkdownOptionsForMathjax;
1618
};

src/styles/default.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
}
2626
div.output_area {
27+
display: flex;
28+
padding: 5px 0;
2729
.prompt {
2830
padding-right: 0 !important;
2931
}

src/types.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ export type LanguageType = "python" | "r" | "julia" | "haskell" | "ruby";
6969

7070
export type HtmlFilter = (html: string) => string;
7171

72+
export type IpynbType = {
73+
cells: CellType[];
74+
worksheets?: { cells: CellType[] }[];
75+
}
76+
7277
export type BaseProps = {
73-
ipynb: {
74-
cells: CellType[];
75-
worksheets?: { cells: CellType[] }[];
76-
};
78+
ipynb: IpynbType;
7779
syntaxTheme?: SyntaxThemeType;
7880
language?: LanguageType;
7981
bgTransparent?: boolean;

0 commit comments

Comments
 (0)