docs(examples): Using twind v1 + fix md code syntax highlighting (#1271)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
This commit is contained in:
co-authored by
Luca Casonato
parent
219ab574db
commit
83925cc1e3
@@ -6,7 +6,7 @@ description: |
|
|||||||
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||||
you'll end up with a `main.ts` like the following:
|
you'll end up with a `main.ts` like the following:
|
||||||
|
|
||||||
```
|
```ts
|
||||||
/// <reference no-default-lib="true" />
|
/// <reference no-default-lib="true" />
|
||||||
/// <reference lib="dom" />
|
/// <reference lib="dom" />
|
||||||
/// <reference lib="dom.iterable" />
|
/// <reference lib="dom.iterable" />
|
||||||
@@ -26,7 +26,7 @@ This is a great start if your site is in English, but let's say you want to
|
|||||||
change the language, as per the `<html lang=asdf>` tag. Then you'll need to do
|
change the language, as per the `<html lang=asdf>` tag. Then you'll need to do
|
||||||
something like this:
|
something like this:
|
||||||
|
|
||||||
```
|
```ts
|
||||||
/// <reference no-default-lib="true" />
|
/// <reference no-default-lib="true" />
|
||||||
/// <reference lib="dom" />
|
/// <reference lib="dom" />
|
||||||
/// <reference lib="dom.iterable" />
|
/// <reference lib="dom.iterable" />
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
description: |
|
||||||
|
With a few tweaks one can use twind v1
|
||||||
|
---
|
||||||
|
|
||||||
|
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||||
|
you'll end up with a `main.ts` like the following:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/// <reference no-default-lib="true" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
/// <reference lib="dom.iterable" />
|
||||||
|
/// <reference lib="dom.asynciterable" />
|
||||||
|
/// <reference lib="deno.ns" />
|
||||||
|
|
||||||
|
import { start } from "$fresh/server.ts";
|
||||||
|
import manifest from "./fresh.gen.ts";
|
||||||
|
|
||||||
|
import twindPlugin from "$fresh/plugins/twind.ts";
|
||||||
|
import twindConfig from "./twind.config.ts";
|
||||||
|
|
||||||
|
await start(manifest, { 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:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/// <reference no-default-lib="true" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
/// <reference lib="dom.iterable" />
|
||||||
|
/// <reference lib="dom.asynciterable" />
|
||||||
|
/// <reference lib="deno.ns" />
|
||||||
|
|
||||||
|
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)] });
|
||||||
|
```
|
||||||
|
|
||||||
|
The twind config object has changed significantly in v1, so we must also go
|
||||||
|
change `twind.config.ts`. A good base looks like this:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { defineConfig } from "https://esm.sh/@twind/core@1.1.3";
|
||||||
|
import presetTailwind from "https://esm.sh/@twind/preset-tailwind@1.1.4";
|
||||||
|
import presetAutoprefix from "https://esm.sh/@twind/preset-autoprefix@1.0.7";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...defineConfig({
|
||||||
|
presets: [presetTailwind(), presetAutoprefix()],
|
||||||
|
}),
|
||||||
|
selfURL: import.meta.url,
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
To see what other presets exist, you can go to the
|
||||||
|
[twind docs](https://twind.style/presets).
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
["setting-the-language", "Setting the language"],
|
["setting-the-language", "Setting the language"],
|
||||||
["writing-tests", "Writing tests"],
|
["writing-tests", "Writing tests"],
|
||||||
["changing-the-src-dir", "Changing the source directory"],
|
["changing-the-src-dir", "Changing the source directory"],
|
||||||
|
["using-twind-v1", "Using Twind v1"],
|
||||||
["init-the-server", "Initializing the server"],
|
["init-the-server", "Initializing the server"],
|
||||||
["using-fresh-canary-version", "Using Fresh canary version"]
|
["using-fresh-canary-version", "Using Fresh canary version"]
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user