@@ -12,9 +12,9 @@ First, let's install the [`@deno/gfm`](https://jsr.io/@deno/gfm) package that
1212can transform markdown to html.
1313
14141 . Run ` deno install jsr:@deno/gfm `
15- 2 . Create a markdown file like ` content.md ` :
15+ 2 . Create a markdown file like ` content/example .md ` :
1616
17- ``` md path/to/ content.md
17+ ``` md content/example .md
1818## some heading
1919
2020and some interesting text here
@@ -24,25 +24,30 @@ and some interesting text here
2424
25253 . Add a route that renders that file
2626
27- ``` tsx main.ts
27+ ``` tsx routes/markdown.tsx
28+ import { define } from " @/utils.ts" ;
2829import { CSS , render as renderMarkdown } from " @deno/gfm" ;
2930
30- const app = new App ();
31-
32- app .get (" /" , async (ctx ) => {
33- const content = await Deno .readTextFile (" path/to/content.md" );
31+ export default define .page (async () => {
32+ const content = await Deno .readTextFile (" ./content/example.md" );
3433 const html = renderMarkdown (content );
3534
36- return await ctx . render (
35+ return (
3736 <div >
3837 <h1 >Here comes a markdown post:</h1 >
38+ { /* deno-lint-ignore react-no-danger */ }
3939 <style dangerouslySetInnerHTML = { { __html: CSS }} />
40+ { /* deno-lint-ignore react-no-danger */ }
4041 <div dangerouslySetInnerHTML = { { __html: html }} />
41- < / div > ,
42+ </div >
4243 );
4344});
4445```
4546
47+ For a more elaborate markdown system with Fresh, take a look at the
48+ [ source code] ( https://github.com/denoland/fresh/tree/main/www ) for this
49+ documentation website.
50+
4651## Other libraries
4752
4853There are several other popular libraries besides ` @deno/gfm ` that can be used
0 commit comments