diff --git a/v3-docs/docs/.vitepress/config.mts b/v3-docs/docs/.vitepress/config.mts index 66de626a3c..eb965e2dcb 100644 --- a/v3-docs/docs/.vitepress/config.mts +++ b/v3-docs/docs/.vitepress/config.mts @@ -44,7 +44,7 @@ export default defineConfig({ { text: 'Tutorials', items: [ - { text: 'Meteor.js 3 + Vue.js 3', link: '/tutorials/meteorjs-vue' }, + { text: 'Meteor.js 3 + Vue', link: '/tutorials/meteorjs-vue' }, ] }, ] diff --git a/v3-docs/docs/tutorials/meteorjs-vue.md b/v3-docs/docs/tutorials/meteorjs-vue.md index f9c258cc89..ef04464b21 100644 --- a/v3-docs/docs/tutorials/meteorjs-vue.md +++ b/v3-docs/docs/tutorials/meteorjs-vue.md @@ -1,4 +1,4 @@ -# Meteor.js 3 + Vue.js 3 Tutorial +# Meteor.js 3 + Vue Tutorial In this tutorial, we will create a simple To-Do app using [Vue 3](https://vuejs.org/) and Meteor 3.0. Meteor works well with other frameworks like [Blaze](https://www.blazejs.org/), [React](https://react.dev/), [Solid](https://www.solidjs.com/), and [Svelte](https://svelte.dev/). @@ -8,6 +8,10 @@ To start building your Vue.js app, you'll need a code editor. If you're unsure w Let’s begin building your app! +# Table of Contents + +[[toc]] + ## 1: Creating the app ### 1.1: Install Meteor.js @@ -53,9 +57,8 @@ Let's remove some unnecessary files for a cleaner start. Keep only `App.vue`, `m Next, update `router.js` to remove references to the deleted components: -`imports/ui/router.js` - -```javascript +::: code-group +```javascript [imports/ui/router.js] import { createRouter, createWebHistory } from 'vue-router'; import App from './App.vue'; @@ -70,21 +73,21 @@ export const router = createRouter({ ], }); ``` +::: This file is where you set up your routes and decide which component to render for each path. Also, update the App component since some components no longer exist. -`imports/ui/App.vue` - -```vue +::: code-group +```vue [imports/ui/App.vue] ``` - +::: ### 1.4: Creating Sample Tasks @@ -94,9 +97,8 @@ We’ll create our Vue components in the `imports/ui/components` folder. Start b This file will export a Vue component called `Task`, representing an individual task in your To-Do list. -`imports/ui/components/Task.vue` - -```vue +::: code-group +```vue [imports/ui/components/Task.vue] ``` - +::: Inside the function, we are adding a task to the `tasks` collection by calling `Meteor.callAsync()`. The first argument is the name of the method we want to call, and the second argument is the text of the task. We are also trimming the text to remove any extra spaces. @@ -469,9 +467,9 @@ Inside the function, we are adding a task to the `tasks` collection by calling ` Now, you just need to make a change which will improve user experience: we will show the newest tasks first. We can accomplish this quickly by sorting our [MongoDB](https://guide.meteor.com/collections.html#mongo-collections) query. -`imports/ui/App.vue` -```javascript +::: code-group +```javascript [imports/ui/App.vue] ... const tasks = autorun(() => { @@ -480,7 +478,7 @@ const tasks = autorun(() => { ... ``` - +::: Your app should look like this: @@ -500,9 +498,8 @@ To do this, we need to add a `ref` to the task document. This will allow us to a We also have a prop called `task` that is passed to the component. This prop is an object that represents the task document. -`imports/ui/components/Task.vue` - -```vue +::: code-group +```vue [imports/ui/components/Task.vue] ... ``` +::: Now, we need to update the list of tasks to filter out completed tasks when `hideCompleted` is `true`. @@ -829,9 +817,9 @@ Update the App component in order to show the number of pending tasks in the app You should avoid adding zero to your app bar when there are no pending tasks. -`imports/ui/App.vue` -```vue +::: code-group +```vue [imports/ui/App.vue] ``` - +::: ### 7.8: Log out We can include a new `button` right after our `h1`. On this button you can add an `onClick` handler to logout the user. It is very straightforward, just call `Meteor.logout()` on it. -`imports/ui/App.vue` -```vue +::: code-group +```vue [imports/ui/App.vue]