Commit Graph
39 Commits
Author SHA1 Message Date
Marvin Hagemeister fe4a59a88c feat: support custom server entry (#3216) 2025-08-12 12:50:10 +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 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 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
Marvin Hagemeister b4e4a0c0f0 docs: update more pages for Fresh 2 (#3141) 2025-07-25 19:04:08 +02:00
Marvin Hagemeister 3ad3e6ecf3 feat: support lazily loading routes/handlers (#3131)
We can improve cold start times by only loading route modules when the particular pattern matches. This PR introduces the concept of lazy middlewares, routes and handlers to do that.
2025-07-25 14:33:28 +02:00
Marvin Hagemeister 659d7687f0 docs: add builder docs (#3130) 2025-07-24 22:18:23 +02:00
Marvin Hagemeister 41b11de470 docs: update fs route (#3125) 2025-07-24 15:34:51 +02:00
Marvin Hagemeister 39737b4530 fix: write matched pattern into ctx.route (#3113)
Fixes https://github.com/denoland/fresh/issues/3112
2025-07-18 22:38:56 +02:00
Marvin Hagemeister a703e79181 docs: update canary docs for Fresh 2 (#3108)
There are still some rough edges here and there, but it's in a much
better shape than what we have today.
2025-07-18 15:18:38 +02:00
Marvin Hagemeister dace008611 chore: release 1.6.0 (#2113) 2023-12-01 16:20:40 +01:00
Marvin Hagemeister bd372b9535 fix: errors in plugin fixture + improve island docs (#2109) 2023-12-01 12:21:10 +01:00
Reed von RedwitzandMarvin Hagemeister 9ab8651018 feat(server): Add basePath config to host from a directory (#2092)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-11-29 16:44:25 +00:00
Reed von Redwitz 72edafde46 feat(server): plugins can create islands (#1472) 2023-11-22 11:19:13 +01:00
Marvin HagemeisterandAdam Gregory 7ff2781fcd feat: allow plugins to modify HTML body (#2022)
Based on https://github.com/denoland/fresh/pull/1769 . Mostly added a
test.

---------

Co-authored-by: Adam Gregory <adam@aguilaengineering.com>
2023-11-10 13:59:41 +01:00
Adam Gregory 14cecc0a6f Allow plugin render hooks to add link tags to the page (#1963)
Adds an extra optional property to plugin render results to allow
plugins to add `<link>` tags to the page.
2023-11-08 23:51:14 +01:00
Adam GregoryandMarvin Hagemeister 264f3073bd Support AOT-built static assets (#1999)
Creates a static folder under `config.build.outDir` during AOT build.
Serves any static files that are found there.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-11-04 14:01:21 +01:00
Reed von Redwitz f39e0d4218 feat(server): throwing Deno.errors.NotFound triggers 404 (#1984) 2023-10-30 18:00:57 +01:00
Marvin Hagemeister fe2c95cc25 chore: release 1.5.0 (#1899) 2023-10-10 18:08:44 +02:00
Marvin Hagemeister 21fcf6169b docs: add partials documentation (#1878) 2023-10-06 22:55:54 +02:00
Marvin Hagemeister e9717ed911 fix: meta charSet -> charset (#1875) 2023-10-06 15:59:13 +02:00
Marvin Hagemeister f8fb61e943 feat: ask for project arg if missing on update (#1821) 2023-09-26 20:48:47 +02:00
Marvin Hagemeister c175e28bf3 chore: release 1.4.0 (#1639) 2023-08-16 17:35:29 +02:00
Marvin Hagemeister 477364c567 feat: prebundle code + restore from snapshot (#1604) 2023-08-16 16:47:51 +02:00
Marvin HagemeisterandReed von Redwitz b2362da281 www: Various documentation improvements (#1635)
Co-authored-by: Reed von Redwitz <reed+github@vonredwitz.com>
2023-08-16 16:24:53 +02:00
Marvin Hagemeister 6a599dbed5 www: new fenced code block design (#1629) 2023-08-13 10:52:41 +02:00
Marvin Hagemeister 7ebaf0404d feat: allow layout and _app overrides (#1611) 2023-08-09 16:35:53 +00:00
Marvin Hagemeister e4d797ae4e feat: add support for route groups (#1563) 2023-08-02 09:51:20 +02:00
Michael GearhardtandMarvin Hagemeister 1ed93cec88 feat: support route layouts via _layout.tsx (#1506)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-07-26 11:49:08 +02:00
Marvin Hagemeister 38d4b90091 fix: middleware state reset between middlewares (#1500) 2023-07-24 11:03:11 +02:00
Marvin Hagemeister 2575ca5cad chore: release 1.3.0 (#1460) 2023-07-18 18:09:13 +02:00
Marvin Hagemeister b3c22384e0 www: add docs for async route components (#1475) 2023-07-18 17:44:04 +02:00
Marvin Hagemeister f12c96ed45 feat: add upgrade check (#1444) 2023-07-17 15:49:47 +02:00
Lino Le VanandMarvin Hagemeister e2a1bf8643 feat: move to Deno.serve (#1427)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-07-12 14:37:53 +02:00
Reed von Redwitz 724c81f2c7 feat(server): middleware params (#1314) 2023-07-10 15:06:43 +02:00
Reed von Redwitz f737e1c4e3 www: cleanup miscellaneous doc items (#1419) 2023-07-07 16:07:40 +02:00