docs: fix markdown docs (#3459)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Bartek Iwańczuk
Claude Opus 4.6
parent
dd1ecf3b16
commit
ad8ec0fa42
@@ -12,9 +12,9 @@ First, let's install the [`@deno/gfm`](https://jsr.io/@deno/gfm) package that
|
|||||||
can transform markdown to html.
|
can transform markdown to html.
|
||||||
|
|
||||||
1. Run `deno install jsr:@deno/gfm`
|
1. Run `deno install jsr:@deno/gfm`
|
||||||
2. Create a markdown file like `content.md`:
|
2. Create a markdown file like `content/example.md`:
|
||||||
|
|
||||||
```md path/to/content.md
|
```md content/example.md
|
||||||
## some heading
|
## some heading
|
||||||
|
|
||||||
and some interesting text here
|
and some interesting text here
|
||||||
@@ -24,25 +24,30 @@ and some interesting text here
|
|||||||
|
|
||||||
3. Add a route that renders that file
|
3. Add a route that renders that file
|
||||||
|
|
||||||
```tsx main.ts
|
```tsx routes/markdown.tsx
|
||||||
|
import { define } from "@/utils.ts";
|
||||||
import { CSS, render as renderMarkdown } from "@deno/gfm";
|
import { CSS, render as renderMarkdown } from "@deno/gfm";
|
||||||
|
|
||||||
const app = new App();
|
export default define.page(async () => {
|
||||||
|
const content = await Deno.readTextFile("./content/example.md");
|
||||||
app.get("/", async (ctx) => {
|
|
||||||
const content = await Deno.readTextFile("path/to/content.md");
|
|
||||||
const html = renderMarkdown(content);
|
const html = renderMarkdown(content);
|
||||||
|
|
||||||
return await ctx.render(
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Here comes a markdown post:</h1>
|
<h1>Here comes a markdown post:</h1>
|
||||||
|
{/* deno-lint-ignore react-no-danger */}
|
||||||
<style dangerouslySetInnerHTML={{ __html: CSS }} />
|
<style dangerouslySetInnerHTML={{ __html: CSS }} />
|
||||||
|
{/* deno-lint-ignore react-no-danger */}
|
||||||
<div dangerouslySetInnerHTML={{ __html: html }} />
|
<div dangerouslySetInnerHTML={{ __html: html }} />
|
||||||
</div>,
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For a more elaborate markdown system with Fresh, take a look at the
|
||||||
|
[source code](https://github.com/denoland/fresh/tree/main/www) for this
|
||||||
|
documentation website.
|
||||||
|
|
||||||
## Other libraries
|
## Other libraries
|
||||||
|
|
||||||
There are several other popular libraries besides `@deno/gfm` that can be used
|
There are several other popular libraries besides `@deno/gfm` that can be used
|
||||||
|
|||||||
Reference in New Issue
Block a user