Skip to content

Commit 9c8e180

Browse files
i18n(zh-cn): Update tutorials (#12755)
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
1 parent be2352a commit 9c8e180

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/content/docs/zh-cn/tutorial/3-components/3.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ import Badge from "~/components/Badge.astro"
103103
2. 将下面的 CSS 样式复制到 `global.css` 中。这些样式会:
104104

105105
- 为移动设备样式和定位导航链接
106-
- 包括一个 `expanded` 类,用于在移动设备上显示或隐藏链接
107106
- 使用 `@media` 查询来定义不同屏幕尺寸下的样式
108107

109108
:::tip[移动优先设计]

src/content/docs/zh-cn/tutorial/3-components/4.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,16 @@ import { Steps } from '@astrojs/starlight/components';
123123
添加一个 `<script>` 标签提供客户端 JavaScript,以「监听」用户事件并做出相应的响应。
124124

125125
<Steps>
126-
1. 将以下 `<script>` 标签添加到 `index.astro`,就在结束的 `</body>` 标签之前。
126+
1. 使用 Astro 内置的 TypeScript 支持,将以下 `<script>` 标签添加到 `index.astro`,就在结束的 `</body>` 标签之前。
127127

128128
```astro title="src/pages/index.astro" ins={2-9}
129129
<Footer />
130130
<script>
131131
const menu = document.querySelector('.menu');
132132
133-
menu.addEventListener('click', () => {
133+
menu?.addEventListener('click', () => {
134134
const isExpanded = menu.getAttribute('aria-expanded') === 'true';
135-
menu.setAttribute('aria-expanded', !isExpanded);
135+
menu.setAttribute('aria-expanded', `${!isExpanded}`);
136136
});
137137
</script>
138138
</body>
@@ -151,9 +151,9 @@ import { Steps } from '@astrojs/starlight/components';
151151
```js title="src/scripts/menu.js"
152152
const menu = document.querySelector('.menu');
153153

154-
menu.addEventListener('click', () => {
154+
menu?.addEventListener('click', () => {
155155
const isExpanded = menu.getAttribute('aria-expanded') === 'true';
156-
menu.setAttribute('aria-expanded', !isExpanded);
156+
menu.setAttribute('aria-expanded', `${!isExpanded}`);
157157
});
158158
```
159159
@@ -164,9 +164,9 @@ import { Steps } from '@astrojs/starlight/components';
164164
<script>
165165
const menu = document.querySelector('.menu');
166166

167-
menu.addEventListener('click', () => {
167+
menu?.addEventListener('click', () => {
168168
const isExpanded = menu.getAttribute('aria-expanded') === 'true';
169-
menu.setAttribute('aria-expanded', !isExpanded);
169+
menu.setAttribute('aria-expanded', `${!isExpanded}`);
170170
});
171171

172172
import "../scripts/menu.js";

src/content/docs/zh-cn/tutorial/5-astro-api/3.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,15 @@ const pageTitle = "标签索引";
271271

272272
1.`src/pages/tags/index.astro` 中复制 `<div class="tags">...</div>``<style>...</style>` 并将它们重新用于 `MarkdownPostLayout.astro`中:
273273

274-
```astro title="src/layouts/MarkdownPostLayout.astro" ins={13-17, 21-40}
274+
```astro title="src/layouts/MarkdownPostLayout.astro" ins={11-15, 19-37}
275275
---
276276
import BaseLayout from './BaseLayout.astro';
277277
const { frontmatter } = Astro.props;
278278
---
279279
<BaseLayout pageTitle={frontmatter.title}>
280-
<p><em>{frontmatter.description}</em></p>
281280
<p>{frontmatter.pubDate.toString().slice(0,10)}</p>
282-
283-
<p>作者:{frontmatter.author}</p>
284-
281+
<p><em>{frontmatter.description}</em></p>
282+
<p>Written by: {frontmatter.author}</p>
285283
<img src={frontmatter.image.url} width="300" alt={frontmatter.image.alt} />
286284
287285
<div class="tags">

src/content/docs/zh-cn/tutorial/6-islands/3.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,25 @@ import { CardGrid, LinkCard } from '@astrojs/starlight/components';
1414

1515
还有一个修改要进行……
1616

17-
```astro title="src/pages/about.astro" del={5} ins={6}
17+
```astro title="src/pages/about.astro" del={15} ins={16}
1818
---
1919
import BaseLayout from "../layouts/BaseLayout.astro";
2020
const pageTitle = "关于我";
21-
const happy = true;
22-
const finished = false;
23-
const finished = true;
24-
const goal = 3;
21+
2522
const identity = {
2623
firstName: "莎拉",
2724
country: "加拿大",
2825
occupation: "技术撰稿人",
2926
hobbies: ["摄影", "观鸟", "棒球"],
3027
};
28+
3129
const skills = ["HTML", "CSS", "JavaScript", "React", "Astro", "Writing Docs"];
30+
31+
const happy = true;
32+
const finished = false;
33+
const finished = true;
34+
const goal = 3;
35+
3236
const skillColor = "crimson";
3337
const fontWeight = "bold";
3438
const textCase = "uppercase";

0 commit comments

Comments
 (0)