Commit Graph
360 Commits
Author SHA1 Message Date
Devon Wells a2c9350cc4 docs: typos in define helpers page (#3533)
## Summary

Minor typos in define docs page I noticed while onboarding to Fresh 2.
2025-10-07 12:48:29 +02:00
Marvin Hagemeister c93e19dfbd docs: add Deno upgrade section (#3526) 2025-10-06 08:08:30 +02:00
fry69 8e9dcc087f docs: troubleshoot deploy error message (#3511)
This adds one sentence to the "My deployment won't start" section
mentioning the common `ISOLATE_INTERNAL_FAILURE` error message, so it
can get found via search.

See also discussion in Discord ->
https://discord.com/channels/684898665143206084/1422792167797166121
2025-10-02 23:47:48 +02:00
fry69 1e94e1c9c5 docs: troubleshoot VS Code extension (#3510)
This adds a short blurb how to install the VS Code extension to the
troubleshooting guide.

Possible concerns:
- maybe redundant as there are already official VS Code Deno docs
- could be shortened to just refer to the main docs or completely
removed
2025-10-01 13:20:47 +02:00
fry69 89ae0935b6 docs: troubleshoot dependency installation (#3508)
This adds:
- a short blurb about missing dependencies to the troubleshooting guide
- a hint to this guide in the getting starting page
2025-09-30 11:32:37 +02:00
Bruno Bernardino fa6f4f4bef docs: fix wrong variable name in migration guide (#3496)
You have `export const handlers = ` when it needs to be `export const
handler = `.

I'm unsure if there's any build process I need to run for this.
2025-09-26 11:03:42 +02:00
fry69 f82bd7e63d docs: add deno.json update section to migration guide (#3471)
fix #3470 

This adds a short blurb about `deno.json` focusing on imports.

Background: Without `npm:vite` and `jsr:@fresh/plugin-vite` installed it
can lead to confusing errors like this one:
```shell
$ deno task dev
vite: command not found
```

Which might lead to users install Vite globally, which is not needed
(and will not fix this problem).
2025-09-20 13:17:11 +02:00
Mau Scheff 18961995d5 docs: Revise migration guide with new help sections (#3455)
Revise migration guide with new help sections
2025-09-16 13:24:39 +02:00
Marvin Hagemeister 3867e60664 fix: improve missing build cache error message (#3441)
Hoping that this helps folks who ignore the migration guide and keep the
entry pointed to `main.ts`.
2025-09-15 19:19:10 +02:00
fry69 999b89501e docs: fix testing docs (#3419)
This fixes the testing page in the docs for real this time.

Every test is hand checked now. Thanks to a certain button, which
appeared recently.

Optionally I can also split this page up in separate pages:
- Middlewars
- AppWrappers and Layouts
- Routing and Handlers
- SSR and Islands
2025-09-15 16:53:48 +00:00
fry69 016f94e28e docs: fix minor issues in middleware docs (#3436) 2025-09-15 12:20:48 +02:00
Emil KrebsandMarvin Hagemeister b4bb004753 feat: add CSP and header middleware (#3421)
Added a CSP and header middleware to simplify the HTTP Security Response
Header creation.

Fixes:
- https://github.com/denoland/fresh/issues/1705

Example:

```ts
// main.ts

export const app = new App<State>()
    .use(csp({
        reportTo: '/api/csp-reports',
    }))
    .use(headers({
        'Cross-Origin-Resource-Policy': 'same-site',
        'Cross-Origin-Embedder-Policy': 'require-corp',
        'Cross-Origin-Opener-Policy': 'same-origin',
        'Permissions-Policy':
            'geolocation=(), camera=(), microphone=(), payment=(), usb=(), bluetooth=(), magnetometer=(), gyroscope=(), accelerometer=()',
        'Referrer-Policy': 'strict-origin-when-cross-origin',
        'X-Content-Type-Options': 'nosniff',
        'X-Frame-Options': 'DENY',
        'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload',
    }))
```

Endpoint example:
```ts
// routes/api/csp-handler.ts

import { Context } from 'fresh';
import { State } from '../../main.ts';

export const handler = {
    async POST(ctx: Context<State>) {
        try {
            const text = await ctx.req.text();
            const body = JSON.parse(text);

            const logEntry = {
                timestamp: new Date().toISOString(),
                report: body,
                userAgent: ctx.req.headers.get('user-agent') || 'unknown',
            };
            await Deno.writeFile('csp-reports.log', new TextEncoder().encode(JSON.stringify(logEntry) + '\n'), { append: true });

            return new Response(JSON.stringify({ status: "ok" }), { status: 200 });
        } catch (error) {
            console.error("Error handling CSP report:", error);
            return new Response(JSON.stringify({ status: "error", error: String(error) }), { status: 500 });
        }
    },
};

```

Implementing these headers improved the security report at [Security
Headers](securityheaders.com) from F to A and helps to prevent security
vulnerabilities like Cross-Site Scripting and Clickjacking.

**Before**
<img width="1200" height="308" alt="image"
src="https://github.com/user-attachments/assets/01adfff4-5bb4-4cc6-bd8f-5e74b471301b"
/>
**After**
<img width="1200" height="335" alt="image"
src="https://github.com/user-attachments/assets/c5a9b07e-babf-4797-b47d-4368de70cbc3"
/>

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-09-15 12:20:22 +02:00
Zhi 7999d500f8 docs: fix missing files on "sharing state with islands" page (#3377)
close #3376
2025-09-12 17:16:30 +02:00
Marvin Hagemeister e06f03ac67 fix: add missing compile entry (#3410)
Fixes https://github.com/denoland/fresh/issues/3409
2025-09-12 13:08:49 +02:00
Marvin Hagemeister fc3cdc9588 docs: update cloudflare workers docs (#3405) 2025-09-12 11:04:47 +02:00
Marvin Hagemeister e30cb375d1 docs: mention entry in cloudflare worker docs (#3403)
Related https://github.com/denoland/fresh/issues/3402
2025-09-12 10:37:38 +02:00
fry69 a473cc9d9f docs: update testing with routes and islands (#3385)
closes #3383
2025-09-12 10:03:08 +02:00
fry69 a7af5c0c3d docs: add simple mountApp example (#3380)
Simple `mountApp()` example from the Discord
2025-09-10 13:41:39 +02:00
Marvin Hagemeister 79d8cfc3ed docs: make 2.x the default version (#3369) 2025-09-09 14:36:51 +02:00
Marvin Hagemeister 2c315a9972 docs: remove outdated crud docs (#3368)
Fixes https://github.com/denoland/fresh/issues/3367
2025-09-09 11:59:34 +02:00
ZhiandMarvin Hagemeister f869bff685 docs: fix typos in image filenames and update references (#3348)
Fix typos in image filenames and update references
#3340 Inconsistent renaming caused images to fail normal detection.

---------

Co-authored-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
2025-09-06 17:39:04 +02:00
Alejandro Martínez 2d3f28a960 docs: include missing imports in the getting started tutorial (#3349)
The Countdown code in the tutorial doesn't work when copied and pasted
because the imports for useSignal and useEffect are missing. Adding the
missing imports will help those following the tutorial to have a better
experience.
2025-09-06 10:32:22 +02:00
ZhiandMarvin Hagemeister 7c5f209296 docs: add images to getting started guide (#3340)
Replaced placeholder TODOs with actual screenshots in the getting
started documentation and added three new image files to illustrate the
initialization, about page, and countdown examples.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-09-05 12:13:32 +02:00
Marvin Hagemeister 70017d2480 docs: fix form data page (#3329)
Fixes https://github.com/denoland/fresh/issues/3320
2025-09-03 12:12:53 +02:00
Marvin Hagemeister fbfdcd719d docs: migration guide ctx.render() (#3314)
Fixes https://github.com/denoland/fresh/issues/2969
2025-09-02 16:04:30 +02:00
Marvin Hagemeister 9685488451 docs: add troubleshooting page (#3313) 2025-09-02 15:35:02 +02:00
fry69 c163e457d0 docs: mention that <Head> is not dynamic (#3312)
Adds a small note that `<Head>` is not dynamic by default
2025-09-02 15:20:12 +02:00
Marvin Hagemeister 9e58af7a5c docs: update for vite (#3308)
Update docs for vite
2025-09-02 10:45:27 +02:00
Kevin e0321efc06 docs: remove duplicate example lines in csrf.md (#3278)
(thanks team! following along and alpha testing.)
2025-08-29 22:19:36 +02:00
Marvin Hagemeister 1daca75489 feat: bring back <Head> component (#3249)
This PR brings back the `<Head>` component from Fresh 1.x . The
implementation is much cleaner than back then and also works client-side
now too.
2025-08-25 15:40:47 +02:00
crowlsyong 54110c6372 docs: fix typo in csrf.md (#3223)
safguard --> safeguard
2025-08-18 13:59:23 +00:00
Marvin Hagemeister 09b0c73d9f docs: mention new entrypoint in migration guide (#3222) 2025-08-18 12:58:39 +02:00
Marvin Hagemeister fe4a59a88c feat: support custom server entry (#3216) 2025-08-12 12:50:10 +02:00
Marvin Hagemeister f27f10fbcb docs: fix duplicate line (#3215) 2025-08-12 12:34:15 +02:00
Marvin Hagemeister 477fcefed4 feat: support inlining FRESH_PUBLIC_ env vars (#3214)
Fixes https://github.com/denoland/fresh/issues/3213
2025-08-12 12:00:59 +02:00
Marvin Hagemeister 27e407a1e3 feat: add define.layout helper (#3198) 2025-08-06 15:23:18 +02:00
Roscoe Rubin-Rottenberg a5205b2a8e docs: add correct ctx.state example to init and docs (#3147)
- Correct outdated, non-functional and confusing "Removal of <Head>
component" section of migration guide in the docs to be real functional
code that uses Fresh 2 and define helpers correctly
- Added example of ctx.state being used for a head component (title)
because it's something almost every single project will need to know how
to do.
- Small change to define docs use of define.page to be more in line with
its use commonly
- Removed mention of deno-puppeteer - a non-official repository that
hasn't been updated in three years - needing to be installed from
`CONTRIBUTING.md`
2025-08-06 00:17:24 +02:00
Christian Svensson b7f1abb0d0 test(docs): type check docs code examples (#3180)
This PR adds the initial seeds of type checking the code in all code
blocks for the Markdown Docs.

- Adds a unit test, disabled due to the many remaining errors, that can
help find incorrect code
- Fixes a bunch of syntax errors, type errors, and other code issues
found in the docs

## Future improvements

A lot of remaining issues is mostly related to missing imports, e.g.
`App`, `staticFiles`, `HttpError` etc. There's a couple of different
directions to solve this in future PR's.

- Add explicit imports to all docs examples (may become unnecessarily
verbose)
- Add code to docs code blocks, but with a hint to remove it when
rendering the markdown as HTML
   ```tsx
   import { App } from "fresh";
   // #docs-start

   // Everything above marker above is trimmed away
   const app = new App();
   ```
- Add a `types.d.ts` with "global" types used during type checking, so
globals, imports and so on can be handled globally

I do think that some examples probably should be more explicit with
imports, but it would be overkill for a lot of places such as `app.md`
and `context.md`.
2025-08-05 23:56:04 +02:00
Christian Svensson e014d80a0f docs: add canary docs for <head> modifications (#3173)
Adds v2 version of "Modyfing the <head>" example. This is the next to
last page that needs to be updated (though the other only requires minor
changes to types).
2025-08-05 23:50:58 +02:00
Marvin Hagemeister 71b7d922ea fix: add deno compile entry (#3189)
Fixes https://github.com/denoland/fresh/issues/3123
2025-08-05 14:53:08 +02:00
Christian SvenssonandMarvin Hagemeister 57596dc406 feat: support passing URL to islands (#3181)
Adds support for passing `URL` values to Islands.

```tsx
// routes/index.html
export default function Page() {
  return <MyIsland url={new URL("https://fresh.deno.dev")} />;
}
```

Also updates documentation with some missing serialization features
(`undefined`, `Map`, `Set`, and `-0`).

---------

Co-authored-by: Marvin Hagemeister <hello@marvinh.dev>
2025-08-03 20:42:50 +02:00
Christian Svensson 24c86ea20e fix: correct anchors by using heading text only (#3167)
Addresses the issue mentioned in
https://github.com/denoland/fresh/pull/3163#discussion_r2246708003.

The issue was that the `raw` markdown was being used for e.g. `## My
title`, thus the slug became `-my-title` instead of `my-title`. Slugs
were working correctly for `codespan` in headers, e.g. ``## `someCode`
``.

I decided to hard error if unexpected heading syntax is used over
sluggifying unexpected content (can become super weird otherwise, e.g.
`## <button ...>My heading</button>`). I can revert to fallbacking to
`raw` if preferred, but perhaps with at least trimming leading `-` just
in case.
2025-08-01 12:46:12 +02:00
Christian Svensson a2de5154ec fix(docs): improve and increase consistency for code blocks (#3163)
Follow-up from #3162.

This PR does various tweaks, mostly related to code blocks.

- Adds missing titles to code blocks, and updates titles to be more
consistent
- Adds filenames to most ` ```tsx` blocks with e.g. `main.ts`, `dev.ts`
or a suitable example (e.g. `routes/greeting.tsx`) based on the code
- Adds filenames to ` ```diff` blocks if there's a relevant file, to
make the icon e.g. TS over Diff icon
  - Code blocks with Fresh code (e.g. interfaces) uses ` ```tsx fresh 🍋`
- Changes most ` ```sh` blocks with example terminal commands to ` ```sh
Terminal`
- Updates ` ```txt Project Structure` or ` ```diff Project Structure`
blocks to be more consistent
- Changes `sh` or `txt` to `txt-files` which improves highlighting and
makes icon consistent
- Renames `<project dir>` to `<project root>` to match builder `root`
option terminology
- Adds `<project root>` root folder to most/all overview folder
overviews
  - Makes the structure blocks more consistently displayed
- Tried to make some "bare" examples more complete

## Comparison

Here's a small curated set of before/after changes.

### Deployment

- `deno` highlighted in terminal commands
- `.gitignore` syntax highlighting works without using `sh` as language

<img width="1641" height="1009" alt="image"
src="https://github.com/user-attachments/assets/170cf833-1f6a-4b0d-8d2d-a081bc28a967"
/>

### File routing

Updated icon, comments same as before, but root and hierarchy have new
colors (`operator`/`function`).

<img width="1647" height="588" alt="image"
src="https://github.com/user-attachments/assets/f28db51b-4bee-45e4-be1c-e137a6d3ae3d"
/>
2025-08-01 09:07:42 +02:00
Christian Svensson c9b43ea32b feat(docs): add file/language type icons to code blocks (#3162)
I originally wanted to make it clearer the distinction between "files"
and e.g. `` ```tsx foo.tsx `` compared to `` ```sh Terminal `` or ``
```txt Project structure``. I originally started just trying to add a 📝
icon or something. But instead I ended showing file types of all
markdown languages.

I took the file type icons for the SVG's from
https://github.com/vscode-icons/vscode-icons, which has a MIT license.

I think the icons make it a even more clear what the language of the
code snippet is.

I have a follow-up PR for improving code block titles and making
examples more consistent in #3163.


## Comparisons

<details>

<summary><strong>Open &mdash; Before | After</strong></summary>


### TS + Shell icons - Hover tooltips and alt text

<img width="1504" height="639" alt="image"
src="https://github.com/user-attachments/assets/636838a3-f38c-4048-a536-52c1cdd6b6d4"
/>


### TS + Shell icons 2

<img width="1511" height="761" alt="image"
src="https://github.com/user-attachments/assets/2ad6d25c-3995-433a-ad93-162830ca55a1"
/>

### Shell + Dockerfile icons

<img width="1500" height="780" alt="image"
src="https://github.com/user-attachments/assets/88010749-d0d2-4498-9eb2-9bd971e48365"
/>

### Nested blocks + Git icon

<img width="1513" height="634" alt="image"
src="https://github.com/user-attachments/assets/400c27f8-d0b4-40bd-801d-611e1e8a8e36"
/>

</details>
2025-07-31 23:48:00 +02:00
Marvin Hagemeister 62f8bb008e docs: update Fresh 2 migration info (#3161) 2025-07-31 10:46:44 +02:00
Marvin Hagemeister 9d769f3cf1 feat: support setting production source maps on builder (#3151)
This adds a new `sourceMap` option on the `Builder` configuration. This
can be used to optionally specify how production source maps should be
generated.

See https://esbuild.github.io/api/#source-maps for more information.
2025-07-29 21:20:15 +02:00
Carlos GuzmanandMarvin Hagemeister 1218038918 docs: fix missing parentheses in about.tsx example file (#3143)
Co-authored-by: Marvin Hagemeister <hello@marvinh.dev>
2025-07-27 12:36:44 +02:00
e4d9160a92 docs: add daisyUI setup to examples (#3144)
Add a page to the docs on how to use https://daisyui.com/ with Fresh. 
---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-07-26 12:28:02 +00:00
Marvin Hagemeister b4e4a0c0f0 docs: update more pages for Fresh 2 (#3141) 2025-07-25 19:04:08 +02:00
Marvin Hagemeister c9c85ba36d docs: add page for define helpers (#3139) 2025-07-25 18:57:39 +02:00