Posts#

AttributeFormatDescription
titlestringThe title of the post.
publishedyyyy/mm/ddThe date the post was published.
descriptionbooleanA short description of the post. Displayed on index page.
imagepathThe cover image path of the post.
1. Start with http:// or https://: Use web image
2. Start with /: For image in public dir
3. With none of the prefixes: Relative to the markdown file
hideimagebooleanWhether to hide the cover image on the post page (defaults to false)
tagsstring[]The tags of the post.
categorystringThe category of the post.
draftbooleanIf this post is still a draft, which won’t be displayed.

Markdown#

Code Blocks#

AttributeOptionsDescription
title=stringThe name of the script. You can include the extension or not
{ }int-intThe area to highlight
ins={ }int-intThe area to highlight as inserted, similar to git diffs
del={ }int-intThe area to highlight as deleted, similar to git diffs
frame=auto
none
code
terminal
The frame styling
showLineNumbersboolWhether or not to show the line numbers.
You don’t need to add equals or the boolean as it defaults to false.
So you can just add showLineNumbers
startLineNumber=intThe number in which the code snippets start at

Syntax Highlighting#

Syntax Highlighting

Regular syntax highlighting#

console.log('This code is syntax highlighted!')

Rendering ANSI escape sequences#

Terminal window
ANSI colors:
- Regular: Red Green Yellow Blue Magenta Cyan
- Bold: Red Green Yellow Blue Magenta Cyan
- Dimmed: Red Green Yellow Blue Magenta Cyan
256 colors (showing colors 160-177):
160 161 162 163 164 165
166 167 168 169 170 171
172 173 174 175 176 177
Full RGB colors:
ForestGreen - RGB(34, 139, 34)
Text formatting: Bold Dimmed Italic Underline

Editor & Terminal Frames#

Editor & Terminal Frames

Code editor frames#

my-test-file.js
console.log('Title attribute example')
src/content/index.html
<div>File name comment example</div>

Terminal frames#

Terminal window
echo "This terminal frame has no title"
PowerShell terminal example
Write-Output "This one has a title!"

Overriding frame types#

echo "Look ma, no frame!"
PowerShell Profile.ps1
# Without overriding, this would be a terminal frame
function Watch-Tail { Get-Content -Tail 20 -Wait $args }
New-Alias tail Watch-Tail

Text & Line Markers#

Text & Line Markers

Marking full lines & line ranges#

// Line 1 - targeted by line number
// Line 2
// Line 3
// Line 4 - targeted by line number
// Line 5
// Line 6
// Line 7 - targeted by range "7-8"
// Line 8 - targeted by range "7-8"

Selecting line marker types (mark, ins, del)#

line-markers.js
function demo() {
console.log('this line is marked as deleted')
// This line and the next one are marked as inserted
console.log('this is the second inserted line')
return 'this line uses the neutral default marker type'
}

Adding labels to line markers#

labeled-line-markers.jsx
<button
role="button"
{...props}
value={value}
className={buttonClassName}
disabled={disabled}
active={active}
>
{children &&
!active &&
(typeof children === 'string' ? <span>{children}</span> : children)}
</button>

Adding long labels on their own lines#

labeled-line-markers.jsx
<button
role="button"
{...props}
value={value}
className={buttonClassName}
disabled={disabled}
active={active}
>
{children &&
!active &&
(typeof children === 'string' ? <span>{children}</span> : children)}
</button>

Using diff-like syntax#

this line will be marked as inserted
this line will be marked as deleted
this is a regular line
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+this is an actual diff file
-all contents will remain unmodified
no whitespace will be removed either

Combining syntax highlighting with diff-like syntax#

function thisIsJavaScript() {
// This entire block gets highlighted as JavaScript,
// and we can still add diff markers to it!
console.log('Old code to be removed')
console.log('New and shiny code!')
}

Marking individual text inside lines#

function demo() {
// Mark any given text inside lines
return 'Multiple matches of the given text are supported';
}

Regular expressions#

console.log('The words yes and yep will be marked.')

Escaping forward slashes#

Terminal window
echo "Test" > /home/test.txt

Selecting inline marker types (mark, ins, del)#

function demo() {
console.log('These are inserted and deleted marker types');
// The return statement uses the default marker type
return true;
}

Word Wrap#

Word Wrap

Configuring word wrap per block#

// Example with wrap
function getLongString() {
return 'This is a very long string that will most probably not fit into the available space unless the container is extremely wide'
}
// Example with wrap=false
function getLongString() {
return 'This is a very long string that will most probably not fit into the available space unless the container is extremely wide'
}

Configuring indentation of wrapped lines#

// Example with preserveIndent (enabled by default)
function getLongString() {
return 'This is a very long string that will most probably not fit into the available space unless the container is extremely wide'
}
// Example with preserveIndent=false
function getLongString() {
return 'This is a very long string that will most probably not fit into the available space unless the container is extremely wide'
}

Collapsible Sections#

Collapsible Sections

// All this boilerplate setup code will be collapsed
import { someBoilerplateEngine } from '@example/some-boilerplate'
import { evenMoreBoilerplate } from '@example/even-more-boilerplate'
const engine = someBoilerplateEngine(evenMoreBoilerplate())
// This part of the code will be visible by default
engine.doSomething(1, 2, 3, calcFn)
function calcFn() {
// You can have multiple collapsed sections
const a = 1
const b = 2
const c = a + b
// This will remain visible
console.log(`Calculation result: ${a} + ${b} = ${c}`)
return c
}
// All this code until the end of the block will be collapsed again
engine.closeConnection()
engine.freeMemory()
engine.shutdown({ reason: 'End of example boilerplate code' })

Line Numbers#

Line Numbers

Displaying line numbers per block#

// This code block will show line numbers
console.log('Greetings from line 2!')
console.log('I am on line 3')
// Line numbers are disabled for this block
console.log('Hello?')
console.log('Sorry, do you know what line I am on?')

Changing the starting line number#

console.log('Greetings from line 5!')
console.log('I am on line 6')

Tables#

Add the following script to the top of the post

<style>
.custom-md img {
display: block;
margin-left: auto;
margin-right: auto;
}
table th {
width: 1000px;
}
</style>

Video#

  • Keep aspect
    • add to tag class="keepaspect"
  • Adding Google Drive video
    • Replace FILEID with the video’s id
Google Drive Embed Example
<iframe src="https://drive.google.com/file/d/FILEID/preview" class="keepaspect" allow="autoplay"></iframe>

Images#

Add the following at the top

<style>
.custom-md img {
mask-image: url("/masks/paintmask-1.png");
mask-size: 100%;
}
</style>

Or if you want a single image

<paintmask>
content goes here
</paintmask>

Unity WebGL Embed#

  1. Add game to /src/games/
  2. Rename index.html to index.astro
Unity WebGL Embed
<iframe class="keepaspect" id="online-game-frame" type="text/html" src="/src/games/gamename/index.astro" scrolling="no"></iframe>

Creating a New Page#

// TODO. Automate this!

  1. Add to LinkPreset in src\config.ts
src\config.ts
export const navBarConfig: NavBarConfig = {
links: [
LinkPreset.Home,
LinkPreset.Archive,
LinkPreset.About,
LinkPreset.AddHere,
],
}
  1. Add to LinkPreset in src\types\config.ts
src\types\config.ts
export enum LinkPreset {
Home = 0,
Archive = 1,
About = 2,
AddHere = 3,
}
  1. Add to LinkPresets in src\constants\link-presets.ts
link-presets.js
export const LinkPresets: { [key in LinkPreset]: NavBarLink } = {
[LinkPreset.Home]: {
name: i18n(I18nKey.home),
url: '/',
},
[LinkPreset.About]: {
name: i18n(I18nKey.about),
url: '/about',
},
[LinkPreset.Archive]: {
name: i18n(I18nKey.archive),
url: '/archive',
},
[LinkPreset.Test]: {
name: i18n(I18nKey.test),
url: '/test',
},
[LinkPreset.AddHere]: {
name: i18n(I18nKey.AddHere),
url: '/addhere',
},
}
  1. Add the translation within the ‘en.ts’ file

    • You can do this with all the translations if you’d like… I’m lazy
  2. Add to i18nKey.ts

  3. Create an astro file within src\pages\

    • src\pages\test.astro
  4. Paste the following code into it. Making sure to change the names

test.astro
---
import MainGridLayout from "../layouts/MainGridLayout.astro";
import { getEntry } from 'astro:content'
import {i18n} from "../i18n/translation";
import I18nKey from "../i18n/i18nKey";
import Markdown from "@components/misc/Markdown.astro";
const test = await getEntry('addhere', 'addhere')
const { Content } = await test.render()
---
<MainGridLayout title={i18n(I18nKey.addhere)}>
<div class="flex w-full rounded-[var(--radius-large)] overflow-hidden relative min-h-32">
<div class="card-base z-10 px-9 py-6 relative w-full ">
<Markdown class="mt-2">
<Content />
</Markdown>
</div>
</div>
</MainGridLayout>
  1. Create a markdown file within src\content\addhere
    • src\content\addhere\addhere.md
  2. You’re done!!!
    • Hopefully you remember you have this here as a reference!

GitHub repository cards#

You can add dynamic cards that link to GitHub repositories, on page load, the repository information is pulled from the GitHub API.

Fabrizz
/
MMM-OnSpotify
Waiting for api.github.com...
00K
0K
0K
Waiting...

Create a GitHub repository card with the code ::github{repo="<owner>/<repo>"}.

::github{repo="saicaca/fuwari"}

Admonitions#

Following types of admonitions are supported: note tip important warning caution

NOTE

Highlights information that users should take into account, even when skimming.

TIP

Optional information to help a user be more successful.

IMPORTANT

Crucial information necessary for users to succeed.

WARNING

Critical content demanding immediate user attention due to potential risks.

CAUTION

Negative potential consequences of an action.

:::note
Highlights information that users should take into account, even when skimming.
:::
:::tip
Optional information to help a user be more successful.
:::

The title of the admonition can be customized.

MY CUSTOM TITLE

This is a note with a custom title.

:::note[MY CUSTOM TITLE]
This is a note with a custom title.
:::
TIP

The GitHub syntax is also supported.

> [!NOTE]
> The GitHub syntax is also supported.
> [!TIP]
> The GitHub syntax is also supported.