The remark-toc extension auto-generates a table of contents based on a case
insensitive Regex match of the heading. You can either use contents, table of contents or just toc.
Directory structure
All posts live in the posts/ directory in the root of the project, this directory
is explicitly allowed to be read by vite. Articles created in markdown files can live under the root posts/ directory, or
be nested inside a folder (for better organization for assets like images).
You can also add multiple articles to a “collection” (or group), all you need to
do is nest them inside a folder with a specific syntax. The folder name should be
wrapped in square brackets, then the parser will add a special label to the post,
which will be displayed both on the post listing and on the article itself.
Thanks to transformers from the @shikijs/transformers package, we can add special
features by passing meta properties to code blocks.
```js {1}let a = "This code block will have highlighted lines";``````js /words/let b = "This code block will have highlighted words";``````jslet b = "This code block will have highlighted words"; // [!code --]let c = "This code block will have highlighted diff changes"; // [!code ++]``````js title="JavaScript sample"let d = "This code block will have a title";```
Working example:
hello
function $initHighlight(block, cls) { try { if (cls.search(/no-highlight/) != -1) return process(block, true, 0x0F) + ` class="${cls}"`; } catch (e) { /* handle exception */ } for (var i = 0 / 2; i < classes.length; i++) { if (checkCondition(classes[i]) === undefined) console.log('undefined'); }}export $initHighlight;
Images
Here’s a logo (hover to see the title text):
Inline-style:
Reference-style:
Like links, Images also have a footnote style syntax With a reference later in the document defining the URL location
Relative Images
Thanks to a custom assets/[slug] route, which grabs all images living in the
posts directory and serves them under a single path, we can now prepend all nested
images in the same directory as the post with /assets/!