Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions docs/latest/examples/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ 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`:
1. Run `deno install --allow-scripts jsr:@deno/gfm`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit JSR packages don't have postinstall scripts like npm. The --allow-scripts flag does nothing here.

@fry69 fry69 Sep 19, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I try to align to docs to a freshly installed demo app with @fresh/init. When I run that command without --allow-scripts, I get warnings about scripts for Tailwind, at least. Also the Vite script seems to run for the first time when run with --allow-scripts, so I almost habitually include that everywhere now.

I'll remove that option.

2. Create a markdown file like `content/example.md`:

```md path/to/content.md
```md content/example.md
## some heading

and some interesting text here
Expand All @@ -24,32 +24,34 @@ and some interesting text here

4. Add a route that renders that file

```tsx main.ts
```tsx route/markdown.tsx
// deno-lint-ignore-file react-no-danger
import { define } from "../utils.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");
export default define.page(async () => {
const content = await Deno.readTextFile("./content/example.md");
const html = renderMarkdown(content);

return await ctx.render(
return (
<div>
<h1>Here comes a markdown post:</h1>
<style dangerouslySetInnerHTML={{ __html: CSS }} />
<div dangerouslySetInnerHTML={{ __html: html }} />
</div>,
</div>
);
});
```

## More complex examples

For building a full markdown blog see this
[tutorial](https://www.jackfiszr.eu/how-to-build-a-blog-with-fresh-2.0).

For a more elaborate markdown system with Fresh 2 take a look at the
[source code](https://github.com/denoland/fresh/tree/main/www) for this
documentation website.

## Other libraries

There are several other popular libraries besides `@deno/gfm` that can be used
Expand Down
Loading