From 4042d473467192a794f9616727b0f964d65da562 Mon Sep 17 00:00:00 2001 From: Reed von Redwitz Date: Mon, 30 Oct 2023 18:01:27 +0100 Subject: [PATCH] docs: update using twindv1 page (#1982) --- docs/latest/examples/using-twind-v1.md | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/latest/examples/using-twind-v1.md b/docs/latest/examples/using-twind-v1.md index 0577bead..2aad8898 100644 --- a/docs/latest/examples/using-twind-v1.md +++ b/docs/latest/examples/using-twind-v1.md @@ -13,37 +13,46 @@ you'll end up with a `main.ts` like the following: /// /// +import "$std/dotenv/load.ts"; + import { start } from "$fresh/server.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 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 -v1 you can follow this guide. First of all, change the import path to use the -`twindv1` plugin: +Let's bump that up to v1: -```ts main.ts -/// -/// -/// -/// -/// +```diff +diff --git a/fresh.config.ts b/fresh.config.ts +index 548e16a..e00d557 100644 +--- a/fresh.config.ts ++++ b/fresh.config.ts +@@ -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"; -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)] }); + export default defineConfig({ ``` -The twind config object has changed significantly in v1, so we must also go -change `twind.config.ts`. A good base looks like this: +The twind config object has changed significantly in v1, so we must also change +`twind.config.ts`. A good base looks like this (just replace whatever is there +with this): ```ts twind.config.ts import { defineConfig, Preset } from "https://esm.sh/@twind/core@1.1.3";