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 10 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
63 changes: 31 additions & 32 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,47 @@ module.exports = {
prism: {
additionalLanguages: ['rust', 'toml'],
},
gtag: {
trackingID: 'G-DENCL8P4YP',
anonymizeIP: true,
algolia: {
appId: 'F8S2ICRD2T',
apiKey: '2dc337d68f84389c3713a393aff39816',
indexName: 'yew-rs',
contextualSearch: true,
insights: true, // Optional, automatically send insights when user interacts with search results
searchPagePath: 'search',
},
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'ja', 'zh-Hans', 'zh-Hant'],
},
plugins: [
'content-pages',
'docusaurus-plugin-sass',
[
'@docusaurus/theme-classic',
{
customCss: require.resolve('./src/css/custom.css'),
},
],
presets: [
[
'@docusaurus/plugin-content-docs',
'@docusaurus/preset-classic',
{
path: 'docs',
sidebarPath: require.resolve('./sidebars/docs.js'),
editUrl,
routeBasePath: '/docs',
theme: {
customCss: ['./src/css/custom.css'],
},
docs: {
path: 'docs',
sidebarPath: require.resolve('./sidebars/docs.js'),
editUrl,
routeBasePath: '/docs',
},
blog: {
path: 'blog',
blogTitle: 'Yew Blog',
editUrl,
},
pages: {},
gtag: {
trackingID: 'G-DENCL8P4YP',
anonymizeIP: true,
},
},
],
],
plugins: [
'docusaurus-plugin-sass',
[
'@docusaurus/plugin-content-docs',
{
Expand All @@ -156,14 +170,6 @@ module.exports = {
editUrl,
},
],
[
'@docusaurus/plugin-content-blog',
{
path: 'blog',
blogTitle: 'Yew Blog',
editUrl,
},
],
[
'client-redirects',
{
Expand All @@ -177,12 +183,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 %}
Loading
Loading