现在你知道要构建什么,是时候设置你需要的所有工具了!
¥Now that you know what you’re going to build, it’s time to set up all the tools you’ll need!
本单元向你展示如何设置开发环境并部署到 Netlify。如果你已经熟悉自己的环境和工作流程,请跳至 单元 2 。
¥This unit shows you how to set up your development environment and deploy to Netlify. Skip ahead to Unit 2 if you are already comfortable with your environment and workflow.
Take the tutorial in an online code editor
Want to complete this tutorial in an online code editor instead? Follow the instructions below for getting started on Google IDX.
Using Google IDX: Follow these instructions, then go directly to Unit 2! Set up IDX
Follow the external link to open the “Empty Project” template in a new workspace on IDX .
Follow the prompt to log into your Google account if you are not already logged in.
Enter a name for your project if you want to change it from the default “Empty Project”. Click Create .
Wait for the workspace to be created. This may take 30 - 60 seconds. If all goes well, you will see the Astro project loaded in an online code editor.
Wait for IDX to run two scripts: one to install Astro and another to start the development server. Note that you may briefly see a message that your workspace “couldn’t find Astro” if your workspace loads before Astro has finished installing. This message can be ignored and cancelled if it does not clear itself.
Make a Change
If all goes well, you should see the code for the file src/pages/index.astro
opened in split screen with a live preview of the website. Follow the instruction to “Write your first line of Astro” to make a change to this file.
Create a GitHub Repository
Navigate to the “Source Control” navigation item in the vertical menu bar, or open with CTRL + SHIFT + G .
Select the option to Publish to GitHub. This will create a new repository in your GitHub account.
Follow the prompts to sign in to your GitHub account.
Once you are signed in, return to the IDX tab and you will be given the choice to name your new repository, and whether you want to create a private or public repository. You can choose any name and either kind of repository for this tutorial.
IDX will make an initial commit and publish to your new GitHub repo.
Going forward, whenever you have changes to be committed back to GitHub, the Source Control navigation icon will show a number. This is the number of files that have changed since your last commit. Navigating to this tab and performing two steps (commit and publish) will allow you to enter a commit message, and update your repository.
Deploy your Site
If you’d like to deploy to Netlify, and have a live published version of your site while you work, go ahead in Unit 1 to Deploy your site to the web .
Otherwise, skip to Unit 2 to start building with Astro!
¥Where are you going?
在本单元中,你将创建一个新项目,该项目在线存储在 GitHub 中并连接到 Netlify。
¥In this unit, you will create a new project that is stored online in GitHub and connected to Netlify .
当你编写代码时,你将定期将更改提交到 GitHub。Netlify 将使用 GitHub 存储库中的文件来构建你的网站,然后将其发布到互联网上的唯一地址,任何人都可以查看它。
¥As you write code, you will periodically commit your changes to GitHub. Netlify will use the files in your GitHub repository to build your website, and then publish it on the internet at a unique address where anyone can view it.
每次你向 GitHub 提交更改时,都会向 Netlify 发送一条通知。然后,Netlify 将自动重建并重新发布你的实时站点以反映这些更改。
¥Every time you commit a change to GitHub, a notification will be sent to Netlify. Then, Netlify will automatically rebuild and republish your live site to reflect those changes.
Tutorials