📝 MDX Showcase
This page demonstrates the usage of MDX.
Created on January 26, 2024 at 12:00 AM
✨ Lorem ipsum dolor sit amet, consectetur adipisicing elit. A alias asperiores atque autem.
Headings
Headings can be added using #
characters at the beginning of a line. The number of #
you use will determine the size of the heading.
It will be rendered as <h1>
for #
and <h2>
for ##
and so on.
h1 Heading
h2 Heading
h3 Heading
h4 Heading
h5 Heading
h6 Heading
Horizontal Rules
Horizontal rules can be added using ---
or ***
or ___
on a line by themselves.
It will be rendered as <hr>
.
The first section
The second section
Emphasis
Simple inline emphasis styles are available using the following syntax:
This is bold text
This is italic text
Strikethrough
Note
Strikethrough functionality is provided by GitHub Flavored Markdown plugin for remark remark-gfm
.
Images
Blockquotes
Blockquotes can be added using >
characters at the beginning of a line.
Also, it can be nested by using additional >
characters right next to each other or with spaces between arrows.
It will be rendered as <blockquote>
.
Blockquotes can also be nested...
...by using additional greater-than signs right next to each other...
...or with spaces between arrows.
Lists
Unordered
Unordered lists can be added using +
, -
, or *
characters at the beginning of a line.
It will be rendered as <ul>
and <li>
.
- Create a list by starting a line with
+
,-
, or*
- Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
- Ac tristique libero volutpat at
- Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
- Marker character change forces new list start:
- Very easy!
Ordered
Ordered lists can be added using 1.
, 2.
, 3.
and so on at the beginning of a line.
You can also start counting with any number you want by using 1.
at the beginning of a line.
It will be rendered as <ol>
and <li>
.
-
Lorem ipsum dolor sit amet
-
Consectetur adipiscing elit
-
Integer molestie lorem at massa
-
Integer molestie lorem at massa
-
You can use sequential numbers...
-
...or keep all the numbers as
1.
Start numbering with offset:
- foo
- bar
Code
Thanks to rehype-pretty-code
, syntax highlighting is available for both code blocks and inline code.
Inline code
A language can be specified by appending {:language_id}
to the end of inline code.
e.g. console.log('Hi'){:js}
.
Here is React component: export const MyComponent = (props: MyComponentProps): ReactNode => (...)
.
You can reduce re-rendering by using useMemo()
hook: const memoizedValue = useMemo(() => runExpensiveEvaluation(a, b), [a, b])
.
By doing this, runExpensiveEvaluation(a, b)
is only called when a
or b
changes instead of every render.
Code blocks
You can specify a language for code blocks by appending language_id
to the end of the opening fence ```
.
Also, you can add showLineNumbers
to the end of the opening fence to show line numbers.
Syntax | Description |
---|---|
```ts | Renders codes with Typescript syntax highlighting |
```c showLineNumbers | Renders codes with Clang syntax highlighting and line numbers |
It will be rendered as <pre><code>
.
Sample text here...
Note
Code blocks are rendered using rehype-pretty-code
and it internally uses shikiji
.
You can configure syntax highlighting themes in rehype-pretty-code
config written in contentlayer.config.ts
.
TeX
is also supported by using remark-math
and rehype-katex
.
If a function is continuous on , then there exists at least one number in such that
Tables
Left aligned columns
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Right aligned columns
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Center aligned columns
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Inline codes and math equations in tables
Syntax | Output |
---|---|
`console.log('Hi'){:js}` | console.log('Hi') |
`from matplotlib import plot as plt{:py}` | from matplotlib import plot as plt |
$ \sum_{n=1}^{10} n^2 $ | |
$ \int_{0}^{\infty} e^{-x} dx $ |
GFM Callouts
You can create colored callouts by using > [!NOTE]
, > [!TIP]
, > [!IMPORTANT]
, > [!WARNING]
, or > [!CAUTION]
at the beginning of a line.
Make sure to add double spaces after the closing ]
character.
Alerts are an extension of Markdown used to emphasize critical information. On GitHub, they are displayed with distinctive colors and icons to indicate the importance of the content. Refer: https://github.com/orgs/community/discussions/16925
Note
Highlights information that users should take into account, even when skimming.
console.log('Hi')
This is bold text This is italic text Strikethrough
Tip
Optional information to help a user be more successful.
console.log('Hi')
This is bold text This is italic text Strikethrough
Important
Crucial information necessary for users to succeed.
console.log('Hi')
This is bold text This is italic text Strikethrough
Warning
Critical content demanding immediate user attention due to potential risks.
console.log('Hi')
This is bold text This is italic text Strikethrough
Caution
Negative potential consequences of an action.
console.log('Hi')
This is bold text This is italic text Strikethrough
GFM Autolink literals
URLs are automatically converted into clickable links.