Logo
MDXMarkdownReactNext.jsFrontend DevelopmentWeb Development

Implement Fancy MDX

Tue Apr 26 2022Fri Apr 29 20227 minutes

Fancy MDX

All your .md and .mdx files under the contents directory will be rendered with MDX, it's an advanced Markdown format with React component support.

Heading

Hello, This Is a Title Inside h1

Hello, This Is a Title Inside h2

Hello, This Is a Title Inside h3

Hello, This Is a Title Inside h4

Hello, This Is a Title Inside h5
Hello, This Is a Title Inside h6

List

Unordered list:

  • 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.
  • Very easy!

Ordered list:

  1. Lorem ipsum dolor sit amet.
  2. Consectetur adipiscing elit.
  3. Integer molestie lorem at massa.

Sequential numbering:

  1. You can use sequential numbers...
  2. ...or keep all the numbers as 1..

Start numbering with offset:

  1. foo.
  2. bar.
  3. foo bar.

Task List

- [x] Write the press release.
- [ ] Update the website.
- [ ] Contact the media.

Renders:

  • Write the press release.
  • Update the website.
  • Contact the media.

Horizontal Rule

___

Renders:

---

Renders:

***

Renders:

Emphasis

Bold

**This is bold text**.

__This is bold text__.

Renders:

This is bold text.

This is bold text.

Italic

*This is italic text*.

_This is italic text_.

Renders:

This is italic text.

This is italic text.

Strikethrough

~This is strikethrough text~.

~~This is strikethrough text~~.

Renders:

This is strikethrough text.

This is strikethrough text.

Blockquote

Blockquotes can also be nested...

...by using additional greater-than signs right next to each other...

...or with spaces between arrows.

Blockquotes can also be continued... ...continued... ...continued continued...

Blockquotes can be very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...very very very very very very very very long...

Table

abcd
10200360048000
20010480003600
36004800010200
48000360020010
OptionDescription
datapath to data files to supply the data that will be passed into templates.
engineengine to be used for processing templates. Handlebars is the default.
extextension to be used for dest files.

Left aligned columns

OptionDescription
datapath to data files to supply the data that will be passed into templates.
engineengine to be used for processing templates. Handlebars is the default.
extextension to be used for dest files.

Center aligned columns

OptionDescription
datapath to data files to supply the data that will be passed into templates.
engineengine to be used for processing templates. Handlebars is the default.
extextension to be used for dest files.

Right aligned columns

OptionDescription
datapath to data files to supply the data that will be passed into templates.
engineengine to be used for processing templates. Handlebars is the default.
extextension to be used for dest files.

Code

Inline code.

Block code "fences":

Sample text here...

Syntax highlighting:

const foo = function (bar) {
  return bar++;
};

foo(5);

some.code();

Auto-converted link https://github.com/sabertazimi/blog (enable linkify to see):

Footnote

A note1.

Another note2.

Yet another note3.

Image

Local image:

image
Preview
Local image
image

Remote image:

Minion
Preview
Minion

Remote Alt image:

Stormtroopocat
Preview
The Stormtroopocat
Stormtroopocat

Like links, Images also have a footnote style syntax:

Alt text
Preview
The Dojocat
Alt text

With a reference later in the document defining the URL location:

[id]: https://octodex.github.com/images/dojocat.jpg  "The Dojocat"

JSX

JSX Element

<h2>JSX Heading 2</h2>

<abbr title="HyperText Markup Language">HTML</abbr> is a lovely language.

<section>
  And here is *markdown* in **JSX**!
</section>

<div># this is not a heading but *this* is emphasis</div>

I can write **Markdown** alongside my _JSX_!

<div>
  This is a `p`.
</div>

Renders:

JSX Heading 2

HTML is a lovely language.

And here is markdown in JSX!

# this is not a heading but this is emphasis

I can write Markdown alongside my JSX!

This is a p.

JavaScript Expression

Two 🍰 is: {Math.PI * 2}

Renders:

Two 🍰 is: 6.283185307179586

{(function () {
  const guess = 0.44

  if (guess > 0.66) {
    return <span style={{color: 'tomato'}}>Look at us.</span>
  }

  if (guess > 0.33) {
    return <span style={{color: 'violet'}}>Who would have guessed?!</span>
  }

  return <span style={{color: 'goldenrod'}}>Not me.</span>
})()}

Renders:

Who would have guessed?!

MDX Comments

{/* A comment! */}

Renders nothing.

Git

Emoji

Thumbs up: πŸ‘, thumbs down: πŸ‘Ž.

Families: πŸ‘¨β€πŸ‘¨β€πŸ‘¦β€πŸ‘¦

Some flags: πŸ‡¨πŸ‡³, πŸ‡ΊπŸ‡Έ, πŸ‡·πŸ‡Ί, πŸ‡¬πŸ‡§, πŸ‡«πŸ‡·.

Tada πŸŽ‰, sparkles ✨, rocket πŸš€.

Bug πŸ›, wrench πŸ”§, zap ⚑.

Math

Inline math formulas

a2+b2\sqrt{a^2 + b^2}

c=Β±a2+b2c = \pm\sqrt{a^2 + b^2}

Block math formulas

L=12ρv2SCLL = \frac{1}{2} \rho v^2 S C_L
abcdefghi\def\arraystretch{1.5} \begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}
a=b+c=e+f\begin{equation} \begin{split} a &= b + c \\ &= e + f \end{split} \end{equation}
a=b+cd+e=f\begin{align} a &= b + c \\ d + e &= f \end{align}
10x+3y=23x+13y=4\begin{alignat}{2} 10 &x + &3 &y = 2 \\ 3 &x + &13 &y = 4 \end{alignat}

Admonitions

Footnotes

  1. Big note. ↩

  2. Small note. ↩

  3. Smallest note. ↩

Copyright Β© Sabertaz Built with React and NextLast Built Time 2022/4/29 13:24:55