Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Migrate from Nuxt to Astro

  • Navigate between page

since we no longer use vue-router plugins. so component / pages that using useNavigate must remote it and change how to redirect. we can redirect to another page use HTML <a href or use window.location.href . this redirect will perform full page refresh

to keep migration as little as possible we keep using pinia as our main store state management. but there is little syntax change to share state between componnet.

  1. import appStore

  1. call appStore on store initialization

since we no longer use vue-i18n plugin, we write our function to translate a string. it's located at src/service/common/language.ts

the syntax is almost same with we have in nuxt project

  •   *   **Defining global function / listener**
    
    In nuxt project, for example in home page we have components Home.vue as parent that wrap other component. usually we put some shared function / global function for that in that component. now in astro project a parent component must be astro file and it have very different functionality ( can't handle vue emit events from it's children and can't use pinia store) . so the solution where we store global function is to create entry component