Skip to content

Commit 83264d3

Browse files
authored
Feat/math examples (#303)
1 parent 5d84908 commit 83264d3

File tree

21 files changed

+313
-115
lines changed

21 files changed

+313
-115
lines changed

apps/dev/outstatic/content/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "d164819e9dad435410707d379bdda074f40eda64",
3-
"generated": "2024-11-11T14:42:41.780Z",
2+
"commit": "da55c4a80a76a17846d35e6ca0f68ef9269b3b59",
3+
"generated": "2025-06-14T19:20:16.310Z",
44
"metadata": [
55
{
66
"__outstatic": {

apps/dev/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@
4141
"esbuild": "^0.15.18",
4242
"eslint": "9.14.0",
4343
"eslint-config-next": "15.2.4",
44+
"katex": "^0.16.22",
4445
"mdx-bundler": "^10.0.1",
4546
"postcss": "8.4.41",
4647
"postcss-nesting": "^12.0.2",
4748
"rehype-autolink-headings": "^6.1.1",
49+
"rehype-katex": "^7.0.1",
4850
"rehype-pretty-code": "^0.12.6",
4951
"rehype-slug": "^5.1.0",
52+
"remark-math": "^6.0.0",
5053
"typescript": "5.7.2"
5154
},
5255
"pnpm": {

apps/dev/src/app/(web)/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ThemeProvider } from '@/components/theme-provider'
55
import { absoluteUrl, ogUrl } from '@/lib/utils'
66
import '@/styles/index.css'
77
import { Metadata } from 'next'
8+
import 'katex/dist/katex.min.css'
89

910
export const metadata: Metadata = {
1011
metadataBase: new URL('https://outstatic.com'),

apps/dev/src/lib/mdx-server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import rehypeAutolinkHeadings from 'rehype-autolink-headings'
33
import rehypePrettyCode from 'rehype-pretty-code'
44
import rehypeSlug from 'rehype-slug'
55
import remarkGfm from 'remark-gfm'
6+
import remarkMath from 'remark-math'
7+
import rehypeKatex from 'rehype-katex'
68

79
export default async function MDXServer(code: string) {
810
const result = await bundleMDX({
911
source: code,
1012
mdxOptions(options) {
1113
options.remarkPlugins = options.remarkPlugins ?? []
1214
options.remarkPlugins.push(remarkGfm as any)
13-
15+
options.remarkPlugins.push(remarkMath as any)
1416
options.rehypePlugins = options.rehypePlugins ?? []
17+
options.rehypePlugins.push(rehypeKatex as any)
1518
options.rehypePlugins.push(rehypeSlug as any)
1619
options.rehypePlugins.push([
1720
rehypePrettyCode as any,

apps/docs/outstatic/content/docs/the-content-editor.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author:
77
slug: "the-content-editor"
88
description: "Learn how the Outstatic Content Editor works."
99
coverImage: ""
10-
publishedAt: "2024-11-06T03:00:00.000Z"
10+
publishedAt: "2024-11-16T03:00:00.000Z"
1111
---
1212

1313
The content editor is the main tool used for editing documents. It's where you'll be writing your content, adding links, images, etc…
@@ -62,12 +62,30 @@ Outstatic's AI-powered completions offers you an effortless writing experience b
6262

6363
## Mathematical Expressions
6464

65-
Outstatic supports math expressions using LaTeX format. You can add them to your Markdown by clicking the Σ icon in the formatting menu. For more details, see GitHub’s [Writing Mathematical Expressions](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions) guide.\
65+
Outstatic supports math expressions using LaTeX format. Example:
66+
67+
$E=mc^2$
68+
69+
You can add them to your Markdown by clicking the Σ icon in the formatting menu. For more details, see GitHub’s [Writing Mathematical Expressions](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions) guide.
70+
6671
Please note that only inline expressions are currently supported—block expressions are not yet available.
6772

68-
To render LaTeX in your frontend you will need to install the packages needed for your framewor. You can use [remark-math](https://www.npmjs.com/package/remark-math) and [rehype-katex](https://www.npmjs.com/package/rehype-katex).
73+
To render LaTeX in your frontend you will need to install the packages needed for your framework. You can use [katex](https://www.npmjs.com/package/katex), [remark-math](https://www.npmjs.com/package/remark-math) and [rehype-katex](https://www.npmjs.com/package/rehype-katex).
74+
75+
Here's a small example for Next.js:
76+
77+
```bash
78+
pnpm i katex remark-math rehype-katex
79+
```
80+
81+
In your `layout.tsx` files add:
82+
83+
```javascript
84+
85+
import "katex/dist/katex.min.css";
86+
```
6987

70-
Here's a small example with `mdx-bundler`
88+
And in your `mdx-bundler`:
7189

7290
```typescript
7391
import { bundleMDX } from 'mdx-bundler'

apps/docs/outstatic/content/metadata.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "46fadfa83b99e86a06db3c079bf7a9b57eeff915",
3-
"generated": "2025-06-14T19:28:34.146Z",
2+
"commit": "051ca0a3c621db5de18718975b4f584245187147",
3+
"generated": "2025-06-16T19:31:00.806Z",
44
"metadata": [
55
{
66
"__outstatic": {
@@ -492,8 +492,8 @@
492492
},
493493
{
494494
"__outstatic": {
495-
"commit": "46fadfa83b99e86a06db3c079bf7a9b57eeff915",
496-
"hash": "2761599742",
495+
"commit": "051ca0a3c621db5de18718975b4f584245187147",
496+
"hash": "1502496",
497497
"path": "/outstatic/content/docs/the-content-editor.md"
498498
},
499499
"author": {
@@ -503,7 +503,7 @@
503503
"collection": "docs",
504504
"coverImage": "",
505505
"description": "Learn how the Outstatic Content Editor works.",
506-
"publishedAt": "2024-11-06T03:00:00.000Z",
506+
"publishedAt": "2024-11-16T03:00:00.000Z",
507507
"slug": "the-content-editor",
508508
"status": "published",
509509
"title": "The content editor"

apps/docs/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
"clsx": "^2.1.1",
1818
"date-fns": "^2.30.0",
1919
"gray-matter": "^4.0.3",
20+
"katex": "^0.16.22",
2021
"lucide-react": "^0.424.0",
2122
"next": "15.2.4",
2223
"next-themes": "^0.4.3",
2324
"outstatic": "workspace:*",
2425
"react": "19.0.0",
2526
"react-dom": "19.0.0",
27+
"rehype-katex": "^7.0.1",
2628
"rehype-pretty-code": "^0.12.6",
2729
"remark": "^14.0.3",
2830
"remark-gfm": "^4.0.0",
2931
"remark-html": "^15.0.2",
32+
"remark-math": "^6.0.0",
3033
"shikiji": "^0.9.19",
3134
"tailwind-merge": "^2.4.0",
3235
"vaul": "^0.8.0"

apps/docs/src/app/(docs)/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ThemeProvider } from '@/components/theme-provider'
33
import '@/styles/style.css'
44
import { Metadata } from 'next'
55
import Script from 'next/script'
6+
import 'katex/dist/katex.min.css'
67

78
export const metadata: Metadata = {
89
metadataBase: new URL('https://outstatic.com'),

apps/docs/src/lib/mdx-server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import rehypeAutolinkHeadings from 'rehype-autolink-headings'
33
import rehypePrettyCode from 'rehype-pretty-code'
44
import rehypeSlug from 'rehype-slug'
55
import remarkGfm from 'remark-gfm'
6+
import remarkMath from 'remark-math'
7+
import rehypeKatex from 'rehype-katex'
68

79
export default async function MDXServer(code: string) {
810
const result = await bundleMDX({
911
source: code,
1012
mdxOptions(options) {
1113
options.remarkPlugins = options.remarkPlugins ?? []
1214
options.remarkPlugins.push(remarkGfm as any)
13-
15+
options.remarkPlugins.push(remarkMath as any)
1416
options.rehypePlugins = options.rehypePlugins ?? []
17+
options.rehypePlugins.push(rehypeKatex as any)
1518
options.rehypePlugins.push(rehypeSlug as any)
1619
options.rehypePlugins.push([
1720
rehypePrettyCode as any,

examples/advanced-blog/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
"clsx": "^2.0.0",
1818
"date-fns": "^2.30.0",
1919
"gray-matter": "^4.0.3",
20+
"katex": "^0.16.22",
2021
"lucide-react": "^0.303.0",
2122
"next": "15.2.4",
2223
"next-themes": "^0.2.1",
2324
"outstatic": "latest",
2425
"react": "19.0.0",
2526
"react-dom": "19.0.0",
27+
"rehype-katex": "^7.0.1",
2628
"remark": "^14.0.3",
2729
"remark-gfm": "^4.0.0",
2830
"remark-html": "^15.0.2",
31+
"remark-math": "^6.0.0",
2932
"shikiji": "^0.9.0",
3033
"tailwind-merge": "^2.2.0",
3134
"tailwindcss": "4.0.7",

0 commit comments

Comments
 (0)