撰写你的第一篇 Markdown 博客文章
现在你已经使用 .astro
文件构建了页面,是时候使用 .md
文件制作一些博客文章了!
¥Now that you have built pages using .astro
files, it’s time to make some blog posts using .md
files!
准备好……
-
创建一个新文件夹并创建一个新帖子
-
写一些 Markdown 内容
-
链接到你的博客页面上的博客文章
创建你的第一个 .md
文件
标题部分 创建你的第一个 .md 文件¥Create your first .md
file
-
Create a new directory at
src/pages/posts/
. -
Add a new (empty) file
post-1.md
inside your new/posts/
folder. -
Look for this page in your browser preview by adding
/posts/post-1
to the end of your existing preview URL. (e.g.http://localhost:4321/posts/post-1
) -
Change the browser preview URL to view
/posts/post-2
instead. (This is a page you have not yet created.)Note the different output when previewing an “empty” page, and one that doesn’t exist. This will help you troubleshoot in the future.
编写 Markdown 内容
标题部分 编写 Markdown 内容¥Write Markdown content
-
Copy or type the following code into
post-1.md
-
Check your browser preview again at
http://localhost:4321/posts/post-1
. You should now see content on this page. It may not yet be properly formatted, but don’t worry, you will update this later in the tutorial! -
Use your browser’s Dev Tools to inspect this page. Notice that although you have not typed any HTML elements, your Markdown has been converted to HTML. You can see elements such as headings, paragraphs, and list items.
链接到你的帖子
标题部分 链接到你的帖子¥Link to your posts
-
Link to your first post with an anchor tag in
src/pages/blog.astro
: -
Now, add two more files in
src/pages/posts/
:post-2.md
andpost-3.md
. Here is some sample code you can copy and paste into your files, or, you can create your own! -
Add links to these new posts:
-
Check your browser preview and make sure that:
All your links for Post 1, Post 2, and Post 3 lead to a working page on your site. (If you find a mistake, check your links on
blog.astro
or your Markdown file names.)
测试你的知识
标题部分 测试你的知识¥Test your knowledge
- Markdown (
.md
) 文件中的内容将转换为:
清单
标题部分 清单¥Checklist
资源
标题部分 资源¥Resources
-
《Markdown 指南》中的 Markdown 备忘单 external
-
什么是浏览器开发者工具?MDN external
-
YAML 前沿问题 external