This article offers a sample of basic and extended Markdown formatting that can be used, also it shows how some basic HTML elements are decorated.
Markdown in Astro
Markdown is commonly used to author text-heavy content like blog posts and documentation. Astro includes built-in support for Markdown files that can also include frontmatter YAML (or TOML) to define custom properties such as a title, description, and tags.
In Astro, you can author content in GitHub Flavored Markdown, then render it in
.astro
components. This combines a familiar writing format designed for content with the flexibility of Astro’s component syntax and architecture.
source: Markdown in Astro | Docs
Theme Specifics
This theme came with a set of shortcodes that can be used to enhance the Markdown experience. These shortcodes are located in the /src/components/shortcodes
directory and can be used to add custom functionality or styling to your Markdown content.
To use these shortcodes, you should first rename the file to a MDX (.mdx) file. Once renamed, you can use the shortcodes in your content like this:
import ExampleShortcode from '/src/components/shortcodes/ExampleShortcode.astro';
your content here...
</ExampleShortcode>
Spoiler
Inspired by the spoiler in Moegirl wiki, you can use the Spoiler
component to hide content that you want to reveal later. This is useful for spoilers in game plots , movies plots, or any other content where you want to keep certain information hidden until the user chooses to reveal it.
To reveal the content, readers can hover over the text to reveal it.
A hot take: the theme is done through what is called ‘vibe coding’.
<Spoiler>
A hot take: the theme is done through what is called 'vibe coding'.
</Spoiler>
You can also display a ‘tip’ for the reader when hovered:
A hot take: the theme is done through what is called ‘vibe coding’.
<Spoiler tip='attention is all you need'>
A hot take: the theme is done through what is called 'vibe coding'.
</Spoiler>
Ruby
The Ruby
component allows you to quickly add ruby annotations to your text, which is useful for providing pronunciation or additional information about certain words, especially in East Asian languages.
<Ruby text="汉" ruby="han" />
<Ruby text="字" ruby="zi" />
Callouts
You can use callouts to highlight important information or warnings in your content. Callouts are styled boxes that draw attention to specific parts of the text.
This is an informational callout. It can be used to provide additional context or tips.
This is a warning callout. Use it to alert users about potential issues or important notes.
This is an error callout. It should be used to indicate critical issues that need immediate attention.
<Callout icon='💁' type="info">
This is an informational callout. It can be used to provide additional context or tips.
</Callout>
<Callout type="warning">
This is a warning callout. Use it to alert users about potential issues or important notes.
</Callout>
<Callout type="danger">
This is an error callout. It should be used to indicate critical issues that need immediate attention.
</Callout>
LinkCard
You can use the LinkCard
component to create cards that link to external resources or pages. This is useful for showcasing projects, documentation, or any other relevant links.
This most simple one can be used like this:
<LinkCard url="https://astro.build"/>
or with a archive link:
<LinkCard url="https://astro.build" showArchive="true" pubDate={frontmatter.pubDate} updatedDate={frontmatter.updatedDate} />
The pubDate
or updatedDate
props is optional, but in order to make the component to display the archived version around the date correctly, they should be passed.
Choose one or both of them according to your needs.
On a machine with bad network, this will significantly increase build time when no other params are passed to the component.
Or to customize the card further with a title and description:
Protected Content
You can use the ProtectedContent
component to protect certain parts of your content with a password. This is useful for sharing exclusive content or information that should only be accessible to certain users.
About security:
Although the encrypt process is happened at build and encrypted content is not visible in the rendered HTML. But it’s still not 100% secure, as the password can be stored in the source code of a document (which could be public). Use it only for not really sensitive content. Using a environment variable to store the password is recommended.
This content is protected. Enter the password to view it:
<ProtectedContent password="42">
Yes, what you input is the ultimate answer to *life*, *the universe*, and **everything**.
</ProtectedContent>
This content is protected. Enter the password to view it:
<ProtectedContent>
And this will be encrypted with a global password, which is set in the environment variable `CONTENT_PASSWORD` or defined by `config.ts`. (config.ts takes precedence over the environment variable)
</ProtectedContent>
Headings
The following HTML <h1>
—<h6>
elements represent six levels of section headings. <h1>
is the highest section level while <h6>
is the lowest.
H1
H2
H3
H4
H5
H6
Paragraph
Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.
Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.
Blockquotes
The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a footer
or cite
element, and optionally with in-line changes such as annotations and abbreviations.
Blockquote without attribution
Tiam, ad mint andaepu dandae nostion secatur sequo quae. Note that you can use Markdown syntax within a blockquote.
Blockquote with attribution
Don’t communicate by sharing memory, share memory by communicating.
— Rob Pike1
Tables
Tables aren’t part of the core Markdown spec, but Astro supports supports them out-of-the-box.
Name | Age |
---|---|
Bob | 27 |
Alice | 23 |
Inline Markdown within tables
Italics | Bold | Code |
---|---|---|
italics | bold | code |
Code Blocks
Code block with backticks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Example HTML5 Document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
List Types
Ordered List
- First item
- Second item
- Third item
Unordered List
- List item
- Another item
- And another item
Nested list
- Fruit
- Apple
- Orange
- Banana
- Dairy
- Milk
- Cheese
Other Elements — abbr, sub, sup, kbd, mark
GIF is a bitmap image format.
H2O
Xn + Yn = Zn
Press CTRL+ALT+Delete to end the session.
Most salamanders are nocturnal, and hunt for insects, worms, and other small creatures.
Formulas
Thanks to the remark-math and KaTeX , you can write mathematical formulas using LaTeX syntax.
Both inline and block formulas are supported (see example below). Inline formulas can be written like $$L$$
or $L$
,
while block formulas can be written like this:
$$
-\frac{\hbar^2}{2m}\nabla^2\psi + V\psi = E\psi
$$
or
```math
-\frac{\hbar^2}{2m}\nabla^2\psi + V\psi = E\psi
```
By default, the reader can copy the formulas in LaTeX format by copy the rendered formulas, unless you set noClientJavaScript
to true
in the config.ts
file.
Lift() can be determined by Lift Coefficient () like the following equation:
Footnotes
-
The above quote is excerpted from Rob Pike’s talk
about
nothing during Gopherfest, November 18, 2015. ↩