]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: add Vue school links (#980)
authorDaniel Kelly <me@danielkelly.io>
Fri, 4 Jun 2021 07:37:04 +0000 (02:37 -0500)
committerGitHub <noreply@github.com>
Fri, 4 Jun 2021 07:37:04 +0000 (09:37 +0200)
docs/.vitepress/components/VueSchoolLink.vue [new file with mode: 0644]
docs/.vitepress/theme/index.js
docs/guide/advanced/lazy-loading.md
docs/guide/advanced/transitions.md
docs/guide/essentials/dynamic-matching.md
docs/guide/essentials/history-mode.md
docs/guide/essentials/named-routes.md
docs/guide/essentials/nested-routes.md
docs/guide/essentials/passing-props.md

diff --git a/docs/.vitepress/components/VueSchoolLink.vue b/docs/.vitepress/components/VueSchoolLink.vue
new file mode 100644 (file)
index 0000000..8a6ef5d
--- /dev/null
@@ -0,0 +1,59 @@
+<template>
+  <div class="vueschool">
+    <a
+      :href="`${href}?friend=vuerouter`"
+      target="_blank"
+      rel="sponsored noopener"
+      :title="title"
+    >
+      <slot>Watch a free video lesson on Vue School</slot>
+    </a>
+  </div>
+</template>
+<script>
+export default {
+  props: {
+    href: { type: String, required: true },
+    title: { type: String, required: true }
+  },
+}
+</script>
+<style scoped>
+.vueschool {
+  margin-top: 20px;
+  background-color: #e7ecf3;
+  padding: 1em 1.25em;
+  border-radius: 2px;
+  color: #486491;
+  position: relative;
+  display: flex;
+}
+.vueschool a {
+  color: #486491 !important;
+  position: relative;
+  padding-left: 36px;
+}
+.vueschool a:before {
+  content: '';
+  position: absolute;
+  display: block;
+  width: 30px;
+  height: 30px;
+  top: calc(50% - 15px);
+  left: -4px;
+  border-radius: 50%;
+  background-color: #73abfe;
+}
+.vueschool a:after {
+  content: '';
+  position: absolute;
+  display: block;
+  width: 0;
+  height: 0;
+  top: calc(50% - 5px);
+  left: 8px;
+  border-top: 5px solid transparent;
+  border-bottom: 5px solid transparent;
+  border-left: 8px solid #fff;
+}
+</style>
index 323bb5f3da45211c36293029ac6aec227e03732f..21fb2394188f7bdc18925bae83d88e9b39de7083 100644 (file)
@@ -1,10 +1,12 @@
 import DefaultTheme from 'vitepress/dist/client/theme-default'
 import Layout from './Layout.vue'
+import VueSchoolLink from '../components/VueSchoolLink.vue'
 
 export default {
   ...DefaultTheme,
   Layout,
   enhanceApp({ app, router, siteData }) {
+    app.component('VueSchoolLink', VueSchoolLink)
     // app is the Vue 3 app instance from createApp()
     // router is VitePress' custom router (see `lib/app/router.js`)
     // siteData is a ref of current site-level metadata.
index 71bf16775ba3a925d0d9c06722beba4a1aedaf80..911528fc71baf397ae8d4f98fd8820cd3d07a5ef 100644 (file)
@@ -1,5 +1,10 @@
 # Lazy Loading Routes
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/lazy-loading-routes-vue-cli-only"
+  title="Learn about lazy loading routes"
+/>
+
 When building apps with a bundler, the JavaScript bundle can become quite large, and thus affect the page load time. It would be more efficient if we can split each route's components into a separate chunks, and only load them when the route is visited.
 
 Vue Router supports [dynamic imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports) out of the box, meaning you can replace static imports with dynamic ones:
index 817efdbbe144651e9473133b93b8b8a1e688e72e..ccfaddf657e71c87171c05e95e4ec004843c8669 100644 (file)
@@ -1,5 +1,10 @@
 # Transitions
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/route-transitions"
+  title="Learn about route transitions"
+/>
+
 In order to use transitions on your route components and animate navigations, you need to use the [v-slot API](../../api/#router-view-s-v-slot):
 
 ```html
index a3b31b74cb35bdb6ca4dbdd87b982c40b9171640..1240151b35835e2dc983f945c7de63f1475757c1 100644 (file)
@@ -1,5 +1,10 @@
 # Dynamic Route Matching with Params
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/dynamic-routes"
+  title="Learn about dynamic route matching with params"
+/>
+
 Very often we will need to map routes with the given pattern to the same component. For example we may have a `User` component which should be rendered for all users but with different user IDs. In Vue Router we can use a dynamic segment in the path to achieve that, we call that a _param_:
 
 ```js
@@ -45,6 +50,11 @@ A working demo of this example can be found [here](https://codesandbox.io/s/rout
 
 ## Reacting to Params Changes
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/reacting-to-param-changes"
+  title="Learn how to react to param changes"
+/>
+
 One thing to note when using routes with params is that when the user navigates from `/users/johnny` to `/users/jolyne`, **the same component instance will be reused**. Since both routes render the same component, this is more efficient than destroying the old instance and then creating a new one. **However, this also means that the lifecycle hooks of the component will not be called**.
 
 To react to params changes in the same component, you can simply watch anything on the `$route` object, in this scenario, the `$route.params`:
@@ -77,6 +87,11 @@ const User = {
 
 ## Catch all / 404 Not found Route
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/404-not-found-page"
+  title="Learn how to make a catch all/404 not found route"
+/>
+
 Regular params will only match characters in between url fragments, separated by `/`. If we want to match **anything**, we can use a custom _param_ regexp by adding the regexp inside parentheses right after the _param_:
 
 ```js
index e3f8fa8e6ef7fd6870f3d894ead31f6eb22cb1c3..1747647321f3115a8fea40b3e8e162e6550625a2 100644 (file)
@@ -1,5 +1,10 @@
 # Different History modes
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/history-mode"
+  title="Learn about the differences between Hash Mode and HTML5 Mode"
+/>
+
 The `history` option when creating the router instance allows us to choose among different history modes.
 
 ## Hash Mode
index b02a93a82ca0d1a3a5d2f2fdf943c1e2c6d4cc12..3580ad6ad46cb5c04ace22c76c357ba92a68cd7c 100644 (file)
@@ -1,5 +1,10 @@
 # Named Routes
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/named-routes"
+  title="Learn about the named routes"
+/>
+
 Alongside the `path`, you can provide a `name` to any route. This has the following advantages:
 
 - No hardcoded URLs
index 4f0e17e5790bb36445888278bf38af98f949258e..7e7b6eb30ace3ca8880022590289a7ccba8605c2 100644 (file)
@@ -1,5 +1,10 @@
 # Nested Routes
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/nested-routes"
+  title="Learn about nested routes"
+/>
+
 Some application's UIs are composed of components that are nested multiple levels deep. In this case, it is very common that the segments of a URL corresponds to a certain structure of nested components, for example:
 
 ```
index e1d9a584a7b3e8532e7b6dc6b19e5d107d5b355d..62a56f6016140b3635602b5d83b481552f954a58 100644 (file)
@@ -1,5 +1,10 @@
 # Passing Props to Route Components
 
+<VueSchoolLink 
+  href="https://vueschool.io/lessons/route-props"
+  title="Learn how to pass props to route components"
+/>
+
 Using `$route` in your component creates a tight coupling with the route which limits the flexibility of the component as it can only be used on certain URLs. While this is not necessarily a bad thing, we can decouple this behavior with a `props` option:
 
 We can replace