doc: improve linking to external code docs (#6158)

This commit is contained in:
Chris Knight 2020-06-10 18:43:44 +01:00 committed by GitHub
parent be8bacaaa4
commit 1120dfe3f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 23 deletions

View file

@ -16,27 +16,26 @@ Current limitations:
Example:
```js
// import_map.json
**import_map.json**
```js
{
"imports": {
"http/": "https://deno.land/std/http/"
"fmt/": "https://deno.land/std@0.55.0/fmt/"
}
}
```
**color.ts**
```ts
// hello_server.ts
import { red } from "fmt/colors.ts";
import { serve } from "http/server.ts";
const body = new TextEncoder().encode("Hello World\n");
for await (const req of serve(":8000")) {
req.respond({ body });
}
console.log(red("hello world"));
```
Then:
```shell
$ deno run --allow-net --importmap=import_map.json --unstable hello_server.ts
$ deno run --importmap=import-map.json --unstable color.ts
```