tutorial links in text files

pull/7038/head
Ignatius Bagus 5 years ago
parent db65cd7191
commit 670f92b1b0
No known key found for this signature in database
GPG Key ID: 357C6674A45CC06B

@ -4,7 +4,7 @@ title: Basics
Welcome to the Svelte tutorial. This will teach you everything you need to know to build fast, small web applications easily. Welcome to the Svelte tutorial. This will teach you everything you need to know to build fast, small web applications easily.
You can also consult the [API docs](docs) and the [examples](examples), or — if you're impatient to start hacking on your machine locally — the [60-second quickstart](blog/the-easiest-way-to-get-started). You can also consult the [API docs](/docs) and the [examples](/examples), or — if you're impatient to start hacking on your machine locally — the [60-second quickstart](/blog/the-easiest-way-to-get-started).
## What is Svelte? ## What is Svelte?

@ -12,9 +12,9 @@ First, you'll need to integrate Svelte with a build tool. There are officially m
...and a variety of [community-maintained ones](https://sveltesociety.dev/tools). ...and a variety of [community-maintained ones](https://sveltesociety.dev/tools).
Don't worry if you're relatively new to web development and haven't used these tools before. We've prepared a simple step-by-step guide, [Svelte for new developers](blog/svelte-for-new-developers), which walks you through the process. Don't worry if you're relatively new to web development and haven't used these tools before. We've prepared a simple step-by-step guide, [Svelte for new developers](/blog/svelte-for-new-developers), which walks you through the process.
You'll also want to configure your text editor. There are [plugins](https://sveltesociety.dev/tools#editor-support) for many popular editors as well as an official [VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If your editor does not have a Svelte plugin then you can follow [this guide](blog/setting-up-your-editor) to configure your text editor to treat `.svelte` files the same as `.html` for the sake of syntax highlighting. You'll also want to configure your text editor. There are [plugins](https://sveltesociety.dev/tools#editor-support) for many popular editors as well as an official [VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If your editor does not have a Svelte plugin then you can follow [this guide](/blog/setting-up-your-editor) to configure your text editor to treat `.svelte` files the same as `.html` for the sake of syntax highlighting.
Then, once you've got your project set up, using Svelte components is easy. The compiler turns each component into a regular JavaScript class — just import it and instantiate with `new`: Then, once you've got your project set up, using Svelte components is easy. The compiler turns each component into a regular JavaScript class — just import it and instantiate with `new`:
@ -30,4 +30,4 @@ const app = new App({
}); });
``` ```
You can then interact with `app` using the [component API](docs#run-time-client-side-component-api) if you need to. You can then interact with `app` using the [component API](/docs#run-time-client-side-component-api) if you need to.

@ -4,7 +4,7 @@ title: Event forwarding
Unlike DOM events, component events don't *bubble*. If you want to listen to an event on some deeply nested component, the intermediate components must *forward* the event. Unlike DOM events, component events don't *bubble*. If you want to listen to an event on some deeply nested component, the intermediate components must *forward* the event.
In this case, we have the same `App.svelte` and `Inner.svelte` as in the [previous chapter](tutorial/component-events), but there's now an `Outer.svelte` component that contains `<Inner/>`. In this case, we have the same `App.svelte` and `Inner.svelte` as in the [previous chapter](/tutorial/component-events), but there's now an `Outer.svelte` component that contains `<Inner/>`.
One way we could solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it: One way we could solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it:

@ -4,7 +4,7 @@ title: Select multiple
A select can have a `multiple` attribute, in which case it will populate an array rather than selecting a single value. A select can have a `multiple` attribute, in which case it will populate an array rather than selecting a single value.
Returning to our [earlier ice cream example](tutorial/group-inputs), we can replace the checkboxes with a `<select multiple>`: Returning to our [earlier ice cream example](/tutorial/group-inputs), we can replace the checkboxes with a `<select multiple>`:
```html ```html
<h2>Flavours</h2> <h2>Flavours</h2>

@ -12,4 +12,4 @@ The readonly `this` binding applies to every element (and component) and allows
></canvas> ></canvas>
``` ```
Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](tutorial/onmount). Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](/tutorial/onmount).

@ -4,7 +4,7 @@ title: onMount
Every component has a *lifecycle* that starts when it is created, and ends when it is destroyed. There are a handful of functions that allow you to run code at key moments during that lifecycle. Every component has a *lifecycle* that starts when it is created, and ends when it is destroyed. There are a handful of functions that allow you to run code at key moments during that lifecycle.
The one you'll use most frequently is `onMount`, which runs after the component is first rendered to the DOM. We briefly encountered it [earlier](tutorial/bind-this) when we needed to interact with a `<canvas>` element after it had been rendered. The one you'll use most frequently is `onMount`, which runs after the component is first rendered to the DOM. We briefly encountered it [earlier](/tutorial/bind-this) when we needed to interact with a `<canvas>` element after it had been rendered.
We'll add an `onMount` handler that loads some data over the network: We'll add an `onMount` handler that loads some data over the network:

@ -13,7 +13,7 @@ const unsubscribe = count.subscribe(value => {
``` ```
> Calling a `subscribe` method returns an `unsubscribe` function. > Calling a `subscribe` method returns an `unsubscribe` function.
You now declared `unsubscribe`, but it still needs to be called, for example through the `onDestroy` [lifecycle hook](tutorial/ondestroy): You now declared `unsubscribe`, but it still needs to be called, for example through the `onDestroy` [lifecycle hook](/tutorial/ondestroy):
```html ```html
<script> <script>

@ -11,4 +11,4 @@ export const elapsed = derived(
); );
``` ```
> It's possible to derive a store from multiple inputs, and to explicitly `set` a value instead of returning it (which is useful for deriving values asynchronously). Consult the [API reference](docs#run-time-svelte-store-derived) for more information. > It's possible to derive a store from multiple inputs, and to explicitly `set` a value instead of returning it (which is useful for deriving values asynchronously). Consult the [API reference](/docs#run-time-svelte-store-derived) for more information.

@ -23,7 +23,7 @@ The function takes two arguments — the node to which the transition is applied
* `delay` — milliseconds before the transition begins * `delay` — milliseconds before the transition begins
* `duration` — length of the transition in milliseconds * `duration` — length of the transition in milliseconds
* `easing` — a `p => t` easing function (see the chapter on [tweening](tutorial/tweened)) * `easing` — a `p => t` easing function (see the chapter on [tweening](/tutorial/tweened))
* `css` — a `(t, u) => css` function, where `u === 1 - t` * `css` — a `(t, u) => css` function, where `u === 1 - t`
* `tick` — a `(t, u) => {...}` function that has some effect on the node * `tick` — a `(t, u) => {...}` function that has some effect on the node

@ -2,7 +2,7 @@
title: The animate directive title: The animate directive
--- ---
In the [previous chapter](tutorial/deferred-transitions), we used deferred transitions to create the illusion of motion as elements move from one todo list to the other. In the [previous chapter](/tutorial/deferred-transitions), we used deferred transitions to create the illusion of motion as elements move from one todo list to the other.
To complete the illusion, we also need to apply motion to the elements that *aren't* transitioning. For this, we use the `animate` directive. To complete the illusion, we also need to apply motion to the elements that *aren't* transitioning. For this, we use the `animate` directive.

@ -19,7 +19,7 @@ setContext(key, {
}); });
``` ```
The context object can be anything you like. Like [lifecycle functions](tutorial/onmount), `setContext` and `getContext` must be called during component initialisation. Calling it afterwards - for example inside `onMount` - will throw an error. In this example, since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself. The context object can be anything you like. Like [lifecycle functions](/tutorial/onmount), `setContext` and `getContext` must be called during component initialisation. Calling it afterwards - for example inside `onMount` - will throw an error. In this example, since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself.
On the other side of the equation, in `MapMarker.svelte`, we can now get a reference to the Mapbox instance: On the other side of the equation, in `MapMarker.svelte`, we can now get a reference to the Mapbox instance:

@ -10,4 +10,4 @@ On line 11, add the `keydown` listener:
<svelte:window on:keydown={handleKeydown}/> <svelte:window on:keydown={handleKeydown}/>
``` ```
> As with DOM elements, you can add [event modifiers](tutorial/event-modifiers) like `preventDefault`. > As with DOM elements, you can add [event modifiers](/tutorial/event-modifiers) like `preventDefault`.

@ -6,7 +6,7 @@ The `<svelte:head>` element allows you to insert elements inside the `<head>` of
```html ```html
<svelte:head> <svelte:head>
<link rel="stylesheet" href="tutorial/dark-theme.css"> <link rel="stylesheet" href="/tutorial/dark-theme.css">
</svelte:head> </svelte:head>
``` ```

@ -27,4 +27,4 @@ The options that can be set here are:
* `namespace="..."` — the namespace where this component will be used, most commonly `"svg"` * `namespace="..."` — the namespace where this component will be used, most commonly `"svg"`
* `tag="..."` — the name to use when compiling this component as a custom element * `tag="..."` — the name to use when compiling this component as a custom element
Consult the [API reference](docs) for more information on these options. Consult the [API reference](/docs) for more information on these options.

@ -2,10 +2,10 @@
title: Congratulations! title: Congratulations!
--- ---
You've now finished the Svelte tutorial and are ready to start building apps. You can refer back to individual chapters at any time (click the title above to reveal a dropdown) or continue your learning via the [API reference](docs), [Examples](examples) and [Blog](blog). If you're a Twitter user, you can get updates via [@sveltejs](https://twitter.com/sveltejs). You've now finished the Svelte tutorial and are ready to start building apps. You can refer back to individual chapters at any time (click the title above to reveal a dropdown) or continue your learning via the [API reference](/docs), [Examples](/examples) and [Blog](/blog). If you're a Twitter user, you can get updates via [@sveltejs](https://twitter.com/sveltejs).
To get set up in your local development environment, check out [the quickstart guide](blog/the-easiest-way-to-get-started). To get set up in your local development environment, check out [the quickstart guide](/blog/the-easiest-way-to-get-started).
If you're looking for a more expansive framework that includes routing, server-side rendering and everything else, take a look at [SvelteKit](https://kit.svelte.dev). If you're looking for a more expansive framework that includes routing, server-side rendering and everything else, take a look at [SvelteKit](https://kit.svelte.dev).
Most importantly: since you're now a member of the Svelte community, you should [join our friendly Discord chatroom](chat). That's where you'll find fellow Svelte users, and it's where we plan the future of the framework. Most importantly: since you're now a member of the Svelte community, you should [join our friendly Discord chatroom](/chat). That's where you'll find fellow Svelte users, and it's where we plan the future of the framework.

Loading…
Cancel
Save