Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@mintlify/prettier-config/config.js"
6 changes: 6 additions & 0 deletions examples/app-router/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--primary-light: 85 215 153;
}
}
17 changes: 7 additions & 10 deletions examples/app-router/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import type { Metadata } from "next";
import "@/app/globals.css";
import "@mintlify/mdx/dist/styles.css";
import '@mintlify/mdx/dist/styles.css';
import type { Metadata } from 'next';

import '@/app/globals.css';

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: 'Create Next App',
description: 'Generated by create next app',
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
Expand Down
10 changes: 4 additions & 6 deletions examples/app-router/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { getCompiledServerMdx } from "@mintlify/mdx";
import { getCompiledServerMdx } from '@mintlify/mdx';
import { promises as fs } from 'fs';

export default async function Home() {
const fileContentResponse = await fetch(
"https://raw.githubusercontent.com/mintlify/starter/main/essentials/code.mdx"
);
const fileContentData = await fileContentResponse.text();
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx');

const { content, frontmatter } = await getCompiledServerMdx<{
title: string;
}>({
source: fileContentData,
source: data.toString(),
});

return (
Expand Down
51 changes: 51 additions & 0 deletions examples/app-router/examples/highlight-example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: 'Line Highlighting'
description: 'Highlights specific lines and/or line ranges'
---

This MDX file demonstrates syntax highlighting for various programming languages.

## JavaScript

```js index.js {2}
console.log('Hello, world!');
function add(a, b) {
return a + b;
}

function subtract(a, b) {
return a - b;
}
```

## Python

```python index.py {1-2,4-5}
def add(a, b):
return a + b

def subtract(a, b):
return a - b
```

## Java

```java {3}
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```

## C#

```csharp index.cs {1,3-4}
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
```
4 changes: 2 additions & 2 deletions examples/app-router/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {};

module.exports = nextConfig
module.exports = nextConfig;
2 changes: 1 addition & 1 deletion examples/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@mintlify/mdx": "^0.0.43",
"@mintlify/mdx": "^0.0.44",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
16 changes: 6 additions & 10 deletions examples/app-router/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
1. Call the `getCompiledServerMdx` function inside your async React Server Component which will give you the `frontmatter` and `content`.

```tsx
import { getCompiledServerMdx } from "@mintlify/mdx";
import { getCompiledServerMdx } from '@mintlify/mdx';

export default async function Home() {
const { content, frontmatter } = await getCompiledServerMdx({
Expand All @@ -38,19 +38,15 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
2. Import `@mintlify/mdx/dist/styles.css` inside your `layout.tsx` file. This file contains the styles for the code syntax highlighting.

```tsx
import type { Metadata } from "next";
import "@mintlify/mdx/dist/styles.css";
import '@mintlify/mdx/dist/styles.css';
import type { Metadata } from 'next';

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: 'Create Next App',
description: 'Generated by create next app',
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
Expand Down
15 changes: 7 additions & 8 deletions examples/app-router/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import type { Config } from "tailwindcss";
import type { Config } from 'tailwindcss';

const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic': 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
plugins: [require("@tailwindcss/typography")],
plugins: [require('@tailwindcss/typography')],
};
export default config;
51 changes: 51 additions & 0 deletions examples/pages-router/examples/highlight-example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: 'Line Highlighting'
description: 'Highlights specific lines and/or line ranges'
---

This MDX file demonstrates syntax highlighting for various programming languages.

## JavaScript

```js index.js {2}
console.log('Hello, world!');
function add(a, b) {
return a + b;
}

function subtract(a, b) {
return a - b;
}
```

## Python

```python index.py {1-2,4-5}
def add(a, b):
return a + b

def subtract(a, b):
return a - b
```

## Java

```java {3}
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```

## C#

```csharp index.cs {1,3-4}
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
```
6 changes: 2 additions & 4 deletions examples/pages-router/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
const nextConfig = {};

module.exports = nextConfig
module.exports = nextConfig;
2 changes: 1 addition & 1 deletion examples/pages-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@mintlify/mdx": "^0.0.43",
"@mintlify/mdx": "^0.0.44",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
Expand Down
6 changes: 3 additions & 3 deletions examples/pages-router/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@/styles/globals.css";
import "@mintlify/mdx/dist/styles.css";
import '@mintlify/mdx/dist/styles.css';
import { AppProps } from 'next/app';

import { AppProps } from "next/app";
import '@/styles/globals.css';

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
Expand Down
4 changes: 2 additions & 2 deletions examples/pages-router/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Html, Head, Main, NextScript } from 'next/document'
import { Html, Head, Main, NextScript } from 'next/document';

export default function Document() {
return (
Expand All @@ -9,5 +9,5 @@ export default function Document() {
<NextScript />
</body>
</Html>
)
);
}
13 changes: 5 additions & 8 deletions examples/pages-router/pages/api/hello.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
import type { NextApiRequest, NextApiResponse } from 'next';

type Data = {
name: string
}
name: string;
};

export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
export default function handler(req: NextApiRequest, res: NextApiResponse<Data>) {
res.status(200).json({ name: 'John Doe' });
}
18 changes: 7 additions & 11 deletions examples/pages-router/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { MDXComponent, getCompiledMdx } from "@mintlify/mdx";
import type { MDXCompiledResult } from "@mintlify/mdx";
import type { GetStaticProps, InferGetStaticPropsType } from "next";
import type { MDXCompiledResult } from '@mintlify/mdx';
import { MDXComponent, getCompiledMdx } from '@mintlify/mdx';
import { promises as fs } from 'fs';
import type { GetStaticProps, InferGetStaticPropsType } from 'next';

export const getStaticProps = (async () => {
const fileContentResponse = await fetch(
"https://raw.githubusercontent.com/mintlify/starter/main/essentials/code.mdx"
);
const fileContentData = await fileContentResponse.text();
const data = await fs.readFile(process.cwd() + '/examples/highlight-example.mdx');

const mdxSource = await getCompiledMdx({
source: fileContentData,
source: data.toString(),
});

return {
Expand All @@ -21,9 +19,7 @@ export const getStaticProps = (async () => {
mdxSource: MDXCompiledResult;
}>;

export default function Home({
mdxSource,
}: InferGetStaticPropsType<typeof getStaticProps>) {
export default function Home({ mdxSource }: InferGetStaticPropsType<typeof getStaticProps>) {
return (
<article className="prose mx-auto py-8">
<h1>{String(mdxSource.frontmatter.title)}</h1>
Expand Down
2 changes: 1 addition & 1 deletion examples/pages-router/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
6 changes: 6 additions & 0 deletions examples/pages-router/styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--primary-light: 85 215 153;
}
}
15 changes: 7 additions & 8 deletions examples/pages-router/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import type { Config } from "tailwindcss";
import type { Config } from 'tailwindcss';

const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic': 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
plugins: [require("@tailwindcss/typography")],
plugins: [require('@tailwindcss/typography')],
};
export default config;
Loading