docs: update using twindv1 page (#1982)

This commit is contained in:
Reed von Redwitz
2023-10-30 18:01:27 +01:00
committed by GitHub
parent f39e0d4218
commit 4042d47346
+28 -19
View File
@@ -13,37 +13,46 @@ you'll end up with a `main.ts` like the following:
/// <reference lib="dom.asynciterable" /> /// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" /> /// <reference lib="deno.ns" />
import "$std/dotenv/load.ts";
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import config from "./fresh.config.ts";
await start(manifest, config);
```
And the Fresh config is like this:
```ts fresh.config.ts
import { defineConfig } from "$fresh/server.ts";
import twindPlugin from "$fresh/plugins/twind.ts"; import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "./twind.config.ts"; import twindConfig from "./twind.config.ts";
await start(manifest, { plugins: [twindPlugin(twindConfig)] }); export default defineConfig({
plugins: [twindPlugin(twindConfig)],
});
``` ```
The template generates a Twind v0 project by default. If you want to use Twind Let's bump that up to v1:
v1 you can follow this guide. First of all, change the import path to use the
`twindv1` plugin:
```ts main.ts ```diff
/// <reference no-default-lib="true" /> diff --git a/fresh.config.ts b/fresh.config.ts
/// <reference lib="dom" /> index 548e16a..e00d557 100644
/// <reference lib="dom.iterable" /> --- a/fresh.config.ts
/// <reference lib="dom.asynciterable" /> +++ b/fresh.config.ts
/// <reference lib="deno.ns" /> @@ -1,5 +1,5 @@
import { defineConfig } from "$fresh/server.ts";
-import twindPlugin from "$fresh/plugins/twind.ts";
+import twindPlugin from "$fresh/plugins/twindv1.ts";
import twindConfig from "./twind.config.ts";
import { start } from "$fresh/server.ts"; export default defineConfig({
import manifest from "./fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twindv1.ts";
import twindConfig from "./twind.config.ts";
await start(manifest, { plugins: [twindPlugin(twindConfig)] });
``` ```
The twind config object has changed significantly in v1, so we must also go The twind config object has changed significantly in v1, so we must also change
change `twind.config.ts`. A good base looks like this: `twind.config.ts`. A good base looks like this (just replace whatever is there
with this):
```ts twind.config.ts ```ts twind.config.ts
import { defineConfig, Preset } from "https://esm.sh/@twind/core@1.1.3"; import { defineConfig, Preset } from "https://esm.sh/@twind/core@1.1.3";