docs: make 2.x the default version (#3369)

This commit is contained in:
Marvin Hagemeister
2025-09-09 14:36:51 +02:00
committed by GitHub
parent 2c315a9972
commit 79d8cfc3ed
109 changed files with 1589 additions and 1502 deletions
+59
View File
@@ -0,0 +1,59 @@
---
description: |
How to render markdown on your Fresh site.
---
[Markdown](https://www.markdownguide.org/basic-syntax/) is a common text-based
file format that is often used for writing documentation, blogs and more. In
this example we are going convert markdown content to HTML and send it to the
browser.
First, let's install the [`@deno/gfm`](https://jsr.io/@deno/gfm) package that
can transform markdown to html.
1. Run `deno install jsr:@deno/gfm`
2. Create a markdown file like `content.md`:
```md path/to/content.md
## some heading
and some interesting text here
> oh look a blockquote
```
4. Add a route that renders that file
```tsx main.ts
import { CSS, render as renderMarkdown } from "@deno/gfm";
const CONTENT = `## some heading
and some interesting text here
> oh look a blockquote
`;
const app = new App();
app.get("/", async (ctx) => {
const content = await Deno.readTextFile("path/to/content.md");
const html = renderMarkdown(content);
return await ctx.render(
<div>
<h1>Here comes a markdown post:</h1>
<style dangerouslySetInnerHTML={{ __html: CSS }} />
<div dangerouslySetInnerHTML={{ __html: html }} />
</div>,
);
});
```
## Other libraries
There are several other popular libraries besides `@deno/gfm` that can be used
to render markdown. The most common ones are:
- [marked](https://marked.js.org/)
- [remark](https://remark.js.org/)