Migrating from Gridsome
Это содержимое пока не доступно на вашем языке.
Gridsome is an open-source static site generator built on Vue and GraphQL.
Key Similarities between Gridsome and Astro
Section titled Key Similarities between Gridsome and AstroGridsome and Astro share some similarities that will help you migrate your project:
-
Both Gridsome and Astro are modern JavaScript static-site generators with similar project file structures.
-
Both Gridsome and Astro use a
src/
folder for your project files and a specialsrc/pages/
folder for file-based routing. Creating and managing pages for your site should feel familiar. -
Astro has an official integration for using Vue components and supports installing NPM packages, including several for Vue. You will be able to write Vue UI components, and may be able to keep some or all of your existing Gridsome Vue components and dependencies.
-
Astro and Gridsome both allow you to use a headless CMS, APIs or Markdown files for data. You can continue to use your preferred content authoring system, and will be able to keep your existing content.
Key Differences between Gridsome and Astro
Section titled Key Differences between Gridsome and AstroWhen you rebuild your Gridsome site in Astro, you will notice some important differences:
-
Gridsome is a Vue-based single-page application (SPA). Astro sites are multi-page apps built using
.astro
components, but can also support React, Preact, Vue.js, Svelte, SolidJS, AlpineJS and raw HTML templating. -
As an SPA, Gridsome uses
vue-router
for SPA routing, andvue-meta
for managing<head>
. In Astro, you will create separate HTML pages and control your page<head>
directly, or in a layout component. -
Local file data: Gridsome uses GraphQL to retrieve data from your project files. Astro uses ESM imports and
import.meta.glob()
to import data from local project files. Remote resources can be loaded using the standardfetch()
API. GraphQL may be optionally added to your project, but is not included by default.
Switch from Gridsome to Astro
Section titled Switch from Gridsome to AstroTo convert a Gridsome blog to Astro, start with our blog theme starter template, or explore more community blog themes in our theme showcase.
You can pass a --template
argument to the create astro
command to start a new Astro project with one of our official starters. Or, you can start a new project from any existing Astro repository on GitHub.
Bring your existing Markdown (or MDX, with our optional integration) files as content to create Markdown or MDX pages.
Since Gridsome’s project structure is similar to Astro’s, you may be able to copy several existing files from your project into the same location in your new Astro project. However, the two project structures are not identical. You may want to examine Astro’s project structure to see what the differences are.
Since Astro queries and imports your local files differently than Gridsome, you may want to read about how to load files using import.meta.glob()
to understand how to work with your local files.
To convert other types of sites, such as a portfolio or documentation site, see more official starter templates on astro.new. You’ll find a link to each project’s GitHub repository, as well as one-click links to open a working project in IDX, StackBlitz, CodeSandbox and Gitpod online development environments.
Community Resources
Section titled Community Resources- Blog Post: Migration from Gridsome to Astro.