Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Docusaurus v3 #3518

Merged
merged 11 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "18"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion website/docs/getting-started/build-a-sample-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn main() {
Finally, add an `index.html` file in the root directory of your app.

```html , title=index.html
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion website/docs/getting-started/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We also welcome Pull Requests and issues for when they inevitably get neglected
For more details including a list of examples, refer to the [README].

:::note
Most of the examples have a live deployment that can be found at https://examples.yew.rs/<example_name>.
Most of the examples have a live deployment that can be found at https://examples.yew.rs/< example_name >.
Click the shield on their README page in their respective sub-folder to navigate to the live demo.
:::

Expand Down
2 changes: 1 addition & 1 deletion website/docs/tutorial/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn main() {
Now, let's create an `index.html` at the root of the project.

```html title="index.html"
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head></head>
<body></body>
Expand Down
14 changes: 7 additions & 7 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ module.exports = {
trackingID: 'G-DENCL8P4YP',
anonymizeIP: true,
},
algolia: {
appId: 'F8S2ICRD2T',
apiKey: '2dc337d68f84389c3713a393aff39816',
indexName: 'yew-rs',
insights: true, // Optional, automatically send insights when user interacts with search results
searchPagePath: 'search',
},
},
i18n: {
defaultLocale: 'en',
Expand Down Expand Up @@ -177,12 +184,5 @@ module.exports = {
],
},
],
[
'@easyops-cn/docusaurus-search-local',
{
hashed: true,
indexBlog: false,
},
],
],
}
20 changes: 20 additions & 0 deletions website/i18n/ja/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,25 @@
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": {
"message": "Toggle navigation bar",
"description": "The ARIA label for hamburger menu button of mobile navigation"
},
"theme.admonition.warning": {
"message": "警告",
"description": "The default label used for the Warning admonition (:::warning)"
},
"theme.DocSidebarItem.expandCategoryAriaLabel": {
"message": "Expand sidebar category '{label}'",
"description": "The ARIA label to expand the sidebar category"
},
"theme.DocSidebarItem.collapseCategoryAriaLabel": {
"message": "Collapse sidebar category '{label}'",
"description": "The ARIA label to collapse the sidebar category"
},
"theme.unlistedContent.title": {
"message": "Unlisted page",
"description": "The unlisted content banner title"
},
"theme.unlistedContent.message": {
"message": "This page is unlisted. Search engines will not index it, and only users having a direct link can access it.",
"description": "The unlisted content banner message"
}
}
36 changes: 36 additions & 0 deletions website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,41 @@
"sidebar.sidebar.category.More": {
"message": "More",
"description": "The label for category More in sidebar sidebar"
},
"sidebar.docs.category.Getting Started": {
"message": "Getting Started",
"description": "The label for category Getting Started in sidebar docs"
},
"sidebar.docs.category.Project Setup": {
"message": "Project Setup",
"description": "The label for category Project Setup in sidebar docs"
},
"sidebar.docs.category.Concepts": {
"message": "Concepts",
"description": "The label for category Concepts in sidebar docs"
},
"sidebar.docs.category.Components": {
"message": "Components",
"description": "The label for category Components in sidebar docs"
},
"sidebar.docs.category.wasm-bindgen": {
"message": "wasm-bindgen",
"description": "The label for category wasm-bindgen in sidebar docs"
},
"sidebar.docs.category.HTML": {
"message": "HTML",
"description": "The label for category HTML in sidebar docs"
},
"sidebar.docs.category.Services": {
"message": "Services",
"description": "The label for category Services in sidebar docs"
},
"sidebar.docs.category.Advanced topics": {
"message": "Advanced topics",
"description": "The label for category Advanced topics in sidebar docs"
},
"sidebar.docs.category.More": {
"message": "More",
"description": "The label for category More in sidebar docs"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ window.alert("hello from wasm!");
</td>
<td style={{ textAlign: 'left' }}>
しばしば<code>Result</code>
を返さずpanicするようになっている。例えば <code>
stdweb::web::window()
</code>
を返さずpanicするようになっている。例えば
<code>stdweb::web::window()</code>
ワーカーの中で呼ばれるパニックする。
</td>
</tr>
Expand Down
52 changes: 52 additions & 0 deletions website/i18n/ja/docusaurus-plugin-content-docs/version-0.19.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,57 @@
"sidebar.sidebar.category.yew-router": {
"message": "yew-router",
"description": "The label for category yew-router in sidebar sidebar"
},
"sidebar.docs.category.Getting Started": {
"message": "Getting Started",
"description": "The label for category Getting Started in sidebar docs"
},
"sidebar.docs.category.Project Setup": {
"message": "Project Setup",
"description": "The label for category Project Setup in sidebar docs"
},
"sidebar.docs.category.Concepts": {
"message": "Concepts",
"description": "The label for category Concepts in sidebar docs"
},
"sidebar.docs.category.wasm-bindgen": {
"message": "wasm-bindgen",
"description": "The label for category wasm-bindgen in sidebar docs"
},
"sidebar.docs.category.Components": {
"message": "Components",
"description": "The label for category Components in sidebar docs"
},
"sidebar.docs.category.HTML": {
"message": "HTML",
"description": "The label for category HTML in sidebar docs"
},
"sidebar.docs.category.Function Components": {
"message": "Function Components",
"description": "The label for category Function Components in sidebar docs"
},
"sidebar.docs.category.Advanced topics": {
"message": "Advanced topics",
"description": "The label for category Advanced topics in sidebar docs"
},
"sidebar.docs.category.More": {
"message": "More",
"description": "The label for category More in sidebar docs"
},
"sidebar.docs.category.Migration guides": {
"message": "Migration guides",
"description": "The label for category Migration guides in sidebar docs"
},
"sidebar.docs.category.yew": {
"message": "yew",
"description": "The label for category yew in sidebar docs"
},
"sidebar.docs.category.yew-agent": {
"message": "yew-agent",
"description": "The label for category yew-agent in sidebar docs"
},
"sidebar.docs.category.yew-router": {
"message": "yew-router",
"description": "The label for category yew-router in sidebar docs"
}
}
20 changes: 20 additions & 0 deletions website/i18n/zh-Hans/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,25 @@
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": {
"message": "切换导航栏",
"description": "The ARIA label for hamburger menu button of mobile navigation"
},
"theme.admonition.warning": {
"message": "注意",
"description": "The default label used for the Warning admonition (:::warning)"
},
"theme.DocSidebarItem.expandCategoryAriaLabel": {
"message": "展开侧边栏分类 '{label}'",
"description": "The ARIA label to expand the sidebar category"
},
"theme.DocSidebarItem.collapseCategoryAriaLabel": {
"message": "折叠侧边栏分类 '{label}'",
"description": "The ARIA label to collapse the sidebar category"
},
"theme.unlistedContent.title": {
"message": "未列出页",
"description": "The unlisted content banner title"
},
"theme.unlistedContent.message": {
"message": "此页面未列出。搜索引擎不会对其索引,只有拥有直接链接的用户才能访问。",
"description": "The unlisted content banner message"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ fn change(&mut self, props: Self::Properties) -> ShouldRender {

但是我们可以更进一步!对于任何实现了 `PartialEq` 的项,可以使用一个 trait 和一个 blanket implementation 将这六行样板代码减少到一行。

{% code title="neq\_assign.rs" %}

```rust
```rust title="neq_assign.rs"
pub trait NeqAssign {
fn neq_assign(&mut self, new: Self) -> ShouldRender;
}
Expand All @@ -46,8 +44,6 @@ fn change(&mut self, props: Self::Properties) -> ShouldRender {
}
```

{% endcode %}

该 trait 称为 `NeqAssign` 是因为如果目标值和新值不相等,它将赋为新值。

这比简单的实现还要短:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ html!{

如果组件的 `Properties` 中有 `children` 字段,则可以被传递子组件。

{% code title="parent.rs" %}

```rust
```rust title="parent.rs"
html! {
<Container>
<h4>{ "Hi" }</h4>
Expand All @@ -38,11 +36,7 @@ html! {
}
```

{% endcode %}

{% code title="container.rs" %}

```rust
```rust title="container.rs"
pub struct Container(Props);

#[derive(Properties)]
Expand All @@ -65,15 +59,11 @@ impl Component for Container {
}
```

{% endcode %}

## 拥有 Props 的嵌套子组件

如果包含组件标注了 children 的类型,则可以访问和更改嵌套组件的属性。在下面的示例中,`List` 组件可以包含 `ListItem` 组件。有关此模式的真实示例,请查看 `yew-router` 的源码。有关更高级的示例,请在 yew 主仓库中查看 `nested-list` 示例代码。

{% code title="parent.rs" %}

```rust
```rust title="parent.rs"
html! {
<List>
<ListItem value="a" />
Expand All @@ -83,11 +73,7 @@ html! {
}
```

{% endcode %}

{% code title="list.rs" %}

```rust
```rust title="list.rs"
pub struct List(Props);

#[derive(Properties)]
Expand All @@ -110,5 +96,3 @@ impl Component for List {
}
}
```

{% endcode %}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ cargo new --bin yew-app && cd yew-app

添加 `yew` 到你的依赖库中([这里](https://docs.rs/yew) 可以查看最新版本的 Yew)

{% code title="Cargo.toml" %}

```text
```text title="Cargo.toml"
[package]
name = "yew-app"
version = "0.1.0"
Expand All @@ -21,13 +19,9 @@ edition = "2018"
yew = { version = "0.14.3", features = ["std_web"] }
```

{% endcode %}

将这份代码复制到你的 `src/main.rs` 文件中:

{% code title="src/main.rs" %}

```rust
```rust title="src/main.rs"
use yew::prelude::*;

struct Model {
Expand Down Expand Up @@ -72,8 +66,6 @@ fn main() {
}
```

{% endcode %}

这份代码将构建你的称为 `Model` 的 `Component` 根组件,它会显示一个按钮,当你点击它时,`Model` 将会更新自己的状态。特别注意 `main()` 中的 `App::<Model>::new().mount_to_body()`,它会启动你的应用并将其挂载到页面的 `<body>` 标签中。如果你想使用任何动态属性来启动应用程序,则可以使用 `App::<Model>::new().mount_to_body_with_props(..)`。

## 运行你的应用程序!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,41 @@
"sidebar.sidebar.category.More": {
"message": "More",
"description": "The label for category More in sidebar sidebar"
},
"sidebar.docs.category.Getting Started": {
"message": "Getting Started",
"description": "The label for category Getting Started in sidebar docs"
},
"sidebar.docs.category.Project Setup": {
"message": "Project Setup",
"description": "The label for category Project Setup in sidebar docs"
},
"sidebar.docs.category.Concepts": {
"message": "Concepts",
"description": "The label for category Concepts in sidebar docs"
},
"sidebar.docs.category.Components": {
"message": "Components",
"description": "The label for category Components in sidebar docs"
},
"sidebar.docs.category.wasm-bindgen": {
"message": "wasm-bindgen",
"description": "The label for category wasm-bindgen in sidebar docs"
},
"sidebar.docs.category.HTML": {
"message": "HTML",
"description": "The label for category HTML in sidebar docs"
},
"sidebar.docs.category.Services": {
"message": "Services",
"description": "The label for category Services in sidebar docs"
},
"sidebar.docs.category.Advanced topics": {
"message": "Advanced topics",
"description": "The label for category Advanced topics in sidebar docs"
},
"sidebar.docs.category.More": {
"message": "More",
"description": "The label for category More in sidebar docs"
}
}
Loading
Loading