From 10b67ea18ca054c7cfc6cac314e10c959e4b3f90 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Thu, 27 May 2021 01:32:07 +0500 Subject: [PATCH] Docusaurus v2 (#1872) * Docusaurus v2 * i18n * Fix firebase hosting config --- .github/workflows/build-website.yml | 2 +- .github/workflows/publish-website.yml | 2 +- docs/README.md | 39 - docs/SUMMARY.md | 41 - firebase.json | 21 +- website/.gitignore | 23 +- website/README.md | 144 +- website/babel.config.js | 3 + website/core/Footer.js | 92 - .../docs}/advanced-topics/how-it-works.md | 6 +- .../docs}/advanced-topics/optimizations.md | 4 +- {docs => website/docs}/concepts/agents.md | 4 +- {docs => website/docs}/concepts/components.md | 4 +- .../docs}/concepts/components/callbacks.md | 4 +- .../docs}/concepts/components/children.md | 3 +- .../docs}/concepts/components/properties.md | 4 +- .../docs}/concepts/components/refs.md | 4 +- {docs => website/docs}/concepts/contexts.md | 4 +- .../docs}/concepts/function-components.md | 4 +- .../concepts/function-components/attribute.md | 4 +- .../function-components/custom-hooks.md | 6 +- .../function-components/pre-defined-hooks.md | 4 +- {docs => website/docs}/concepts/html.md | 4 +- .../docs}/concepts/html/classes.md | 4 +- .../docs}/concepts/html/components.md | 4 +- .../docs}/concepts/html/elements.md | 4 +- {docs => website/docs}/concepts/html/lists.md | 2 +- .../concepts/html/literals-and-expressions.md | 2 +- {docs => website/docs}/concepts/router.md | 4 +- {docs => website/docs}/concepts/services.md | 4 +- .../docs}/concepts/services/fetch.md | 2 +- .../concepts/services/format.md | 4 +- .../getting-started/build-a-sample-app.md | 4 +- .../docs}/getting-started/examples.md | 2 +- .../docs}/getting-started/project-setup.md | 4 +- .../project-setup/using-trunk.md | 2 +- .../project-setup/using-wasm-pack.md | 2 +- .../getting-started/starter-templates.md | 2 +- {docs => website/docs}/index.md | 2 +- {docs => website/docs}/more/css.md | 2 +- {docs => website/docs}/more/debugging.md | 2 +- .../docs}/more/development-tips.md | 2 +- {docs => website/docs}/more/external-libs.md | 4 +- {docs => website/docs}/more/roadmap.md | 4 +- {docs => website/docs}/more/testing.md | 4 +- .../docs}/more/wasm-build-tools.md | 8 +- website/docusaurus.config.js | 117 + website/i18n/en.json | 337 - website/i18n/ja.json | 213 - .../0.17.3}/SUMMARY.md | 0 .../0.17.3}/advanced-topics/how-it-works.md | 0 .../0.17.3}/advanced-topics/optimizations.md | 0 .../0.17.3}/concepts/agents.md | 0 .../0.17.3}/concepts/components.md | 0 .../0.17.3}/concepts/components/callbacks.md | 0 .../0.17.3}/concepts/components/properties.md | 0 .../0.17.3}/concepts/components/refs.md | 0 .../0.17.3}/concepts/html.md | 0 .../0.17.3}/concepts/html/components.md | 0 .../0.17.3}/concepts/html/elements.md | 0 .../0.17.3}/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../0.17.3}/concepts/router.md | 0 .../0.17.3}/concepts/services.md | 0 .../0.17.3}/concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 36 +- .../0.17.3}/getting-started/examples.md | 0 .../0.17.3/getting-started/project-setup.md | 142 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../0.17.3}/index.md | 0 .../0.17.3}/more/css.md | 0 .../0.17.3}/more/debugging.md | 0 .../0.17.3}/more/external-libs.md | 0 .../0.17.3}/more/roadmap.md | 0 .../0.17.3}/more/testing.md | 0 .../current}/advanced-topics/how-it-works.md | 0 .../current}/advanced-topics/optimizations.md | 0 .../current}/concepts/agents.md | 0 .../current}/concepts/components.md | 0 .../current}/concepts/components/callbacks.md | 0 .../concepts/components/properties.md | 0 .../current}/concepts/components/refs.md | 0 .../current}/concepts/html.md | 0 .../current}/concepts/html/components.md | 0 .../current}/concepts/html/elements.md | 0 .../current}/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../current}/concepts/router.md | 0 .../current}/concepts/services.md | 0 .../current}/concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 36 +- .../current}/getting-started/examples.md | 0 .../current/getting-started/project-setup.md | 142 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../current}/index.md | 0 .../current}/more/css.md | 0 .../current}/more/debugging.md | 0 .../current}/more/external-libs.md | 0 .../current}/more/roadmap.md | 0 .../current}/more/testing.md | 0 .../version-0.18.0}/SUMMARY.md | 0 .../advanced-topics/how-it-works.md | 9 + .../advanced-topics/optimizations.md | 186 + .../version-0.18.0/concepts/agents.md | 56 + .../version-0.18.0/concepts/components.md | 197 + .../concepts/components/callbacks.md | 34 + .../concepts/components/properties.md | 85 + .../concepts/components/refs.md | 25 + .../version-0.18.0/concepts/html.md | 21 + .../concepts/html/components.md | 20 +- .../version-0.18.0}/concepts/html/elements.md | 116 +- .../version-0.18.0/concepts/html/lists.md | 55 + .../concepts/html/literals-and-expressions.md | 59 + .../version-0.18.0/concepts/router.md | 94 + .../version-0.18.0/concepts/services.md | 10 + .../concepts/services/format.md | 1 + .../getting-started/build-a-sample-app.md | 28 +- .../getting-started/choose-web-library.md | 123 + .../getting-started/examples.md | 15 + .../getting-started/project-setup.md | 142 + .../project-setup/using-cargo-web.md | 36 + .../project-setup/using-wasm-bindgen.md | 51 + .../project-setup/using-wasm-pack.md | 49 + .../getting-started/starter-templates.md | 42 + .../version-0.18.0/index.md | 64 + .../version-0.18.0/more/css.md | 18 + .../version-0.18.0/more/debugging.md | 58 + .../version-0.18.0/more/external-libs.md | 27 + .../version-0.18.0/more/roadmap.md | 46 + .../version-0.18.0/more/testing.md | 12 + website/i18n/zh-CN.json | 213 - .../current}/SUMMARY.md | 0 .../current}/advanced-topics/how-it-works.md | 0 .../current}/advanced-topics/optimizations.md | 0 .../current}/concepts/agents.md | 0 .../current}/concepts/components.md | 0 .../current}/concepts/components/callbacks.md | 0 .../concepts/components/properties.md | 0 .../current}/concepts/components/refs.md | 0 .../current}/concepts/html.md | 0 .../current}/concepts/html/components.md | 0 .../current}/concepts/html/elements.md | 0 .../current}/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../current}/concepts/router.md | 0 .../current}/concepts/services.md | 0 .../current}/concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 36 +- .../current}/getting-started/examples.md | 0 .../current/getting-started/project-setup.md | 138 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../current}/index.md | 0 .../current}/more/css.md | 0 .../current}/more/debugging.md | 0 .../current}/more/external-libs.md | 0 .../current}/more/roadmap.md | 0 .../current}/more/testing.md | 0 .../version-0.17.3/SUMMARY.md | 0 .../advanced-topics/how-it-works.md | 0 .../advanced-topics/optimizations.md | 0 .../version-0.17.3/concepts/agents.md | 0 .../version-0.17.3/concepts/components.md | 0 .../concepts/components/callbacks.md | 0 .../concepts/components/properties.md | 0 .../concepts/components/refs.md | 0 .../version-0.17.3/concepts/html.md | 0 .../concepts/html/components.md | 0 .../version-0.17.3/concepts/html/elements.md | 0 .../version-0.17.3/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../version-0.17.3/concepts/router.md | 0 .../version-0.17.3/concepts/services.md | 0 .../concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 36 +- .../getting-started/examples.md | 0 .../getting-started/project-setup.md | 138 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../version-0.17.3/index.md | 0 .../version-0.17.3/more/css.md | 0 .../version-0.17.3/more/debugging.md | 0 .../version-0.17.3/more/external-libs.md | 0 .../version-0.17.3/more/roadmap.md | 0 .../version-0.17.3/more/testing.md | 0 .../version-0.18.0/SUMMARY.md | 44 + .../advanced-topics/how-it-works.md | 8 + .../advanced-topics/optimizations.md | 104 + .../version-0.18.0/concepts/agents.md | 41 + .../version-0.18.0/concepts/components.md | 171 + .../concepts/components/callbacks.md | 28 + .../concepts/components/properties.md | 73 + .../concepts/components/refs.md | 23 + .../version-0.18.0/concepts/html.md | 13 + .../concepts/html/components.md | 107 + .../version-0.18.0/concepts/html/elements.md | 246 + .../version-0.18.0/concepts/html/lists.md | 52 + .../concepts/html/literals-and-expressions.md | 58 + .../version-0.18.0/concepts/router.md | 46 + .../version-0.18.0/concepts/services.md | 6 + .../concepts/services/format.md | 6 + .../getting-started/build-a-sample-app.md | 84 + .../getting-started/choose-web-library.md | 121 + .../getting-started/examples.md | 12 + .../getting-started/project-setup.md | 138 + .../project-setup/using-cargo-web.md | 32 + .../project-setup/using-wasm-bindgen.md | 6 + .../project-setup/using-wasm-pack.md | 42 + .../getting-started/starter-templates.md | 32 + .../version-0.18.0/index.md | 46 + .../version-0.18.0/more/css.md | 6 + .../version-0.18.0}/more/debugging.md | 10 +- .../version-0.18.0/more/external-libs.md | 24 + .../version-0.18.0/more/roadmap.md | 40 + .../version-0.18.0/more/testing.md | 12 + website/i18n/zh-TW.json | 213 - .../current}/SUMMARY.md | 0 .../current}/advanced-topics/how-it-works.md | 0 .../current}/advanced-topics/optimizations.md | 0 .../current}/concepts/agents.md | 0 .../current}/concepts/components.md | 0 .../current}/concepts/components/callbacks.md | 0 .../concepts/components/properties.md | 0 .../current}/concepts/components/refs.md | 0 .../current}/concepts/html.md | 0 .../current}/concepts/html/components.md | 0 .../current}/concepts/html/elements.md | 0 .../current}/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../current}/concepts/router.md | 0 .../current}/concepts/services.md | 0 .../current}/concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 14 +- .../current}/getting-started/examples.md | 0 .../current/getting-started/project-setup.md | 137 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../current}/index.md | 0 .../current}/more/css.md | 0 .../current}/more/debugging.md | 0 .../current}/more/external-libs.md | 0 .../current}/more/roadmap.md | 0 .../current}/more/testing.md | 0 .../version-0.17.3/SUMMARY.md | 0 .../advanced-topics/how-it-works.md | 0 .../advanced-topics/optimizations.md | 0 .../version-0.17.3/concepts/agents.md | 0 .../version-0.17.3/concepts/components.md | 0 .../concepts/components/callbacks.md | 0 .../concepts/components/properties.md | 0 .../concepts/components/refs.md | 0 .../version-0.17.3/concepts/html.md | 0 .../concepts/html/components.md | 0 .../version-0.17.3/concepts/html/elements.md | 0 .../version-0.17.3/concepts/html/lists.md | 0 .../concepts/html/literals-and-expressions.md | 0 .../version-0.17.3/concepts/router.md | 0 .../version-0.17.3/concepts/services.md | 0 .../concepts/services/format.md | 0 .../getting-started/build-a-sample-app.md | 0 .../getting-started/choose-web-library.md | 14 +- .../getting-started/examples.md | 0 .../getting-started/project-setup.md | 137 + .../project-setup/using-cargo-web.md | 0 .../project-setup/using-wasm-bindgen.md | 0 .../project-setup/using-wasm-pack.md | 0 .../getting-started/starter-templates.md | 0 .../version-0.17.3/index.md | 0 .../version-0.17.3/more/css.md | 0 .../version-0.17.3/more/debugging.md | 0 .../version-0.17.3/more/external-libs.md | 0 .../version-0.17.3/more/roadmap.md | 0 .../version-0.17.3/more/testing.md | 0 .../version-0.18.0/SUMMARY.md | 44 + .../advanced-topics/how-it-works.md | 8 + .../advanced-topics/optimizations.md | 132 + .../version-0.18.0/concepts/agents.md | 42 + .../version-0.18.0/concepts/components.md | 176 + .../concepts/components/callbacks.md | 34 + .../concepts/components/properties.md | 71 + .../concepts/components/refs.md | 26 + .../version-0.18.0/concepts/html.md | 13 + .../concepts/html/components.md | 107 + .../version-0.18.0/concepts/html/elements.md | 246 + .../version-0.18.0}/concepts/html/lists.md | 12 +- .../concepts/html/literals-and-expressions.md | 58 + .../version-0.18.0/concepts/router.md | 82 + .../version-0.18.0/concepts/services.md | 9 + .../concepts/services/format.md | 6 + .../getting-started/build-a-sample-app.md | 122 + .../getting-started/choose-web-library.md | 110 + .../getting-started/examples.md | 12 + .../getting-started/project-setup.md | 137 + .../project-setup/using-cargo-web.md | 32 + .../project-setup/using-wasm-bindgen.md | 6 + .../project-setup/using-wasm-pack.md | 42 + .../getting-started/starter-templates.md | 35 + .../version-0.18.0/index.md | 46 + .../version-0.18.0/more/css.md | 6 + .../version-0.18.0/more/debugging.md | 51 + .../version-0.18.0/more/external-libs.md | 24 + .../version-0.18.0/more/roadmap.md | 45 + .../version-0.18.0/more/testing.md | 12 + website/languages.js | 181 - website/package-lock.json | 26059 ++++++++++++++++ website/package.json | 53 +- website/pages/en/404.js | 22 - website/pages/en/index.js | 36 - website/pages/en/versions.js | 110 - website/sidebars.js | 109 + website/sidebars.json | 78 - website/siteConfig.js | 113 - website/src/css/custom.css | 25 + website/src/pages/index.tsx | 14 + website/static/.nojekyll | 0 website/static/css/admonition.css | 102 - website/static/css/custom.css | 31 - .../ja/getting-started/project-setup.md | 142 - .../getting-started/project-setup.md | 142 - .../zh-CN/getting-started/project-setup.md | 138 - .../getting-started/project-setup.md | 138 - .../zh-TW/getting-started/project-setup.md | 137 - .../getting-started/project-setup.md | 137 - website/tsconfig.json | 4 + .../advanced-topics/how-it-works.md | 11 - .../advanced-topics/optimizations.md | 189 - .../version-0.17.3/concepts/components.md | 176 - .../concepts/components/callbacks.md | 30 - .../concepts/components/properties.md | 75 - .../concepts/components/refs.md | 25 - .../version-0.17.3/concepts/html.md | 26 - .../version-0.17.3/concepts/router.md | 89 - .../version-0.17.3/concepts/services.md | 11 - .../getting-started/choose-web-library.md | 120 - .../getting-started/examples.md | 16 - .../getting-started/project-setup.md | 137 - .../project-setup/using-wasm-bindgen.md | 48 - .../project-setup/using-wasm-pack.md | 46 - .../getting-started/starter-templates.md | 43 - .../versioned_docs/version-0.17.3/index.md | 70 - .../versioned_docs/version-0.17.3/more/css.md | 18 - .../version-0.17.3/more/external-libs.md | 33 - .../version-0.17.3/more/roadmap.md | 48 - .../version-0.17.3/more/testing.md | 13 - .../advanced-topics/how-it-works.md | 8 +- .../advanced-topics/optimizations.md | 6 +- .../concepts/agents.md | 6 +- .../version-0.18.0/concepts/components.md | 6 +- .../concepts/components/callbacks.md | 6 +- .../concepts/components/children.md | 5 +- .../concepts/components/properties.md | 6 +- .../concepts/components/refs.md | 6 +- .../concepts/function-components.md | 6 +- .../concepts/function-components/attribute.md | 6 +- .../function-components/custom-hooks.md | 6 +- .../function-components/pre-defined-hooks.md | 6 +- .../version-0.18.0/concepts/html.md | 6 +- .../version-0.18.0/concepts/html/classes.md | 6 +- .../concepts/html/components.md | 6 +- .../version-0.18.0/concepts/html/elements.md | 6 +- .../version-0.18.0/concepts/html/lists.md | 4 +- .../concepts/html/literals-and-expressions.md | 4 +- .../version-0.18.0/concepts/router.md | 6 +- .../version-0.18.0/concepts/services.md | 9 + .../version-0.18.0/concepts/services/fetch.md | 5 +- .../concepts/services/format.md | 6 + .../getting-started/build-a-sample-app.md | 4 +- .../getting-started/choose-web-library.md | 40 +- .../getting-started/examples.md | 4 +- .../getting-started/project-setup.md | 6 +- .../project-setup/using-cargo-web.md | 4 +- .../project-setup/using-trunk.md | 4 +- .../project-setup/using-wasm-pack.md | 4 +- .../getting-started/starter-templates.md | 4 +- .../versioned_docs/version-0.18.0/index.md | 4 +- .../versioned_docs/version-0.18.0/more/css.md | 4 +- .../version-0.18.0/more/debugging.md | 4 +- .../version-0.18.0/more/external-libs.md | 6 +- .../version-0.18.0/more/roadmap.md | 6 +- .../version-0.18.0/more/testing.md | 6 +- .../version-0.17.3-sidebars.json | 64 - .../version-0.18.0-sidebars.json | 280 +- website/versions.json | 3 +- 400 files changed, 32666 insertions(+), 4562 deletions(-) delete mode 100644 docs/README.md delete mode 100644 docs/SUMMARY.md create mode 100644 website/babel.config.js delete mode 100644 website/core/Footer.js rename {docs => website/docs}/advanced-topics/how-it-works.md (97%) rename {docs => website/docs}/advanced-topics/optimizations.md (99%) rename {docs => website/docs}/concepts/agents.md (98%) rename {docs => website/docs}/concepts/components.md (98%) rename {docs => website/docs}/concepts/components/callbacks.md (98%) rename {docs => website/docs}/concepts/components/children.md (98%) rename {docs => website/docs}/concepts/components/properties.md (98%) rename {docs => website/docs}/concepts/components/refs.md (94%) rename {docs => website/docs}/concepts/contexts.md (96%) rename {docs => website/docs}/concepts/function-components.md (96%) rename {docs => website/docs}/concepts/function-components/attribute.md (96%) rename {docs => website/docs}/concepts/function-components/custom-hooks.md (93%) rename {docs => website/docs}/concepts/function-components/pre-defined-hooks.md (98%) rename {docs => website/docs}/concepts/html.md (98%) rename {docs => website/docs}/concepts/html/classes.md (97%) rename {docs => website/docs}/concepts/html/components.md (97%) rename {docs => website/docs}/concepts/html/elements.md (99%) rename {docs => website/docs}/concepts/html/lists.md (98%) rename {docs => website/docs}/concepts/html/literals-and-expressions.md (97%) rename {docs => website/docs}/concepts/router.md (98%) rename {docs => website/docs}/concepts/services.md (59%) rename {docs => website/docs}/concepts/services/fetch.md (99%) rename website/{versioned_docs/version-0.17.3 => docs}/concepts/services/format.md (70%) rename {docs => website/docs}/getting-started/build-a-sample-app.md (98%) rename {docs => website/docs}/getting-started/examples.md (96%) rename {docs => website/docs}/getting-started/project-setup.md (96%) rename {docs => website/docs}/getting-started/project-setup/using-trunk.md (98%) rename {docs => website/docs}/getting-started/project-setup/using-wasm-pack.md (98%) rename {docs => website/docs}/getting-started/starter-templates.md (98%) rename {docs => website/docs}/index.md (99%) rename {docs => website/docs}/more/css.md (98%) rename {docs => website/docs}/more/debugging.md (99%) rename {docs => website/docs}/more/development-tips.md (98%) rename {docs => website/docs}/more/external-libs.md (94%) rename {docs => website/docs}/more/roadmap.md (93%) rename {docs => website/docs}/more/testing.md (93%) rename {docs => website/docs}/more/wasm-build-tools.md (93%) create mode 100644 website/docusaurus.config.js delete mode 100644 website/i18n/en.json delete mode 100644 website/i18n/ja.json rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/SUMMARY.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/advanced-topics/optimizations.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/agents.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/components.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/components/callbacks.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/components/properties.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/components/refs.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/html.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/html/components.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/html/elements.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/html/lists.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/router.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/services.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/concepts/services/format.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/choose-web-library.md (68%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/examples.md (100%) create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup.md rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/getting-started/starter-templates.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/index.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/more/css.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/more/debugging.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/more/external-libs.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/more/roadmap.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/0.17.3}/more/testing.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/advanced-topics/optimizations.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/agents.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/components.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/components/callbacks.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/components/properties.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/components/refs.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/html.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/html/components.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/html/elements.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/html/lists.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/router.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/services.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/concepts/services/format.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/choose-web-library.md (68%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/examples.md (100%) create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup.md rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/getting-started/starter-templates.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/index.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/more/css.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/more/debugging.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/more/external-libs.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/more/roadmap.md (100%) rename website/{translated_docs/ja/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/current}/more/testing.md (100%) rename website/{translated_docs/ja => i18n/ja/docusaurus-plugin-content-docs/version-0.18.0}/SUMMARY.md (100%) create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md rename website/{versioned_docs/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/version-0.18.0}/concepts/html/components.md (59%) rename website/{versioned_docs/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/version-0.18.0}/concepts/html/elements.md (84%) create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/lists.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md rename {docs => website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0}/concepts/services/format.md (99%) rename website/{versioned_docs/version-0.17.3 => i18n/ja/docusaurus-plugin-content-docs/version-0.18.0}/getting-started/build-a-sample-app.md (52%) create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/index.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/css.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/debugging.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md create mode 100644 website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md delete mode 100644 website/i18n/zh-CN.json rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/SUMMARY.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/advanced-topics/optimizations.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/agents.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/components.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/components/callbacks.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/components/properties.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/components/refs.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/html.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/html/components.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/html/elements.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/html/lists.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/router.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/services.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/concepts/services/format.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/choose-web-library.md (63%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/examples.md (100%) create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup.md rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/getting-started/starter-templates.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/index.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/more/css.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/more/debugging.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/more/external-libs.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/more/roadmap.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs/current}/more/testing.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/SUMMARY.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/advanced-topics/optimizations.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/agents.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/callbacks.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/properties.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/refs.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/components.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/elements.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/lists.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/router.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/services.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/concepts/services/format.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/choose-web-library.md (63%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/examples.md (100%) create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup.md rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/starter-templates.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/index.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/more/css.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/more/debugging.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/more/external-libs.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/more/roadmap.md (100%) rename website/{translated_docs/zh-CN => i18n/zh-CN/docusaurus-plugin-content-docs}/version-0.17.3/more/testing.md (100%) create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/lists.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/services/format.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/build-a-sample-app.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/index.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/more/css.md rename website/{versioned_docs/version-0.17.3 => i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0}/more/debugging.md (90%) create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md create mode 100644 website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md delete mode 100644 website/i18n/zh-TW.json rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/SUMMARY.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/advanced-topics/optimizations.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/agents.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/components.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/components/callbacks.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/components/properties.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/components/refs.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/html.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/html/components.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/html/elements.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/html/lists.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/router.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/services.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/concepts/services/format.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/choose-web-library.md (88%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/examples.md (100%) create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/current/getting-started/project-setup.md rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/getting-started/starter-templates.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/index.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/more/css.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/more/debugging.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/more/external-libs.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/more/roadmap.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs/current}/more/testing.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/SUMMARY.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/advanced-topics/how-it-works.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/advanced-topics/optimizations.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/agents.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/callbacks.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/properties.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/components/refs.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/components.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/elements.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/lists.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/html/literals-and-expressions.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/router.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/services.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/concepts/services/format.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/build-a-sample-app.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/choose-web-library.md (88%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/examples.md (100%) create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup.md rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-cargo-web.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/project-setup/using-wasm-pack.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/getting-started/starter-templates.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/index.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/more/css.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/more/debugging.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/more/external-libs.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/more/roadmap.md (100%) rename website/{translated_docs/zh-TW => i18n/zh-TW/docusaurus-plugin-content-docs}/version-0.17.3/more/testing.md (100%) create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md rename website/{versioned_docs/version-0.17.3 => i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0}/concepts/html/lists.md (70%) create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/concepts/services/format.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/build-a-sample-app.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/index.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/more/css.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/more/debugging.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md create mode 100644 website/i18n/zh-TW/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md delete mode 100644 website/languages.js create mode 100644 website/package-lock.json delete mode 100644 website/pages/en/404.js delete mode 100644 website/pages/en/index.js delete mode 100644 website/pages/en/versions.js create mode 100644 website/sidebars.js delete mode 100644 website/sidebars.json delete mode 100644 website/siteConfig.js create mode 100644 website/src/css/custom.css create mode 100644 website/src/pages/index.tsx create mode 100644 website/static/.nojekyll delete mode 100644 website/static/css/admonition.css delete mode 100644 website/static/css/custom.css delete mode 100644 website/translated_docs/ja/getting-started/project-setup.md delete mode 100644 website/translated_docs/ja/version-0.17.3/getting-started/project-setup.md delete mode 100644 website/translated_docs/zh-CN/getting-started/project-setup.md delete mode 100644 website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup.md delete mode 100644 website/translated_docs/zh-TW/getting-started/project-setup.md delete mode 100644 website/translated_docs/zh-TW/version-0.17.3/getting-started/project-setup.md create mode 100644 website/tsconfig.json delete mode 100644 website/versioned_docs/version-0.17.3/advanced-topics/how-it-works.md delete mode 100644 website/versioned_docs/version-0.17.3/advanced-topics/optimizations.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/components.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/components/callbacks.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/components/properties.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/components/refs.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/html.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/router.md delete mode 100644 website/versioned_docs/version-0.17.3/concepts/services.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/choose-web-library.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/examples.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/project-setup.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/project-setup/using-wasm-pack.md delete mode 100644 website/versioned_docs/version-0.17.3/getting-started/starter-templates.md delete mode 100644 website/versioned_docs/version-0.17.3/index.md delete mode 100644 website/versioned_docs/version-0.17.3/more/css.md delete mode 100644 website/versioned_docs/version-0.17.3/more/external-libs.md delete mode 100644 website/versioned_docs/version-0.17.3/more/roadmap.md delete mode 100644 website/versioned_docs/version-0.17.3/more/testing.md rename website/versioned_docs/{version-0.17.3 => version-0.18.0}/concepts/agents.md (96%) rename website/versioned_docs/{version-0.17.3 => version-0.18.0}/concepts/html/literals-and-expressions.md (91%) create mode 100644 website/versioned_docs/version-0.18.0/concepts/services.md create mode 100644 website/versioned_docs/version-0.18.0/concepts/services/format.md rename website/versioned_docs/{version-0.17.3 => version-0.18.0}/getting-started/project-setup/using-cargo-web.md (86%) delete mode 100644 website/versioned_sidebars/version-0.17.3-sidebars.json diff --git a/.github/workflows/build-website.yml b/.github/workflows/build-website.yml index 5e74193d3..977d10bab 100644 --- a/.github/workflows/build-website.yml +++ b/.github/workflows/build-website.yml @@ -35,7 +35,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: website - path: website/build/yew + path: website/build/ retention-days: 1 - if: github.event_name == 'pull_request' diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml index 785e660ca..b972fcc8b 100644 --- a/.github/workflows/publish-website.yml +++ b/.github/workflows/publish-website.yml @@ -27,7 +27,7 @@ jobs: workflow: build-website.yml run_id: ${{ github.event.workflow_run.id }} name: website - path: website/build/yew + path: website/build - if: github.event.workflow_run.event == 'pull_request' name: Download pr info diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index daf135892..000000000 --- a/docs/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Contributing to the documentation - -Firstly, thanks for considering contributing to Yew. We're a friendly community of humans who -collaborate to build (hopefully) awesome software. We try to write software which is easy to use so -we ask that you follow a few guidelines when contributing – these are laid out in this document. - -Note that this document is about *contributing documentation* not contributing code and only -applies to the contents of the `docs` folder – not any other parts of the project. - -## Can I just submit a PR or do I need to create an issue first? - -PRs not attached to previously created issues are welcome *if* they're a small change. This could -be something like fixing a small grammar mistake or a typo. - -If your PR is something bigger create an issue beforehand. This will save everyone time and effort: - -1. Multiple people don't end up submitting duplicate PRs doing the same thing. -2. People have a chance to submit feedback on an idea *before* someone does a lot of work on it. -3. It's easy to track progress on the development of the documentation. - -## Spelling and grammar - -We recognize that not everyone who contributes to Yew will have "perfect" grammar or be a native -English speaker. We're all human; everyone makes mistakes and nobody will look down on you if you -make typos or grammar mistakes (we'll just fix them, merge PRs and move on with life). - -To help catch spelling mistakes, we use a spellchecking script which originally came from the Rust -Book. If it picks up a spelling "mistake" which isn't actually a mistake, then please add it to the -list in `ci/dictionary.txt` (in alphabetically sorted order). - -If in doubt about spelling, grammar or style you might find it useful to consult the -[Microsoft Style Guide](https://docs.microsoft.com/style-guide/) which we sometimes use as a handy -reference. - -## Line wrap -Having really long lines makes it hard to review code and see differences between versions. To -solve this problem all lines should be wrapped at 100 characters. - -If you're editing a line which is more than 100 characters long, please feel free to shorten it! \ No newline at end of file diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md deleted file mode 100644 index 054fa3bbe..000000000 --- a/docs/SUMMARY.md +++ /dev/null @@ -1,41 +0,0 @@ -# Table of contents - -- [Introduction](README.md) - -## Getting Started - -- [Project Setup](getting-started/project-setup.md) - - [Using trunk](getting-started/project-setup/using-trunk.md) - - [Using wasm-pack](getting-started/project-setup/using-wasm-pack.md) -- [Starter Templates](getting-started/starter-templates.md) -- [Build a Sample App](getting-started/build-a-sample-app.md) -- [Learn through examples](getting-started/examples.md) - -## Core Concepts - -- [Using html!](concepts/html.md) - - [Lists](concepts/html/lists.md) - - [Elements](concepts/html/elements.md) - - [Literals & Expressions](concepts/html/literals-and-expressions.md) - - [Components](concepts/html/components.md) -- [Components](concepts/components.md) - - [Properties](concepts/components/properties.md) - - [Callbacks](concepts/components/callbacks.md) - - [Refs](concepts/components/refs.md) -- [Agents](concepts/agents.md) -- [Services](concepts/services.md) - - [Format](concepts/services/format.md) -- [Router](concepts/router.md) - -## Advanced Topics - -- [Optimizations & Best Practices](advanced-topics/optimizations.md) -- [Low-level library internals](advanced-topics/how-it-works.md) - -## More - -- [CSS](more/css.md) -- [Roadmap](more/roadmap.md) -- [Testing](more/testing.md) -- [Debugging](more/debugging.md) -- [External Libs](more/external-libs.md) diff --git a/firebase.json b/firebase.json index c62f26896..de7bac428 100644 --- a/firebase.json +++ b/firebase.json @@ -2,39 +2,44 @@ "hosting": [ { "target": "website", - "public": "website/build/yew", + "public": "website/build/", "cleanUrls": true, "redirects": [ // `/intro` -> `/` (2020-10-15) { - "source": "/docs/:lang/intro", - "destination": "/docs/:lang/", + "source": "/", + "destination": "/docs/index/", + "type": 302 + }, + { + "source": "/docs/:lang/index", + "destination": "/:lang/docs/index", "type": 301 }, { "source": "/docs/:lang/next/intro", - "destination": "/docs/:lang/next/", + "destination": "/:lang/docs/next/index", "type": 301 }, // legacy (2020-08-15) { "source": "/docs/v/zh_cn", - "destination": "/docs/zh-CN/", + "destination": "/zh-CN/docs/", "type": 301 }, { "source": "/docs/v/zh_tw", - "destination": "/docs/zh-TW/", + "destination": "/zh-TW/docs/", "type": 301 }, { "regex": "/docs/v/zh_cn/(.*)", - "destination": "/docs/zh-CN/:1", + "destination": "/zh-CN/docs/:1", "type": 301 }, { "regex": "/docs/v/zh_tw/(.*)", - "destination": "/docs/zh-TW/:1", + "destination": "/zh-TW/docs/:1", "type": 301 } ] diff --git a/website/.gitignore b/website/.gitignore index 566118413..b2d6de306 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -1,5 +1,20 @@ -build/ -node_modules/ +# Dependencies +/node_modules -/package-lock.json -/yarn.lock +# Production +/build + +# Generated files +.docusaurus +.cache-loader + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/website/README.md b/website/README.md index 1fb0e067b..231a499c0 100644 --- a/website/README.md +++ b/website/README.md @@ -1,143 +1,33 @@ -This website was created with [Docusaurus](https://docusaurus.io/). +# Website -# What's In This Document +This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. -- [Get Started in 5 Minutes](#get-started-in-5-minutes) -- [Directory Structure](#directory-structure) -- [Editing Content](#editing-content) -- [Adding Content](#adding-content) -- [Full Documentation](#full-documentation) +## Installation -# Get Started in 5 Minutes - -1. Make sure all the dependencies for the website are installed: - -```sh -# Install dependencies -$ npm install +```console +yarn install ``` -2. Run your dev server: +## Local Development -```sh -# Start the site -$ npm start +```console +yarn start ``` -## Directory Structure +This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. -Your project file structure should look something like this +## Build -``` -yew/ - docs/ - website/ - core/ - node_modules/ - static/ - css/ - img/ - package.json - sidebars.json - siteConfig.js +```console +yarn build ``` -# Editing Content +This command generates static content into the `build` directory and can be served using any static contents hosting service. -## Editing an existing docs page +## Deployment -Edit docs by navigating to `docs/` and editing the corresponding document: - -`docs/doc-to-be-edited.md` - -```markdown ---- -id: page-needs-edit -title: This Doc Needs To Be Edited ---- - -Edit me... +```console +GIT_USER= USE_SSH=true yarn deploy ``` -For more information about docs, click [here](https://docusaurus.io/docs/en/navigation) - -# Adding Content - -## Adding a new docs page to an existing sidebar - -1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`: - -```md ---- -id: newly-created-doc -title: This Doc Needs To Be Edited ---- - -My new content here.. -``` - -1. Refer to that doc's ID in an existing sidebar in `website/sidebars.json`: - -```javascript -// Add newly-created-doc to the Getting Started category of docs -{ - "docs": { - "Getting Started": [ - "quick-start", - "newly-created-doc" // new doc here - ], - ... - }, - ... -} -``` - -For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation) - -## Adding items to your site's top navigation bar - -1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`: - -`website/siteConfig.js` - -```javascript -{ - headerLinks: [ - ... - /* you can add docs */ - { doc: 'my-examples', label: 'Examples' }, - /* you can add custom pages */ - { page: 'help', label: 'Help' }, - /* you can add external links */ - { href: 'https://github.com/facebook/docusaurus', label: 'GitHub' }, - ... - ], - ... -} -``` - -For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation) - -## Adding custom pages - -1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`: -1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element: - -`website/siteConfig.js` - -```javascript -{ - headerLinks: [ - ... - { page: 'my-new-custom-page', label: 'My New Custom Page' }, - ... - ], - ... -} -``` - -For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages). - -# Full Documentation - -Full documentation can be found on the [website](https://docusaurus.io/). +If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. diff --git a/website/babel.config.js b/website/babel.config.js new file mode 100644 index 000000000..e00595dae --- /dev/null +++ b/website/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: [require.resolve('@docusaurus/core/lib/babel/preset')], +}; diff --git a/website/core/Footer.js b/website/core/Footer.js deleted file mode 100644 index 0413aea35..000000000 --- a/website/core/Footer.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const React = require('react'); - -class Footer extends React.Component { - docUrl(doc, language) { - const baseUrl = this.props.config.baseUrl; - const docsUrl = this.props.config.docsUrl; - const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; - const langPart = `${language ? `${language}/` : ''}`; - return `${baseUrl}${docsPart}${langPart}${doc}`; - } - - pageUrl(doc, language) { - const baseUrl = this.props.config.baseUrl; - return baseUrl + (language ? `${language}/` : '') + doc; - } - - render() { - return ( - - ); - } -} - -module.exports = Footer; diff --git a/docs/advanced-topics/how-it-works.md b/website/docs/advanced-topics/how-it-works.md similarity index 97% rename from docs/advanced-topics/how-it-works.md rename to website/docs/advanced-topics/how-it-works.md index d7b1a797d..4d11aa873 100644 --- a/docs/advanced-topics/how-it-works.md +++ b/website/docs/advanced-topics/how-it-works.md @@ -1,6 +1,6 @@ --- -title: How it works -description: Low level details about the framework +title: "How it works" +description: "Low level details about the framework" --- # Low-level library internals @@ -68,4 +68,4 @@ indicate whether a re-render is required to help with performance. ## Further reading * [More information about macros from the Rust Book](https://doc.rust-lang.org/stable/book/ch19-06-macros.html) * [More information about `cargo-expand`](https://github.com/dtolnay/cargo-expand) -* [The API documentation for `yew::virtual_dom`](https://docs.rs/yew/*/yew/virtual_dom/index.html) \ No newline at end of file +* [The API documentation for `yew::virtual_dom`](https://docs.rs/yew/*/yew/virtual_dom/index.html) diff --git a/docs/advanced-topics/optimizations.md b/website/docs/advanced-topics/optimizations.md similarity index 99% rename from docs/advanced-topics/optimizations.md rename to website/docs/advanced-topics/optimizations.md index 092e45421..4537996d3 100644 --- a/docs/advanced-topics/optimizations.md +++ b/website/docs/advanced-topics/optimizations.md @@ -1,7 +1,7 @@ --- -title: Optimizations & Best Practices +title: "Optimizations & Best Practices" sidebar_label: Optimizations -description: Make your app faster +description: "Make your app faster" --- ## neq\_assign diff --git a/docs/concepts/agents.md b/website/docs/concepts/agents.md similarity index 98% rename from docs/concepts/agents.md rename to website/docs/concepts/agents.md index bf5d95cd0..637096d84 100644 --- a/docs/concepts/agents.md +++ b/website/docs/concepts/agents.md @@ -1,6 +1,6 @@ --- -title: Agents -description: Yew's Actor System +title: "Agents" +description: "Yew's Actor System" --- Agents are similar to Angular's [Services](https://angular.io/guide/architecture-services) \(but without dependency injection\), and provide a Yew with an [Actor Model](https://en.wikipedia.org/wiki/Actor_model). Agents can be used to route messages between components independently of where they sit in the component hierarchy, or they can be used to create a shared state, and they can also be used to offload computationally expensive tasks from the main thread which renders the UI. There is also planned support for using agents to allow Yew applications to communicate across tabs \(in the future\). diff --git a/docs/concepts/components.md b/website/docs/concepts/components.md similarity index 98% rename from docs/concepts/components.md rename to website/docs/concepts/components.md index 0fbda0971..d69960ff2 100644 --- a/docs/concepts/components.md +++ b/website/docs/concepts/components.md @@ -1,6 +1,6 @@ --- -title: Introduction -description: Components and their lifecycle hooks +title: "Introduction" +description: "Components and their lifecycle hooks" --- ## What are Components? diff --git a/docs/concepts/components/callbacks.md b/website/docs/concepts/components/callbacks.md similarity index 98% rename from docs/concepts/components/callbacks.md rename to website/docs/concepts/components/callbacks.md index e0851a3f6..cc5bb2397 100644 --- a/docs/concepts/components/callbacks.md +++ b/website/docs/concepts/components/callbacks.md @@ -1,6 +1,6 @@ --- -title: Callbacks -description: ComponentLink and Callbacks +title: "Callbacks" +description: "ComponentLink and Callbacks" --- The component "link" is the mechanism through which components are able to create callbacks and update themselves. diff --git a/docs/concepts/components/children.md b/website/docs/concepts/components/children.md similarity index 98% rename from docs/concepts/components/children.md rename to website/docs/concepts/components/children.md index a4b62abf6..82e19d4b8 100644 --- a/docs/concepts/components/children.md +++ b/website/docs/concepts/components/children.md @@ -1,6 +1,5 @@ --- -title: Children -description: +title: "Children" --- ## General usage diff --git a/docs/concepts/components/properties.md b/website/docs/concepts/components/properties.md similarity index 98% rename from docs/concepts/components/properties.md rename to website/docs/concepts/components/properties.md index 1e6cb03a5..528ed0b35 100644 --- a/docs/concepts/components/properties.md +++ b/website/docs/concepts/components/properties.md @@ -1,6 +1,6 @@ --- -title: Properties -description: Parent to child communication +title: "Properties" +description: "Parent to child communication" --- Properties enable child and parent components to communicate with each other. diff --git a/docs/concepts/components/refs.md b/website/docs/concepts/components/refs.md similarity index 94% rename from docs/concepts/components/refs.md rename to website/docs/concepts/components/refs.md index 97038b829..87c865317 100644 --- a/docs/concepts/components/refs.md +++ b/website/docs/concepts/components/refs.md @@ -1,6 +1,6 @@ --- -title: Refs -description: Out-of-band DOM access +title: "Refs" +description: "Out-of-band DOM access" --- The `ref` keyword can be used inside of any HTML element or component to get the DOM `Element` that diff --git a/docs/concepts/contexts.md b/website/docs/concepts/contexts.md similarity index 96% rename from docs/concepts/contexts.md rename to website/docs/concepts/contexts.md index eb9ae7d71..aae8d2e86 100644 --- a/docs/concepts/contexts.md +++ b/website/docs/concepts/contexts.md @@ -1,7 +1,7 @@ --- -title: Contexts +title: "Contexts" sidebar_label: Contexts -description: Using contexts to pass data within application +description: "Using contexts to pass data within application" --- Generally data is passed down the component tree using props but that becomes tedious for values such as diff --git a/docs/concepts/function-components.md b/website/docs/concepts/function-components.md similarity index 96% rename from docs/concepts/function-components.md rename to website/docs/concepts/function-components.md index 781838acb..ccedd46c8 100644 --- a/docs/concepts/function-components.md +++ b/website/docs/concepts/function-components.md @@ -1,7 +1,7 @@ --- -title: Function Components +title: "Function Components" sidebar_label: Introduction -description: Introduction to function components +description: "Introduction to function components " --- :::warning diff --git a/docs/concepts/function-components/attribute.md b/website/docs/concepts/function-components/attribute.md similarity index 96% rename from docs/concepts/function-components/attribute.md rename to website/docs/concepts/function-components/attribute.md index aa7262df4..551e72f8e 100644 --- a/docs/concepts/function-components/attribute.md +++ b/website/docs/concepts/function-components/attribute.md @@ -1,6 +1,6 @@ --- -title: #[function_component] -description: The #[function_component] attribute +title: "#[function_component]" +description: "The #[function_component] attribute" --- `#[function_component(_)]` turns a normal Rust function into a function component. diff --git a/docs/concepts/function-components/custom-hooks.md b/website/docs/concepts/function-components/custom-hooks.md similarity index 93% rename from docs/concepts/function-components/custom-hooks.md rename to website/docs/concepts/function-components/custom-hooks.md index 333a1e198..752f6c503 100644 --- a/docs/concepts/function-components/custom-hooks.md +++ b/website/docs/concepts/function-components/custom-hooks.md @@ -1,6 +1,6 @@ --- -title: Custom Hooks -description: Defining your own Hooks +title: "Custom Hooks" +description: "Defining your own Hooks " --- ## Defining custom Hooks @@ -68,5 +68,5 @@ Although this approach works in almost all cases, it can't be used to write prim ### Writing primitive hooks -`use_hook` function is used to write such hooks. View the docs on [docs.rs]() for the documentation +`use_hook` function is used to write such hooks. View the docs on [docs.rs](https://docs.rs/yew/0.18.0/yew-functional/use_hook.html) for the documentation and `hooks` directory to see implementations of pre-defined hooks. diff --git a/docs/concepts/function-components/pre-defined-hooks.md b/website/docs/concepts/function-components/pre-defined-hooks.md similarity index 98% rename from docs/concepts/function-components/pre-defined-hooks.md rename to website/docs/concepts/function-components/pre-defined-hooks.md index a32cbb806..fc6dd7d5e 100644 --- a/docs/concepts/function-components/pre-defined-hooks.md +++ b/website/docs/concepts/function-components/pre-defined-hooks.md @@ -1,6 +1,6 @@ --- -title: Pre-defined Hooks -description: The pre-defined Hooks that Yew comes with +title: "Pre-defined Hooks" +description: "The pre-defined Hooks that Yew comes with " --- ## `use_state` diff --git a/docs/concepts/html.md b/website/docs/concepts/html.md similarity index 98% rename from docs/concepts/html.md rename to website/docs/concepts/html.md index e893173a0..f1f850232 100644 --- a/docs/concepts/html.md +++ b/website/docs/concepts/html.md @@ -1,7 +1,7 @@ --- -title: HTML +title: "HTML" sidebar_label: Introduction -description: The procedural macro for generating HTML and SVG +description: "The procedural macro for generating HTML and SVG" --- The `html!` macro allows you to write HTML and SVG code declaratively. It is similar to JSX diff --git a/docs/concepts/html/classes.md b/website/docs/concepts/html/classes.md similarity index 97% rename from docs/concepts/html/classes.md rename to website/docs/concepts/html/classes.md index 2d8f2f051..0544791ef 100644 --- a/docs/concepts/html/classes.md +++ b/website/docs/concepts/html/classes.md @@ -1,6 +1,6 @@ --- -title: Classes -description: A handy macro to handle classes +title: "Classes" +description: "A handy macro to handle classes" --- ## Classes diff --git a/docs/concepts/html/components.md b/website/docs/concepts/html/components.md similarity index 97% rename from docs/concepts/html/components.md rename to website/docs/concepts/html/components.md index c0e6fae8b..200db0037 100644 --- a/docs/concepts/html/components.md +++ b/website/docs/concepts/html/components.md @@ -1,6 +1,6 @@ --- -title: Components -description: Create complex layouts with component hierarchies +title: "Components" +description: "Create complex layouts with component hierarchies" --- ## Basic diff --git a/docs/concepts/html/elements.md b/website/docs/concepts/html/elements.md similarity index 99% rename from docs/concepts/html/elements.md rename to website/docs/concepts/html/elements.md index 6bdab7007..230f1f7c3 100644 --- a/docs/concepts/html/elements.md +++ b/website/docs/concepts/html/elements.md @@ -1,6 +1,6 @@ --- -title: Elements -description: Both HTML and SVG elements are supported +title: "Elements" +description: "Both HTML and SVG elements are supported" --- ## Dynamic tag names diff --git a/docs/concepts/html/lists.md b/website/docs/concepts/html/lists.md similarity index 98% rename from docs/concepts/html/lists.md rename to website/docs/concepts/html/lists.md index 543bdf40c..46ea8e137 100644 --- a/docs/concepts/html/lists.md +++ b/website/docs/concepts/html/lists.md @@ -1,5 +1,5 @@ --- -title: Lists +title: "Lists" --- ## Fragments diff --git a/docs/concepts/html/literals-and-expressions.md b/website/docs/concepts/html/literals-and-expressions.md similarity index 97% rename from docs/concepts/html/literals-and-expressions.md rename to website/docs/concepts/html/literals-and-expressions.md index 722bd5c05..b20882747 100644 --- a/docs/concepts/html/literals-and-expressions.md +++ b/website/docs/concepts/html/literals-and-expressions.md @@ -1,5 +1,5 @@ --- -title: Literals and Expressions +title: "Literals and Expressions" --- ## Literals diff --git a/docs/concepts/router.md b/website/docs/concepts/router.md similarity index 98% rename from docs/concepts/router.md rename to website/docs/concepts/router.md index 99a1b381f..0c3180e8b 100644 --- a/docs/concepts/router.md +++ b/website/docs/concepts/router.md @@ -1,6 +1,6 @@ --- -title: Router -description: Yew's official router +title: "Router" +description: "Yew's official router" --- [The router on crates.io](https://crates.io/crates/yew-router) diff --git a/docs/concepts/services.md b/website/docs/concepts/services.md similarity index 59% rename from docs/concepts/services.md rename to website/docs/concepts/services.md index 0ad293365..130292e89 100644 --- a/docs/concepts/services.md +++ b/website/docs/concepts/services.md @@ -1,7 +1,7 @@ --- -title: Services +title: "Services" sidebar_label: Overview -description: Yew's glue to browser APIs +description: "Yew's glue to browser APIs" --- :::note diff --git a/docs/concepts/services/fetch.md b/website/docs/concepts/services/fetch.md similarity index 99% rename from docs/concepts/services/fetch.md rename to website/docs/concepts/services/fetch.md index 7b96625f6..72977d924 100644 --- a/docs/concepts/services/fetch.md +++ b/website/docs/concepts/services/fetch.md @@ -1,6 +1,6 @@ --- id: fetch -title: Fetch +title: "Fetch" --- ## Introduction The fetch service can be used to make HTTP requests to a server. This enables applications to diff --git a/website/versioned_docs/version-0.17.3/concepts/services/format.md b/website/docs/concepts/services/format.md similarity index 70% rename from website/versioned_docs/version-0.17.3/concepts/services/format.md rename to website/docs/concepts/services/format.md index 20fda2edd..89fc2fcdb 100644 --- a/website/versioned_docs/version-0.17.3/concepts/services/format.md +++ b/website/docs/concepts/services/format.md @@ -1,7 +1,5 @@ --- -title: Format -id: version-0.17.3-format -original_id: format +title: "Format" --- :::important contribute `Contribute to our docs:` [Explain the format module in depth](https://github.com/yewstack/docs/issues/24) diff --git a/docs/getting-started/build-a-sample-app.md b/website/docs/getting-started/build-a-sample-app.md similarity index 98% rename from docs/getting-started/build-a-sample-app.md rename to website/docs/getting-started/build-a-sample-app.md index b85477a4e..71cda49a4 100644 --- a/docs/getting-started/build-a-sample-app.md +++ b/website/docs/getting-started/build-a-sample-app.md @@ -1,5 +1,5 @@ --- -title: Build a sample app +title: "Build a sample app" --- ## Create Project @@ -141,4 +141,4 @@ Trunk will helpfully rebuild your application if you modify any of its files. You have now successfully setup your Yew development environment, and built your first web application. -Experiment with this application and review the [examples](./examples.md) to further your learning. \ No newline at end of file +Experiment with this application and review the [examples](./examples.md) to further your learning. diff --git a/docs/getting-started/examples.md b/website/docs/getting-started/examples.md similarity index 96% rename from docs/getting-started/examples.md rename to website/docs/getting-started/examples.md index 67812fd87..e68279b30 100644 --- a/docs/getting-started/examples.md +++ b/website/docs/getting-started/examples.md @@ -1,5 +1,5 @@ --- -title: Examples +title: "Examples" --- The Yew repository is chock-full of [examples] \(in various states of maintenance\). diff --git a/docs/getting-started/project-setup.md b/website/docs/getting-started/project-setup.md similarity index 96% rename from docs/getting-started/project-setup.md rename to website/docs/getting-started/project-setup.md index 7edec58ac..dd7236e2e 100644 --- a/docs/getting-started/project-setup.md +++ b/website/docs/getting-started/project-setup.md @@ -1,7 +1,7 @@ --- -title: Project Setup +title: "Project Setup" sidebar_label: Introduction -description: Set yourself up for success +description: "Set yourself up for success" --- ## Overview diff --git a/docs/getting-started/project-setup/using-trunk.md b/website/docs/getting-started/project-setup/using-trunk.md similarity index 98% rename from docs/getting-started/project-setup/using-trunk.md rename to website/docs/getting-started/project-setup/using-trunk.md index 234a5f13a..1651fc530 100644 --- a/docs/getting-started/project-setup/using-trunk.md +++ b/website/docs/getting-started/project-setup/using-trunk.md @@ -1,5 +1,5 @@ --- -title: Using trunk +title: "Using trunk" --- ## Install diff --git a/docs/getting-started/project-setup/using-wasm-pack.md b/website/docs/getting-started/project-setup/using-wasm-pack.md similarity index 98% rename from docs/getting-started/project-setup/using-wasm-pack.md rename to website/docs/getting-started/project-setup/using-wasm-pack.md index 52eed9226..e8567e6ae 100644 --- a/docs/getting-started/project-setup/using-wasm-pack.md +++ b/website/docs/getting-started/project-setup/using-wasm-pack.md @@ -1,5 +1,5 @@ --- -title: Using wasm-pack +title: "Using wasm-pack" --- This tool was created by the Rust / Wasm Working Group for building WebAssembly applications. It supports packaging code into `npm` modules and has an accompanying [Webpack plugin](https://github.com/wasm-tool/wasm-pack-plugin) for easy integration with existing JavaScript applications. More information is given in [the `wasm-pack` documentation](https://rustwasm.github.io/docs/wasm-pack/introduction.html). diff --git a/docs/getting-started/starter-templates.md b/website/docs/getting-started/starter-templates.md similarity index 98% rename from docs/getting-started/starter-templates.md rename to website/docs/getting-started/starter-templates.md index 851ac5ca2..af8d434f9 100644 --- a/docs/getting-started/starter-templates.md +++ b/website/docs/getting-started/starter-templates.md @@ -1,5 +1,5 @@ --- -title: Starter templates +title: "Starter templates" --- ## `trunk` diff --git a/docs/index.md b/website/docs/index.md similarity index 99% rename from docs/index.md rename to website/docs/index.md index 9df9258a1..1474bf88e 100644 --- a/docs/index.md +++ b/website/docs/index.md @@ -1,5 +1,5 @@ --- -title: Introduction +title: "Introduction" --- ## What is Yew? diff --git a/docs/more/css.md b/website/docs/more/css.md similarity index 98% rename from docs/more/css.md rename to website/docs/more/css.md index 80ead4835..e15e06e45 100644 --- a/docs/more/css.md +++ b/website/docs/more/css.md @@ -1,5 +1,5 @@ --- -title: CSS +title: "CSS" --- <TODO> diff --git a/docs/more/debugging.md b/website/docs/more/debugging.md similarity index 99% rename from docs/more/debugging.md rename to website/docs/more/debugging.md index 20498c2b1..a2f5815e4 100644 --- a/docs/more/debugging.md +++ b/website/docs/more/debugging.md @@ -1,5 +1,5 @@ --- -title: Debugging +title: "Debugging" --- ## Panics diff --git a/docs/more/development-tips.md b/website/docs/more/development-tips.md similarity index 98% rename from docs/more/development-tips.md rename to website/docs/more/development-tips.md index 221807d2d..b67dcf711 100644 --- a/docs/more/development-tips.md +++ b/website/docs/more/development-tips.md @@ -1,5 +1,5 @@ --- -title: Tips for developing Yew applications +title: "Tips for developing Yew applications" --- :::important contribute diff --git a/docs/more/external-libs.md b/website/docs/more/external-libs.md similarity index 94% rename from docs/more/external-libs.md rename to website/docs/more/external-libs.md index 28100b7e6..6253d09e4 100644 --- a/docs/more/external-libs.md +++ b/website/docs/more/external-libs.md @@ -1,6 +1,6 @@ --- -title: External libraries -description: Libraries that can help with Yew development +title: "External libraries" +description: "Libraries that can help with Yew development" --- ### Yewtil diff --git a/docs/more/roadmap.md b/website/docs/more/roadmap.md similarity index 93% rename from docs/more/roadmap.md rename to website/docs/more/roadmap.md index ecdf9370d..9f6b7079c 100644 --- a/docs/more/roadmap.md +++ b/website/docs/more/roadmap.md @@ -1,6 +1,6 @@ --- -title: Roadmap -description: The planned feature roadmap for the Yew framework +title: "Roadmap" +description: "The planned feature roadmap for the Yew framework" --- ## Prioritization diff --git a/docs/more/testing.md b/website/docs/more/testing.md similarity index 93% rename from docs/more/testing.md rename to website/docs/more/testing.md index 419b1214a..5c0748d2f 100644 --- a/docs/more/testing.md +++ b/website/docs/more/testing.md @@ -1,6 +1,6 @@ --- -title: Testing apps -description: Testing your app +title: "Testing apps" +description: "Testing your app" --- <TODO> diff --git a/docs/more/wasm-build-tools.md b/website/docs/more/wasm-build-tools.md similarity index 93% rename from docs/more/wasm-build-tools.md rename to website/docs/more/wasm-build-tools.md index e6d4855d9..5529e8cd1 100644 --- a/docs/more/wasm-build-tools.md +++ b/website/docs/more/wasm-build-tools.md @@ -1,6 +1,6 @@ --- -title: Wasm Build Tools -description: Information about build tools +title: "Wasm Build Tools" +description: "Information about build tools" --- @@ -20,7 +20,7 @@ It can bundle assets for your app and even ships with a Sass compiler. All of our examples are built with Trunk. -[Getting started with `trunk`](project-setup/using-trunk.md) +[Getting started with `trunk`](../getting-started/project-setup/using-trunk.md) ### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) @@ -29,7 +29,7 @@ together with the [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-pl The primary purpose of `wasm-pack` is building Wasm libraries for use in JavaScript. Because of this, it can only build libraries and doesn't provide useful tools like a development server or automatic rebuilds. -[Get started with `wasm-pack`](project-setup/using-wasm-pack.md) +[Get started with `wasm-pack`](../getting-started/project-setup/using-wasm-pack.md) ### Comparison diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js new file mode 100644 index 000000000..81db01724 --- /dev/null +++ b/website/docusaurus.config.js @@ -0,0 +1,117 @@ +/** @type {import('@docusaurus/types').DocusaurusConfig} */ +module.exports = { + title: 'Yew', + tagline: 'Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.', + url: 'https://yew.rs', + baseUrl: '/', + onBrokenLinks: 'warn', + onBrokenMarkdownLinks: 'warn', + favicon: 'img/favicon.png', + organizationName: 'yewstack', // Usually your GitHub org/user name. + projectName: 'yew', // Usually your repo name. + themeConfig: { + navbar: { + title: 'Yew', + logo: { + alt: 'Yew Logo', + src: 'img/logo.png', + }, + items: [ + { + type: 'docsVersionDropdown', + position: 'left', + }, + { + type: 'localeDropdown', + position: 'left', + }, + { + type: 'doc', + docId: 'index', + position: 'left', + label: 'Docs', + }, + { + href: 'https://docs.rs/yew', + position: 'right', + label: 'API', + }, + { + href: 'https://github.com/yewstack/yew', + label: 'GitHub', + position: 'right', + }, + ], + }, + footer: { + style: 'dark', + links: [ + { + title: 'Support', + items: [ + { + label: 'Fund Issues', + href: 'https://issuehunt.io/r/yewstack/yew', + }, + { + label: 'Sponsor Project', + href: 'https://opencollective.com/yew', + }, + ], + }, + { + title: 'Participate', + items: [ + { + label: 'GitHub', + href: 'https://github.com/yewstack/yew', + }, + { + label: 'Discord', + href: 'https://discord.gg/VQck8X4', + }, + { + label: 'Twitter', + href: 'https://twitter.com/yewstack', + }, + ], + }, + { + title: 'More', + items: [ + { + label: 'Yew Awesome', + href: 'https://github.com/jetli/awesome-yew', + }, + ], + }, + ], + }, + prism: { + // TODO additionalLanguages: ['rust'], + }, + algolia: { + apiKey: "bbaacf676920f3836ccab85fb87dd37c", + indexName: "yew", + } + }, + i18n: { + defaultLocale: 'en', + locales: ['en', 'ja', 'zh-CN', 'zh-TW'], + }, + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + sidebarPath: require.resolve('./sidebars.js'), + editUrl: + 'https://github.com/yewstack/yew/blob/master/website/', + }, + theme: { + customCss: require.resolve('./src/css/custom.css'), + }, + }, + ], + ], +}; diff --git a/website/i18n/en.json b/website/i18n/en.json deleted file mode 100644 index 8809f6533..000000000 --- a/website/i18n/en.json +++ /dev/null @@ -1,337 +0,0 @@ -{ - "_comment": "This file is auto-generated by write-translations.js", - "localized-strings": { - "next": "Next", - "previous": "Previous", - "tagline": "Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.", - "docs": { - "advanced-topics/how-it-works": { - "title": "How it works" - }, - "advanced-topics/optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "concepts/agents": { - "title": "Agents" - }, - "concepts/components": { - "title": "Introduction" - }, - "concepts/components/callbacks": { - "title": "Callbacks" - }, - "concepts/components/children": { - "title": "Children" - }, - "concepts/components/properties": { - "title": "Properties" - }, - "concepts/components/refs": { - "title": "Refs" - }, - "concepts/contexts": { - "title": "Contexts", - "sidebar_label": "Contexts" - }, - "concepts/function-components": { - "title": "Function Components", - "sidebar_label": "Introduction" - }, - "concepts/function-components/attribute": { - "title": "#[function_component]" - }, - "concepts/function-components/custom-hooks": { - "title": "Custom Hooks" - }, - "concepts/function-components/pre-defined-hooks": { - "title": "Pre-defined Hooks" - }, - "concepts/html": { - "title": "HTML", - "sidebar_label": "Introduction" - }, - "concepts/html/classes": { - "title": "Classes" - }, - "concepts/html/components": { - "title": "Components" - }, - "concepts/html/elements": { - "title": "Elements" - }, - "concepts/html/lists": { - "title": "Lists" - }, - "concepts/html/literals-and-expressions": { - "title": "Literals and Expressions" - }, - "concepts/router": { - "title": "Router" - }, - "concepts/services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "concepts/services/fetch": { - "title": "Fetch" - }, - "concepts/services/format": { - "title": "Format" - }, - "getting-started/build-a-sample-app": { - "title": "Build a sample app" - }, - "getting-started/examples": { - "title": "Examples" - }, - "getting-started/project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "getting-started/project-setup/using-trunk": { - "title": "Using trunk" - }, - "getting-started/project-setup/using-wasm-pack": { - "title": "Using wasm-pack" - }, - "getting-started/starter-templates": { - "title": "Starter templates" - }, - "index": { - "title": "Introduction" - }, - "more/css": { - "title": "CSS" - }, - "more/debugging": { - "title": "Debugging" - }, - "more/development-tips": { - "title": "Tips for developing Yew applications" - }, - "more/external-libs": { - "title": "External libraries" - }, - "more/roadmap": { - "title": "Roadmap" - }, - "more/testing": { - "title": "Testing apps" - }, - "more/wasm-build-tools": { - "title": "Wasm Build Tools" - }, - "README": { - "title": "README" - }, - "SUMMARY": { - "title": "SUMMARY" - }, - "version-0.17.3/advanced-topics/version-0.17.3-how-it-works": { - "title": "How it works" - }, - "version-0.17.3/advanced-topics/version-0.17.3-optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "version-0.17.3/concepts/version-0.17.3-agents": { - "title": "Agents" - }, - "version-0.17.3/concepts/version-0.17.3-components": { - "title": "Introduction" - }, - "version-0.17.3/concepts/components/version-0.17.3-callbacks": { - "title": "Callbacks" - }, - "version-0.17.3/concepts/components/version-0.17.3-properties": { - "title": "Properties" - }, - "version-0.17.3/concepts/components/version-0.17.3-refs": { - "title": "Refs" - }, - "version-0.17.3/concepts/version-0.17.3-html": { - "title": "html!", - "sidebar_label": "Introduction" - }, - "version-0.17.3/concepts/html/version-0.17.3-components": { - "title": "Components" - }, - "version-0.17.3/concepts/html/version-0.17.3-elements": { - "title": "Elements" - }, - "version-0.17.3/concepts/html/version-0.17.3-lists": { - "title": "Lists" - }, - "version-0.17.3/concepts/html/version-0.17.3-literals-and-expressions": { - "title": "Literals and Expressions" - }, - "version-0.17.3/concepts/version-0.17.3-router": { - "title": "Router" - }, - "version-0.17.3/concepts/version-0.17.3-services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "version-0.17.3/concepts/services/version-0.17.3-format": { - "title": "Format" - }, - "version-0.17.3/getting-started/version-0.17.3-build-a-sample-app": { - "title": "Build a sample app" - }, - "version-0.17.3/getting-started/version-0.17.3-choose-web-library": { - "title": "Choosing a web library" - }, - "version-0.17.3/getting-started/version-0.17.3-examples": { - "title": "Examples" - }, - "version-0.17.3/getting-started/version-0.17.3-project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "version-0.17.3/getting-started/project-setup/version-0.17.3-using-cargo-web": { - "title": "Using cargo-web" - }, - "version-0.17.3/getting-started/project-setup/version-0.17.3-using-wasm-bindgen": { - "title": "Using wasm-bindgen" - }, - "version-0.17.3/getting-started/project-setup/version-0.17.3-using-wasm-pack": { - "title": "Using wasm-pack" - }, - "version-0.17.3/getting-started/version-0.17.3-starter-templates": { - "title": "Starter templates" - }, - "version-0.17.3/version-0.17.3-index": { - "title": "Introduction" - }, - "version-0.17.3/more/version-0.17.3-css": { - "title": "CSS" - }, - "version-0.17.3/more/version-0.17.3-debugging": { - "title": "Debugging" - }, - "version-0.17.3/more/version-0.17.3-external-libs": { - "title": "External libraries" - }, - "version-0.17.3/more/version-0.17.3-roadmap": { - "title": "Roadmap" - }, - "version-0.17.3/more/version-0.17.3-testing": { - "title": "Testing apps" - }, - "version-0.18.0/advanced-topics/version-0.18.0-how-it-works": { - "title": "How it works" - }, - "version-0.18.0/advanced-topics/version-0.18.0-optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "version-0.18.0/concepts/version-0.18.0-components": { - "title": "Introduction" - }, - "version-0.18.0/concepts/components/version-0.18.0-callbacks": { - "title": "Callbacks" - }, - "version-0.18.0/concepts/components/version-0.18.0-children": { - "title": "Children" - }, - "version-0.18.0/concepts/components/version-0.18.0-properties": { - "title": "Properties" - }, - "version-0.18.0/concepts/components/version-0.18.0-refs": { - "title": "Refs" - }, - "version-0.18.0/concepts/version-0.18.0-function-components": { - "title": "Function Components", - "sidebar_label": "Introduction" - }, - "version-0.18.0/concepts/function-components/version-0.18.0-attribute": { - "title": "#[function_component]" - }, - "version-0.18.0/concepts/function-components/version-0.18.0-custom-hooks": { - "title": "Custom Hooks" - }, - "version-0.18.0/concepts/function-components/version-0.18.0-pre-defined-hooks": { - "title": "Pre-defined Hooks" - }, - "version-0.18.0/concepts/version-0.18.0-html": { - "title": "HTML", - "sidebar_label": "Introduction" - }, - "version-0.18.0/concepts/html/version-0.18.0-classes": { - "title": "Classes" - }, - "version-0.18.0/concepts/html/version-0.18.0-components": { - "title": "Components" - }, - "version-0.18.0/concepts/html/version-0.18.0-elements": { - "title": "Elements" - }, - "version-0.18.0/concepts/html/version-0.18.0-lists": { - "title": "Lists" - }, - "version-0.18.0/concepts/version-0.18.0-router": { - "title": "Router" - }, - "version-0.18.0/concepts/services/version-0.18.0-fetch": { - "title": "Fetch" - }, - "version-0.18.0/getting-started/version-0.18.0-build-a-sample-app": { - "title": "Build a sample app" - }, - "version-0.18.0/getting-started/version-0.18.0-choose-web-library": { - "title": "Choosing a web library" - }, - "version-0.18.0/getting-started/version-0.18.0-examples": { - "title": "Examples" - }, - "version-0.18.0/getting-started/version-0.18.0-project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "version-0.18.0/getting-started/project-setup/version-0.18.0-using-trunk": { - "title": "Using trunk" - }, - "version-0.18.0/getting-started/project-setup/version-0.18.0-using-wasm-pack": { - "title": "Using wasm-pack" - }, - "version-0.18.0/getting-started/version-0.18.0-starter-templates": { - "title": "Starter templates" - }, - "version-0.18.0/version-0.18.0-index": { - "title": "Introduction" - }, - "version-0.18.0/more/version-0.18.0-css": { - "title": "CSS" - }, - "version-0.18.0/more/version-0.18.0-debugging": { - "title": "Debugging" - }, - "version-0.18.0/more/version-0.18.0-external-libs": { - "title": "External libraries" - }, - "version-0.18.0/more/version-0.18.0-roadmap": { - "title": "Roadmap" - }, - "version-0.18.0/more/version-0.18.0-testing": { - "title": "Testing apps" - } - }, - "links": { - "Changelog": "Changelog", - "API": "API", - "Discord": "Discord" - }, - "categories": { - "Getting Started": "Getting Started", - "Concepts": "Concepts", - "Advanced topics": "Advanced topics", - "More": "More" - } - }, - "pages-strings": { - "Help Translate|recruit community translators for your project": "Help Translate", - "Edit this Doc|recruitment message asking to edit the doc source": "Edit", - "Translate this Doc|recruitment message asking to translate the docs": "Translate" - } -} diff --git a/website/i18n/ja.json b/website/i18n/ja.json deleted file mode 100644 index af4d0b11b..000000000 --- a/website/i18n/ja.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "localized-strings": { - "next": "Next", - "previous": "Previous", - "tagline": "Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.", - "docs": { - "advanced-topics/how-it-works": { - "title": "How it works" - }, - "advanced-topics/optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "concepts/agents": { - "title": "Agents" - }, - "concepts/components": { - "title": "Introduction" - }, - "concepts/components/callbacks": { - "title": "Callbacks" - }, - "concepts/components/properties": { - "title": "Properties" - }, - "concepts/components/refs": { - "title": "Refs" - }, - "concepts/html": { - "title": "html!", - "sidebar_label": "Introduction" - }, - "concepts/html/components": { - "title": "Components" - }, - "concepts/html/elements": { - "title": "Elements" - }, - "concepts/html/lists": { - "title": "Lists" - }, - "concepts/html/literals-and-expressions": { - "title": "Literals and Expressions" - }, - "concepts/router": { - "title": "Router" - }, - "concepts/services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "concepts/services/format": { - "title": "Format" - }, - "getting-started/build-a-sample-app": { - "title": "Build a sample app" - }, - "getting-started/choose-web-library": { - "title": "Choosing a web library" - }, - "getting-started/examples": { - "title": "Examples" - }, - "getting-started/project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "getting-started/project-setup/using-cargo-web": { - "title": "Using cargo-web" - }, - "getting-started/project-setup/using-wasm-bindgen": { - "title": "Using wasm-bindgen" - }, - "getting-started/project-setup/using-wasm-pack": { - "title": "Using wasm-pack" - }, - "getting-started/starter-templates": { - "title": "Starter templates" - }, - "index": { - "title": "Introduction" - }, - "more/css": { - "title": "CSS" - }, - "more/debugging": { - "title": "Debugging" - }, - "more/external-libs": { - "title": "External libraries" - }, - "more/roadmap": { - "title": "Roadmap" - }, - "more/testing": { - "title": "Testing apps" - }, - "README": { - "title": "README" - }, - "SUMMARY": { - "title": "SUMMARY" - }, - "version-0.17.3-advanced-topics/how-it-works": { - "title": "How it works" - }, - "version-0.17.3-advanced-topics/optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "version-0.17.3-concepts/agents": { - "title": "Agents" - }, - "version-0.17.3-concepts/components": { - "title": "Introduction" - }, - "version-0.17.3-concepts/components/callbacks": { - "title": "Callbacks" - }, - "version-0.17.3-concepts/components/properties": { - "title": "Properties" - }, - "version-0.17.3-concepts/components/refs": { - "title": "Refs" - }, - "version-0.17.3-concepts/html": { - "title": "html!", - "sidebar_label": "Introduction" - }, - "version-0.17.3-concepts/html/components": { - "title": "Components" - }, - "version-0.17.3-concepts/html/elements": { - "title": "Elements" - }, - "version-0.17.3-concepts/html/lists": { - "title": "Lists" - }, - "version-0.17.3-concepts/html/literals-and-expressions": { - "title": "Literals and Expressions" - }, - "version-0.17.3-concepts/router": { - "title": "Router" - }, - "version-0.17.3-concepts/services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "version-0.17.3-concepts/services/format": { - "title": "Format" - }, - "version-0.17.3-getting-started/build-a-sample-app": { - "title": "Build a sample app" - }, - "version-0.17.3-getting-started/choose-web-library": { - "title": "Choosing a web library" - }, - "version-0.17.3-getting-started/examples": { - "title": "Examples" - }, - "version-0.17.3-getting-started/project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "version-0.17.3-getting-started/project-setup/using-cargo-web": { - "title": "Using cargo-web" - }, - "version-0.17.3-getting-started/project-setup/using-wasm-bindgen": { - "title": "Using wasm-bindgen" - }, - "version-0.17.3-getting-started/project-setup/using-wasm-pack": { - "title": "Using wasm-pack" - }, - "version-0.17.3-getting-started/starter-templates": { - "title": "Starter templates" - }, - "version-0.17.3-index": { - "title": "Introduction" - }, - "version-0.17.3-more/css": { - "title": "CSS" - }, - "version-0.17.3-more/debugging": { - "title": "Debugging" - }, - "version-0.17.3-more/external-libs": { - "title": "External libraries" - }, - "version-0.17.3-more/roadmap": { - "title": "Roadmap" - }, - "version-0.17.3-more/testing": { - "title": "Testing apps" - } - }, - "links": { - "Changelog": "Changelog", - "API": "API", - "Discord": "Discord" - }, - "categories": { - "Getting Started": "Getting Started", - "Concepts": "Concepts", - "Advanced topics": "Advanced topics", - "More": "More" - } - }, - "pages-strings": { - "Help Translate|recruit community translators for your project": "Help Translate", - "Edit this Doc|recruitment message asking to edit the doc source": "Edit", - "Translate this Doc|recruitment message asking to translate the docs": "Translate" - } -} diff --git a/website/translated_docs/ja/version-0.17.3/SUMMARY.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/SUMMARY.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/SUMMARY.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/SUMMARY.md diff --git a/website/translated_docs/ja/advanced-topics/how-it-works.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/advanced-topics/how-it-works.md similarity index 100% rename from website/translated_docs/ja/advanced-topics/how-it-works.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/advanced-topics/how-it-works.md diff --git a/website/translated_docs/ja/advanced-topics/optimizations.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/advanced-topics/optimizations.md similarity index 100% rename from website/translated_docs/ja/advanced-topics/optimizations.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/advanced-topics/optimizations.md diff --git a/website/translated_docs/ja/concepts/agents.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/agents.md similarity index 100% rename from website/translated_docs/ja/concepts/agents.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/agents.md diff --git a/website/translated_docs/ja/concepts/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components.md similarity index 100% rename from website/translated_docs/ja/concepts/components.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components.md diff --git a/website/translated_docs/ja/concepts/components/callbacks.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/callbacks.md similarity index 100% rename from website/translated_docs/ja/concepts/components/callbacks.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/callbacks.md diff --git a/website/translated_docs/ja/concepts/components/properties.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/properties.md similarity index 100% rename from website/translated_docs/ja/concepts/components/properties.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/properties.md diff --git a/website/translated_docs/ja/concepts/components/refs.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/refs.md similarity index 100% rename from website/translated_docs/ja/concepts/components/refs.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/components/refs.md diff --git a/website/translated_docs/ja/concepts/html.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html.md similarity index 100% rename from website/translated_docs/ja/concepts/html.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html.md diff --git a/website/translated_docs/ja/concepts/html/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/components.md similarity index 100% rename from website/translated_docs/ja/concepts/html/components.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/components.md diff --git a/website/translated_docs/ja/concepts/html/elements.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/elements.md similarity index 100% rename from website/translated_docs/ja/concepts/html/elements.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/elements.md diff --git a/website/translated_docs/ja/concepts/html/lists.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/lists.md similarity index 100% rename from website/translated_docs/ja/concepts/html/lists.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/lists.md diff --git a/website/translated_docs/ja/concepts/html/literals-and-expressions.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/literals-and-expressions.md similarity index 100% rename from website/translated_docs/ja/concepts/html/literals-and-expressions.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/html/literals-and-expressions.md diff --git a/website/translated_docs/ja/concepts/router.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/router.md similarity index 100% rename from website/translated_docs/ja/concepts/router.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/router.md diff --git a/website/translated_docs/ja/concepts/services.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/services.md similarity index 100% rename from website/translated_docs/ja/concepts/services.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/services.md diff --git a/website/translated_docs/ja/concepts/services/format.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/services/format.md similarity index 100% rename from website/translated_docs/ja/concepts/services/format.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/concepts/services/format.md diff --git a/website/translated_docs/ja/getting-started/build-a-sample-app.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/build-a-sample-app.md similarity index 100% rename from website/translated_docs/ja/getting-started/build-a-sample-app.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/build-a-sample-app.md diff --git a/website/translated_docs/ja/getting-started/choose-web-library.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/choose-web-library.md similarity index 68% rename from website/translated_docs/ja/getting-started/choose-web-library.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/choose-web-library.md index e1d623cdc..58b3672fc 100644 --- a/website/translated_docs/ja/getting-started/choose-web-library.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/choose-web-library.md @@ -49,36 +49,36 @@ window.alert("hello from wasm!"); - - + - - - + - + - - - + + + - - + - + - - + - - - + -
web-sys + web-sys stdweb + stdweb
プロジェクトの進捗状況 + プロジェクトの進捗状況 Rust / Wasm 活動チームにより活発にメンテナンスされている GitHubで8ヶ月間動きなしGitHubで8ヶ月間動きなし
Web API のカバーRustのAPIはWeb IDLスペックから自動的に生成される。Browser APIはコミュニティにより追加。Web API のカバーRustのAPIはWeb IDLスペックから自動的に生成される。Browser APIはコミュニティにより追加。
RustのAPIのデザイン + RustのAPIのデザイン ほとんどのAPIコールおいてResultが返ってくるよう保守的なアプローチがとられている。 しばしばResultを返さずpanicするようになっている。例えば stdweb::web::window()ワーカーの中で呼ばれるパニックする。しばしばResultを返さずpanicするようになっている。例えば stdweb::web::window()ワーカーの中で呼ばれるパニックする。
サポートされているビルドツール + サポートされているビルドツール

  • wasm-bindgen @@ -87,7 +87,7 @@ window.alert("hello from wasm!");
+

  • cargo-web @@ -100,14 +100,14 @@ window.alert("hello from wasm!");
サポートされているターゲット + サポートされているターゲット
  • wasm32-unknown-unknown
+
  • wasm32-unknown-unknown
  • diff --git a/website/translated_docs/ja/getting-started/examples.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/examples.md similarity index 100% rename from website/translated_docs/ja/getting-started/examples.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/examples.md diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup.md new file mode 100644 index 000000000..a34cd61b5 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup.md @@ -0,0 +1,142 @@ +--- +title: Introduction +description: Set yourself up for success +--- + +# 始める + +## Rust + +まずはじめにRustが必要です。Rustとビルドツールの`cargo`をインストールするために、以下の[公式サイト](https://www.rust-lang.org/tools/install) +を見てください。 + +## **Wasm ビルドツール** + +WebAssemblyとJavaScriptの互換を持たせるために他にツールが必要です。さらに、選んだツールに応じてブラウザでアプリから`.wasm`ファイルを実行するのに +必要なJavaScriptラッパーのコードを生成し、これによってデプロイやパッケージ化での頭痛の種を軽減させるのに役立ちます。 + +### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) + +Rust / Wasm活動チームによって開発されているCLIツールで、WebAssemblyをパッケージ化することができます。 +Webpackには[`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin)が最もよく使われています。 + +[`wasm-pack`で始める](project-setup/using-wasm-pack.md) + +### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/) + +Rust/Wasm活動チームによって開発されているライブラリとCLIツールで、JS / WebAssemblyの互換性を持たせるための低レベルなツールです +(`wasm-pack`で内部的に使われています)。 +`wasm-bindgen`は手書きのJavaScriptでWebAssemblyのバイナリを使う必要があるため、直接使うのは非推奨です。 +しかし、詳細な情報については[**`wasm-bindgen` ガイド**](https://rustwasm.github.io/docs/wasm-bindgen/)から得られます。 + +[`wasm-bindgen`で始める。](project-setup/using-wasm-bindgen.md) + +### [**`cargo-web`**](https://github.com/koute/cargo-web) + +`wasm-pack`と`wasm-bindgen`を導入する前は好まれたWebワークフローツールです。 +`wasm-pack`がサポートされていないサンプルを動かすのにインストールする価値があり、依然として**最もお手軽に**始められる方法です。 + +[`cargo web`で始める](project-setup/using-cargo-web.md) + +### 比較 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    wasm-pack + wasm-bindgen + cargo-web +
    プロジェクトの進行状況Rust / Wasm活動チームにより活発にメンテナンス + Rust / Wasm 活動チームにより活発にメンテナンス + 6ヶ月間GitHubでの活発な活動無し
    開発体験ほぼ大丈夫! webpackがあればなお良い。だいたい大丈夫。開発においては少し流れを書かないといけない。しっかり動く!完結していて、外部ライブラリに頼る必要無し。
    ローカルサーバーwebpackプラグインによるサポートありサポート無しサポートあり
    ローカル環境での変更による自動再ビルドwebpackプラグインによるサポートありサポート無しサポートあり
    ヘッドレスブラウザテストサポートあり + サポートあり + サポートあり +
    サポートされているターゲット +
      +
    • wasm32-unknown-unknown +
    • +
    +
    +
      +
    • wasm32-unknown-unknown +
    • +
    +
    +
      +
    • wasm32-unknown-unknown +
    • +
    • wasm32-unknown-emscripten +
    • +
    • asmjs-unknown-emscripten +
    • +
    +
    web-sys互換性あり互換性あり互換性無し
    stdweb互換性あり互換性あり互換性あり
    使用例入門用テンプレート + + Yewで作る例 + + Yewで作る例 +
    + diff --git a/website/translated_docs/ja/getting-started/project-setup/using-cargo-web.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-cargo-web.md similarity index 100% rename from website/translated_docs/ja/getting-started/project-setup/using-cargo-web.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-cargo-web.md diff --git a/website/translated_docs/ja/getting-started/project-setup/using-wasm-bindgen.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-wasm-bindgen.md similarity index 100% rename from website/translated_docs/ja/getting-started/project-setup/using-wasm-bindgen.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-wasm-bindgen.md diff --git a/website/translated_docs/ja/getting-started/project-setup/using-wasm-pack.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-wasm-pack.md similarity index 100% rename from website/translated_docs/ja/getting-started/project-setup/using-wasm-pack.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/project-setup/using-wasm-pack.md diff --git a/website/translated_docs/ja/getting-started/starter-templates.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/starter-templates.md similarity index 100% rename from website/translated_docs/ja/getting-started/starter-templates.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/getting-started/starter-templates.md diff --git a/website/translated_docs/ja/index.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/index.md similarity index 100% rename from website/translated_docs/ja/index.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/index.md diff --git a/website/translated_docs/ja/more/css.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/css.md similarity index 100% rename from website/translated_docs/ja/more/css.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/css.md diff --git a/website/translated_docs/ja/more/debugging.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/debugging.md similarity index 100% rename from website/translated_docs/ja/more/debugging.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/debugging.md diff --git a/website/translated_docs/ja/more/external-libs.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/external-libs.md similarity index 100% rename from website/translated_docs/ja/more/external-libs.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/external-libs.md diff --git a/website/translated_docs/ja/more/roadmap.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/roadmap.md similarity index 100% rename from website/translated_docs/ja/more/roadmap.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/roadmap.md diff --git a/website/translated_docs/ja/more/testing.md b/website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/testing.md similarity index 100% rename from website/translated_docs/ja/more/testing.md rename to website/i18n/ja/docusaurus-plugin-content-docs/0.17.3/more/testing.md diff --git a/website/translated_docs/ja/version-0.17.3/advanced-topics/how-it-works.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/advanced-topics/how-it-works.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/advanced-topics/how-it-works.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/advanced-topics/how-it-works.md diff --git a/website/translated_docs/ja/version-0.17.3/advanced-topics/optimizations.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/advanced-topics/optimizations.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/advanced-topics/optimizations.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/advanced-topics/optimizations.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/agents.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/agents.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/agents.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/agents.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/components.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/components/callbacks.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/callbacks.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/components/callbacks.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/callbacks.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/components/properties.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/properties.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/components/properties.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/properties.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/components/refs.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/refs.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/components/refs.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/components/refs.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/html.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/html.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/html/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/components.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/html/components.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/components.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/html/elements.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/elements.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/html/elements.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/elements.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/html/lists.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/lists.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/html/lists.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/lists.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/html/literals-and-expressions.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/literals-and-expressions.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/html/literals-and-expressions.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/html/literals-and-expressions.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/router.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/router.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/router.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/router.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/services.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/services.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/services.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/services.md diff --git a/website/translated_docs/ja/version-0.17.3/concepts/services/format.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/services/format.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/concepts/services/format.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/services/format.md diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/build-a-sample-app.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/build-a-sample-app.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/build-a-sample-app.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/build-a-sample-app.md diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/choose-web-library.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md similarity index 68% rename from website/translated_docs/ja/version-0.17.3/getting-started/choose-web-library.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md index e1d623cdc..58b3672fc 100644 --- a/website/translated_docs/ja/version-0.17.3/getting-started/choose-web-library.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md @@ -49,36 +49,36 @@ window.alert("hello from wasm!"); - - + - - - + - + - - - + + + - - + - + - - + - - - + -
    web-sys + web-sys stdweb + stdweb
    プロジェクトの進捗状況 + プロジェクトの進捗状況 Rust / Wasm 活動チームにより活発にメンテナンスされている GitHubで8ヶ月間動きなしGitHubで8ヶ月間動きなし
    Web API のカバーRustのAPIはWeb IDLスペックから自動的に生成される。Browser APIはコミュニティにより追加。Web API のカバーRustのAPIはWeb IDLスペックから自動的に生成される。Browser APIはコミュニティにより追加。
    RustのAPIのデザイン + RustのAPIのデザイン ほとんどのAPIコールおいてResultが返ってくるよう保守的なアプローチがとられている。 しばしばResultを返さずpanicするようになっている。例えば stdweb::web::window()ワーカーの中で呼ばれるパニックする。しばしばResultを返さずpanicするようになっている。例えば stdweb::web::window()ワーカーの中で呼ばれるパニックする。
    サポートされているビルドツール + サポートされているビルドツール

    • wasm-bindgen @@ -87,7 +87,7 @@ window.alert("hello from wasm!");
    +

    • cargo-web @@ -100,14 +100,14 @@ window.alert("hello from wasm!");
    サポートされているターゲット + サポートされているターゲット
    • wasm32-unknown-unknown
    +
    • wasm32-unknown-unknown
    • diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/examples.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/examples.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/examples.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/examples.md diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup.md new file mode 100644 index 000000000..a34cd61b5 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup.md @@ -0,0 +1,142 @@ +--- +title: Introduction +description: Set yourself up for success +--- + +# 始める + +## Rust + +まずはじめにRustが必要です。Rustとビルドツールの`cargo`をインストールするために、以下の[公式サイト](https://www.rust-lang.org/tools/install) +を見てください。 + +## **Wasm ビルドツール** + +WebAssemblyとJavaScriptの互換を持たせるために他にツールが必要です。さらに、選んだツールに応じてブラウザでアプリから`.wasm`ファイルを実行するのに +必要なJavaScriptラッパーのコードを生成し、これによってデプロイやパッケージ化での頭痛の種を軽減させるのに役立ちます。 + +### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) + +Rust / Wasm活動チームによって開発されているCLIツールで、WebAssemblyをパッケージ化することができます。 +Webpackには[`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin)が最もよく使われています。 + +[`wasm-pack`で始める](project-setup/using-wasm-pack.md) + +### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/) + +Rust/Wasm活動チームによって開発されているライブラリとCLIツールで、JS / WebAssemblyの互換性を持たせるための低レベルなツールです +(`wasm-pack`で内部的に使われています)。 +`wasm-bindgen`は手書きのJavaScriptでWebAssemblyのバイナリを使う必要があるため、直接使うのは非推奨です。 +しかし、詳細な情報については[**`wasm-bindgen` ガイド**](https://rustwasm.github.io/docs/wasm-bindgen/)から得られます。 + +[`wasm-bindgen`で始める。](project-setup/using-wasm-bindgen.md) + +### [**`cargo-web`**](https://github.com/koute/cargo-web) + +`wasm-pack`と`wasm-bindgen`を導入する前は好まれたWebワークフローツールです。 +`wasm-pack`がサポートされていないサンプルを動かすのにインストールする価値があり、依然として**最もお手軽に**始められる方法です。 + +[`cargo web`で始める](project-setup/using-cargo-web.md) + +### 比較 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      wasm-pack + wasm-bindgen + cargo-web +
      プロジェクトの進行状況Rust / Wasm活動チームにより活発にメンテナンス + Rust / Wasm 活動チームにより活発にメンテナンス + 6ヶ月間GitHubでの活発な活動無し
      開発体験ほぼ大丈夫! webpackがあればなお良い。だいたい大丈夫。開発においては少し流れを書かないといけない。しっかり動く!完結していて、外部ライブラリに頼る必要無し。
      ローカルサーバーwebpackプラグインによるサポートありサポート無しサポートあり
      ローカル環境での変更による自動再ビルドwebpackプラグインによるサポートありサポート無しサポートあり
      ヘッドレスブラウザテストサポートあり + サポートあり + サポートあり +
      サポートされているターゲット +
        +
      • wasm32-unknown-unknown +
      • +
      +
      +
        +
      • wasm32-unknown-unknown +
      • +
      +
      +
        +
      • wasm32-unknown-unknown +
      • +
      • wasm32-unknown-emscripten +
      • +
      • asmjs-unknown-emscripten +
      • +
      +
      web-sys互換性あり互換性あり互換性無し
      stdweb互換性あり互換性あり互換性あり
      使用例入門用テンプレート + + Yewで作る例 + + Yewで作る例 +
      + diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-cargo-web.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-cargo-web.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-cargo-web.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-cargo-web.md diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-bindgen.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-bindgen.md diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-wasm-pack.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-pack.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/project-setup/using-wasm-pack.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-pack.md diff --git a/website/translated_docs/ja/version-0.17.3/getting-started/starter-templates.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/starter-templates.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/getting-started/starter-templates.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/starter-templates.md diff --git a/website/translated_docs/ja/version-0.17.3/index.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/index.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/index.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/index.md diff --git a/website/translated_docs/ja/version-0.17.3/more/css.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/more/css.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/more/css.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/more/css.md diff --git a/website/translated_docs/ja/version-0.17.3/more/debugging.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/more/debugging.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/more/debugging.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/more/debugging.md diff --git a/website/translated_docs/ja/version-0.17.3/more/external-libs.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/more/external-libs.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/more/external-libs.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/more/external-libs.md diff --git a/website/translated_docs/ja/version-0.17.3/more/roadmap.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/more/roadmap.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/more/roadmap.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/more/roadmap.md diff --git a/website/translated_docs/ja/version-0.17.3/more/testing.md b/website/i18n/ja/docusaurus-plugin-content-docs/current/more/testing.md similarity index 100% rename from website/translated_docs/ja/version-0.17.3/more/testing.md rename to website/i18n/ja/docusaurus-plugin-content-docs/current/more/testing.md diff --git a/website/translated_docs/ja/SUMMARY.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md similarity index 100% rename from website/translated_docs/ja/SUMMARY.md rename to website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md new file mode 100644 index 000000000..3de4633e2 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md @@ -0,0 +1,9 @@ +--- +title: How it works +description: Low level details about the framework +--- + +# 低レベルなライブラリの中身 + +コンポーネントのライフサイクルの状態機械、VDOMの異なるアルゴリズム + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md new file mode 100644 index 000000000..23302ba93 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md @@ -0,0 +1,186 @@ +--- +title: Optimizations +description: Make your app faster +--- + +# 最適化とベストプラクティス + +## neq\_assign + +親コンポーネントからpropsを受け取った際、`change`メソッドが呼ばれます。 +これはコンポーネントの状態を更新することができるのに加え、コンポーネントがpropsが変わった際に再レンダリングするかどうかを決める +`ShouldRender`という真偽値を返すことができます。 + +再レンダリングはコストがかかるもので、もし避けられるのであれば避けるべきです。 +一般的なルールとしてpropsが実際に変化した際にのみ再レンダリングすれば良いでしょう。 +以下のコードブロックはこのルールを表しており、propsが前と変わったときに`true`を返します。 + +```rust +use yew::ShouldRender; + +#[derive(PartialEq)] +struct ExampleProps; + +struct Example { + props: ExampleProps, +}; + +impl Example { + fn change(&mut self, props: ExampleProps) -> ShouldRender { + if self.props != props { + self.props = props; + true + } else { + false + } + } +} +``` + +しかし我々は先に進んでいけます! +この6行のボイラープレードは`PartialEq`を実装したものにトレイトとブランケットを用いることで1行のコードへと落とし込むことができます。 +[こちら](https://docs.rs/yewtil/*/yewtil/trait.NeqAssign.html)にて`yewtil`クレートの`NewAssign`トレイトを見てみてください。 + +## 効果的にスマートポインタを使う + +**注意: このセクションで使われている用語がわからなければRust bookは +[スマートポインタについての章](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html) +があり、非常に有用です。** + +再レンダリングの際にpropsを作るデータを大量にコピーしないために、スマートポインタを用いてデータ自体ではなくデータへの参照だけを +コピーできます。 +propsや子コンポーネントで関連するデータに実データではなく参照を渡すと、子コンポーネントでデータを変更する必要がなければ +データのコピーを避けることができます。 +その際、`Rc::make_mut`によって変更したいデータの変更可能な参照を得ることができます。 + +これにより、propsが変更されたときにコンポーネントが再レンダリングされるかどうかを決めるかで`Component::change`に更なる恩恵があります。 +なぜなら、データの値を比較する代わりに元々のポインタのアドレス (つまりデータが保管されている機械のメモリの場所) を比較できるためです。 +2つのポインターが同じデータを指す場合、それらのデータの値は同じでなければならないのです。 +ただし、その逆は必ずしも成り立たないことに注意してください! +もし2つのポインタが異なるのであれば、そのデータは同じである可能性があります。 +この場合はデータを比較するべきでしょう。 + +この比較においては`PartialEq`ではなく`Rc::ptr_eq`を使う必要があります。 +`PartialEq`は等価演算子`==`を使う際に自動的に使われます。 +Rustのドキュメントには[`Rc::ptr_eq`についてより詳しく書いてあります](https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.ptr_eq)。 + +この最適化は`Copy`を実装していないデータの型に対して極めて有効なものです。 +もしデータを簡単に変更できるのであれば、スマートポインタに取り換える必要はありません。 +しかし`Vec`や`HashMap`、`String`などのような重たいデータの構造体に対してはスマートポインタを使うことで +パフォーマンスを改善することができるでしょう。 + +この最適化は値がまだ一度も子によって更新されていない場合に極めて有効で、親からほとんど更新されない場合においてもかなり有効です。 +これにより、`Rc<_>s`が純粋なコンポーネントに対してプロパティの値をラップする良い一手となります。 + +## View関数 + +コードの可読性の理由から`html!`の部分を関数へと移植するのは意味があります。 +これは、インデントを減らすのでコードを読みやすくするだけでなく、良いデザインパターンを産むことにも繋がるのです。 +これらの関数は複数箇所で呼ばれて書くべきコード量を減らせるため、分解可能なアプリケーションを作ることができるのです。 + +## 純粋なコンポーネント + +純粋なコンポーネントは状態を変化せず、ただ中身を表示してメッセージを普通の変更可能なコンポーネントへ渡すコンポーネントのことです。 +View関数との違いとして、純粋なコンポーネントは式の構文\(`{some_view_function()}`\)ではなく +コンポーネントの構文\(``\)を使うことで`html!`マクロの中で呼ばれる点、 +そして実装次第で記憶され (つまり、一度関数が呼ばれれば値は"保存"され、 +同じ引数でもう一度呼ばれても値を再計算する必要がなく最初に関数が呼ばれたときの保存された値を返すことができる)、 +先述の`neq_assign`ロジックを使う別々のpropsで再レンダリングを避けられる点があります。 + +Yewは純粋な関数やコンポーネントをサポートしていませんが、外部のクレートを用いることで実現できます。 + +## 関数型コンポーネント (a.k.a フック) + +関数型コンポーネントはまだ開発中です! +開発状況については[プロジェクトボード](https://github.com/yewstack/yew/projects/3)に詳しく書いてあります。 + +## キー付きDOMノード + +## ワークスペースでコンパイル時間を減らす + +間違いなくYewを使う上での最大の欠点はコンパイルに時間がかかる点です。 +プロジェクトのコンパイルにかかる時間は`html!`マクロに渡されるコードの量に関係しています。 +これは小さなプロジェクトにはそこまで問題ないようですが、大きなアプリではコードを複数クレートに分割することでアプリに変更が加られた際に +コンパイラの作業量を減らすのが有効です。 + +一つ可能なやり方として、ルーティングとページ洗濯を担当するメインのクレートを作り、それぞれのページに対して別のクレートを作ることです。 +そうして各ページは異なるコンポーネントか、`Html`を生成する大きな関数となります。 +アプリの異なる部分を含むクレート同士で共有されるコードはプロジェクト全体で依存する分離したクレートに保存されます。 +理想的には1回のコンパイルでコード全てを再ビルドせずメインのクレートかどれかのページのクレートを再ビルドするだけにすることです。 +最悪なのは、"共通"のクレートを編集して、はじめに戻ってくることです: +共有のクレートに依存している全てのコード、恐らく全てのコードをコンパイルすることです。 + +もしメインのクレートが重たすぎる、もしくは深くネストしたページ (例えば別ページのトップでレンダリングされるページ) +で速く繰り返したい場合、クレートの例を用いてメインページの実装をシンプルにしたりトップで動かしているコンポーネントをレンダリングできます。 + +## バイナリサイズを小さくする + +* Rustのコードを最適化する + * `wee_alloc` \( tiny allocatorを使用 \) + * `cargo.toml` \( release profileを定義 \) +* `wasm-opt`を用いてwasmのコードを最適化する + +**注意: バイナリサイズを小さくするのについては[Rust Wasm Book](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size)に詳しく書いてあります。** + +### wee\_alloc + +[wee\_alloc](https://github.com/rustwasm/wee_alloc)は小さなアロケーターで、Rustのバイナリで使用される通常のものより遥かに小さなものです。 +デフォルトのアロケーターと置き換えることで、Wasmファイルをより小さくすることができ、速度とメモリのオーバーヘッドを軽減できます。 + +デフォルトのアロケータを含めないことによるサイズの増加と比較して、速度とメモリのオーバーヘッドが悪くなります。 +ファイルサイズが小さいことで、ページの読み込みが速くなります。 +そのため、アロケーションのタスクが非常に多い場合でなければデフォルトのものではなくtiny allocatorを利用することが一般的に推奨されています。 + +```rust +// `wee_alloc`を使用する。 +#[global_allocator] +static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; +``` + +### Cargo.toml + +`Cargo.toml`で`[profile.release]`のセクションに設定を書き込むことでリリースビルドを小さくすることが可能です。 + +```text +[profile.release] +# バイナリに含むコードを少なくする +panic = 'abort' +# コードベース全体での最適化 ( 良い最適化だがビルドが遅くなる) +codegen-units = 1 +# サイズの最適化( よりアグレッシブに ) +opt-level = 'z' +# サイズの最適化 +# opt-level = 's' +# プログラム全体の分析によるリンク時最適化 +lto = true +``` + +### wasm-opt + +更に`wasm`のコードのサイズを最適化することができます。 + +The Rust Wasm BookにはWasmバイナリのサイズを小さくすることについてのセクションがあります: +[Shrinking .wasm size](https://rustwasm.github.io/book/game-of-life/code-size.html) + +* `wasm-pack`でデフォルトの`wasm`のコードをリリースビルド時に最適化する +* `wasm-opt`によって直接`wasm`ファイルを最適化する + +```text +wasm-opt wasm_bg.wasm -Os -o wasm_bg_opt.wasm +``` + +#### yew/examples/にある例を小さなサイズでビルドする + +注意: `wasm-pack`はRustとWasmのコードへの最適化を組み合わせます。`wasm-bindgen`はこの例ではRustのサイズ最適化を用いていません。 + +| 使用したツール | サイズ | +| :--- | :--- | +| wasm-bindgen | 158KB | +| wasm-bindgen + wasm-opt -Os | 116KB | +| wasm-pack | 99 KB | + +## 参考文献: + * [The Rust Bookのスマートポインタに関する章](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html) + * [the Rust Wasm Bookでのバイナリサイズを小さくすることについて](https://rustwasm.github.io/book/reference/code-size.html#optimizing-builds-for-code-size) + * [Rust profilesについてのドキュメント](https://doc.rust-lang.org/cargo/reference/profiles.html) + * [binaryenプロジェクト](https://github.com/WebAssembly/binaryen) diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md new file mode 100644 index 000000000..5c3300559 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md @@ -0,0 +1,56 @@ +--- +title: Agents +description: Yew's Actor System +--- + +エージェントはAngularの[サービス](https://angular.io/guide/architecture-services)に似ており\(ただし依存性インジェクションはありません\)、 +[アクターモデル](https://en.wikipedia.org/wiki/Actor_model)を提供します。 +エージェントはコンポーネント階層のどこに位置するかに関わらず、コンポーネント間でメッセージをルーティングしたり、共有状態を作成したり、UIをレンダリングするメインスレッドから計算量の多いタスクをオフロードするために使用することができます。 +また、Yew アプリケーションがタブをまたいで通信できるようにするためのエージェントのサポートも\(将来的には\)計画されています。 + +エージェントが並行に動くようにYewは[web-workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers)を使用しています。 + +## ライフサイクル + +![エージェントのライフサイクル](https://user-images.githubusercontent.com/42674621/79125224-b6481d80-7d95-11ea-8e6a-ab9b52d1d8ac.png) + +## エージェントの種類 + +### Reaches + +* Context - Contextエージェントのインスタンスは、常に最大1つ存在します。 + Bridgesは、UIスレッド上で既にスポーンされたエージェントをスポーンするか、接続します。 + これは、コンポーネントまたは他のエージェント間の状態を調整するために使用することができます。 + このエージェントにBridgesが接続されていない場合、このエージェントは消滅します。 + +* Job - 新しいブリッジごとにUIスレッド上で新しいエージェントをスポーンします。 + これは、ブラウザと通信する共有されているが独立した動作をコンポーネントの外に移動させるのに適しています。 + (TODO 確認) タスクが完了すると、エージェントは消えます。 + +* Public - Contextと同じですが、独自のweb workerで動作します。 + +* Private - Jobと同じですが、独自のweb workerで動作します。 + +* Global \(WIP\) + +## エージェントとコンポーネントのやり取り + +### Bridges + +Bridgeは、エージェントとコンポーネント間の双方向通信を可能にします。 +また、Bridgeはエージェント同士の通信を可能にします。 + +### Dispatchers + +Dispatcherは、コンポーネントとエージェント間の一方向通信を可能にします。 +Dispatcherは、コンポーネントがエージェントにメッセージを送信することを可能にします。 + +## オーバーヘッド + +独自の独立したweb worker(プライベートとパブリック)にあるエージェントは、送受信するメッセージにシリアライズするオーバーヘッドが発生します。 +他のスレッドとの通信には[bincode](https://github.com/servo/bincode)を使用するので、関数を呼び出すよりもコストはかなり高くなります。 +計算コストがメッセージの受け渡しコストを上回る場合を除き、ロジックを UI スレッドエージェント\(JobまたはContext\)に格納する必要があります。 + +## 参考資料 + +* [pub\_sub](https://github.com/yewstack/yew/tree/master/examples/pub_sub)の例でコンポーネントがどのようにエージェントと通信させているかがわかります。 \ No newline at end of file diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md new file mode 100644 index 000000000..49f7363e8 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md @@ -0,0 +1,197 @@ +--- +title: Introduction +description: Components and their lifecycle hooks +--- +## コンポーネントとは? + +コンポーネントはYewを構成するブロックです。 +コンポーネントは状態を管理し、自身をDOMへレンダリングすることができます。 +コンポーネントはライフサイクルの機能がある`Component`トレイトを実装することによって作られます。 + +## ライフサイクル + +:::important contribute +`Contribute to our docs:` [Add a diagram of the component lifecycle](https://github.com/yewstack/docs/issues/22) +::: + +## ライフサイクルのメソッド + +### Create + +コンポーネントが作られると、`ComponentLink`と同様に親コンポーネントからプロパティを受け取ります。 +プロパティはコンポーネントの状態を初期化するのに使われ、"link"はコールバックを登録したりコンポーネントにメッセージを送るのに使われます。 + +propsとlinkをコンポーネント構造体に格納するのが一般的です。 +例えば: + +```rust +pub struct MyComponent { + props: Props, + link: ComponentLink, +} + +impl Component for MyComponent { + type Properties = Props; + // ... + + fn create(props: Self::Properties, link: ComponentLink) -> Self { + MyComponent { props, link } + } + + // ... +} +``` + +### View + +コンポーネントは`view()`メソッドによってレイアウトを宣言します。 +Yewは`html!`マクロによってHTMLとSVGノード、リスナー、子コンポーネントを宣言できます。 +マクロはReactのJSXのような動きをしますが、JavaScriptの代わりにRustの式を用います。 + +```rust +impl Component for MyComponent { + // ... + + fn view(&self) -> Html { + let onclick = self.link.callback(|_| Msg::Click); + html! { + + } + } +} +``` + +使い方については[`html!`ガイド](html.md)をご確認ください。 + +### Rendered + +`rendered()`コンポーネントのライフサイクルのメソッドは`view()`が処理されたてYewがコンポーネントをレンダリングした後、 +ブラウザがページを更新する前に呼ばれます。 +コンポーネントは、コンポーネントが要素をレンダリングした後にのみ実行できるアクションを実行するため、このメソッドを実装したい場合があります。 +コンポーネントが初めてレンダリングされたかどうかは `first_render` パラメータで確認できます。 + +```rust +use stdweb::web::html_element::InputElement; +use stdweb::web::IHtmlElement; +use yew::prelude::*; + +pub struct MyComponent { + node_ref: NodeRef, +} + +impl Component for MyComponent { + // ... + + fn view(&self) -> Html { + html! { + + } + } + + fn rendered(&mut self, first_render: bool) { + if first_render { + if let Some(input) = self.node_ref.try_into::() { + input.focus(); + } + } + } +} +``` + +:::tip note +ライフサイクルメソッドは実装の必要がなく、デフォルトでは何もしません。 +::: + +### Update + +コンポーネントは動的で、非同期メッセージを受信するために登録することができます。 +ライフサイクルメソッド `update()` はメッセージごとに呼び出されます。 +これにより、コンポーネントはメッセージが何であったかに基づいて自身を更新し、自身を再レンダリングする必要があるかどうかを判断することができます。 +メッセージは、HTML要素リスナーによってトリガーされたり、子コンポーネント、エージェント、サービス、またはFuturesによって送信されたりします。 + +`update()`がどのようなのかについての例は以下の通りです: + +```rust +pub enum Msg { + SetInputEnabled(bool) +} + +impl Component for MyComponent { + type Message = Msg; + + // ... + + fn update(&mut self, msg: Self::Message) -> ShouldRender { + match msg { + Msg::SetInputEnabled(enabled) => { + if self.input_enabled != enabled { + self.input_enabled = enabled; + true // Re-render + } else { + false + } + } + } + } +} +``` + +### Change + +コンポーネントは親によって再レンダリングされることがあります。 +このような場合、新しいプロパティを受け取り、再レンダリングを選択する可能性があります。 +この設計では、プロパティを変更することで、親から子へのコンポーネントの通信が容易になります。 + +典型的な実装例は以下の通りです: + +```rust +impl Component for MyComponent { + // ... + + fn change(&mut self, props: Self::Properties) -> ShouldRender { + if self.props != props { + self.props = props; + true + } else { + false + } + } +} +``` + +### Destroy + +コンポーネントが DOM からアンマウントされた後、Yew は `destroy()` ライフサイクルメソッドを呼び出し、必要なクリーンアップ操作をサポートします。 +このメソッドはオプションで、デフォルトでは何もしません。 + +## Associated Types + +`Component`トレイトは2つの関連型があります: `Message`と`Properties`です。 + +```rust +impl Component for MyComponent { + type Message = Msg; + type Properties = Props; + + // ... +} +``` + +`Message`はコンポーネントによって処理され、何らかの副作用を引き起こすことができるさまざまなメッセージを表します。 +例えば、APIリクエストをトリガーしたり、UIコンポーネントの外観を切り替えたりする `Click` メッセージがあります。 +コンポーネントのモジュールで `Msg` という名前の列挙型を作成し、それをコンポーネントのメッセージ型として使用するのが一般的です。 +"message"を"msg"と省略するのも一般的です。 + +```rust +enum Msg { + Click, +} +``` + +`Properties`は、親からコンポーネントに渡される情報を表します。 +この型はProperties traitを実装していなければならず\(通常はこれを派生させることで\)、特定のプロパティが必須かオプションかを指定することができます。 +この型は、コンポーネントの作成・更新時に使用されます。 +コンポーネントのモジュール内に `Props` という構造体を作成し、それをコンポーネントの `Properties` 型として使用するのが一般的です。 +”Properties”を"props"に短縮するのが一般的です。 +Propsは親コンポーネントから継承されるので、アプリケーションのルートコンポーネントは通常`()`型の`Properties`を持ちます。 +ルートコンポーネントのプロパティを指定したい場合は、`App::mount_with_props`メソッドを利用します。 \ No newline at end of file diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md new file mode 100644 index 000000000..5bac63b29 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md @@ -0,0 +1,34 @@ +--- +title: Callbacks +description: ComponentLink and Callbacks +--- +”リンク”コンポーネントはコンポーネントがコールバックを登録できて自身を更新することができるメカニズムです。 + +## ComponentLink API + +### callback + +実行時にコンポーネントの更新メカニズムにメッセージを送信するコールバックを登録します。 +これは、渡されたクロージャから返されるメッセージで `send_self` を呼び出します。 +`Fn(IN) -> Vec`が渡され、`Callback`が返されます。 + +### send\_message + +現在のループが終了した直後にコンポーネントにメッセージを送信し、別の更新ループを開始します。 + +### send\_message\_batch + +実行時に一度に多数のメッセージを一括して送信するコールバックを登録します。 +メッセージによってコンポーネントが再レンダリングされる場合、バッチ内のすべてのメッセージが処理された後、コンポーネントは再レンダリングされます。 +`Fn(IN) -> COMP::Message`が渡され、`Callback`が返されます。 + +## コールバック + +_\(This might need its own short page.\)_ + +コールバックは、Yew 内のサービス、エージェント、親コンポーネントとの通信に使われます。 +これらは単に `Fn` を `Rc` でラップしただけであり、クローンを作成できるようにするためのものです。 + +これらの関数には `emit` 関数があり、`` 型を引数に取り、それをアドレスが欲しいメッセージに変換します。 +親からのコールバックが子コンポーネントにpropsで提供されている場合、子は `update` ライフサイクルフックで `emit` をコールバックに呼び出して親にメッセージを返すことができます。 +マクロ内でpropsとして提供されたクロージャや関数は自動的にコールバックに変換されます。 diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md new file mode 100644 index 000000000..4d5f9831b --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md @@ -0,0 +1,85 @@ +--- +title: Properties +description: Parent to child communication +--- +プロパティは、子コンポーネントと親コンポーネントが互いに通信できるようにします。 + +## マクロの継承 + +`Properties`を自分で実装しようとせず、代わりに`#[derive(Properties)]`を使ってください。 + +:::note +`Properties`を継承した型は`Clone`を実装していなければいけません。 +これは`#[derive(Properties, Clone)`か`Clone`を手で実装することで可能です。 +::: + +### 必要な属性 + +デフォルトでは、`Properties` を導出する構造体内のフィールドは必須です。 +フィールドが欠落していて `html!` マクロでコンポーネントが作成された場合、コンパイラエラーが返されます。 +オプションのプロパティを持つフィールドについては、`#[prop_or_default]` 属性を使用して、propが指定されていない場合はその型のデフォルト値を使用します。 +値を指定するには `#[prop_or(value)]` 属性を用います。 +ここでvalueはプロパティのデフォルト値、あるいは代わりに `#[prop_or_else(function)]` を使用して、`function` はデフォルト値を返します。 +例えば、ブール値のデフォルトを `true` とするには、属性 `#[prop_or(true)]` を使用します。オプションのプロパティでは、デフォルト値 `None` を持つ `Option` 列挙型を使うのが一般的です。 + +### PartialEq + +もし可能ならpropsで `PartialEq` を継承するのが良いかもしれません。 +`PartialEq`を使うことで、不必要な再レンダリングを避けることができます +(これについては、**最適化とベストプラクティス**のセクションで説明しています)。 + +## プロパティを使用する際のメモリと速度のオーバーヘッド + +`Compoenent::view`ではコンポーネントの状態への参照を取り、それを使って `Html` を作成します。 +しかし、プロパティは自身の値です。 +つまり、それらを作成して子コンポーネントに渡すためには、`view` 関数で提供される参照を所有する必要があるのです。 +これは所有する値を取得するためにコンポーネントに渡される参照を暗黙のうちにクローンすることで行われます。 + + +これは、各コンポーネントが親から受け継いだ状態の独自のコピーを持っていることを意味し、コンポーネントを再レンダリングするときはいつでも、再レンダリングしたコンポーネントのすべての子コンポーネントのpropsがクローンされなければならないことを意味します。 + +このことの意味するところは、もしそうでなければ_大量の_データ \(10KBもあるような文字列\) をpropsとして渡してしまうのであれば、子コンポーネントを親が呼び出す `Html` を返す関数にすることを考えた方がいいかもしれないということです。 + +propsを介して渡されたデータを変更する必要がない場合は、実際のデータそのものではなく、データへの参照カウントされたポインタのみが複製されるように `Rc` でラップすることができます。 + +## 例 + +```rust +use std::rc::Rc; +use yew::Properties; + +#[derive(Clone, PartialEq)] +pub enum LinkColor { + Blue, + Red, + Green, + Black, + Purple, +} + +impl Default for LinkColor { + fn default() -> Self { + // The link color will be blue unless otherwise specified. + LinkColor::Blue + } +} + +#[derive(Properties, Clone, PartialEq)] +pub struct LinkProps { + /// The link must have a target. + href: String, + /// If the link text is huge, this will make copying the string much cheaper. + /// This isn't usually recommended unless performance is known to be a problem. + text: Rc, + /// Color of the link. + #[prop_or_default] + color: LinkColor, + /// The view function will not specify a size if this is None. + #[prop_or_default] + size: Option, + /// When the view function doesn't specify active, it defaults to true. + #[prop_or(true)] + active: bool, +} +``` + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md new file mode 100644 index 000000000..1a6a90590 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md @@ -0,0 +1,25 @@ +--- +title: Refs +description: Out-of-band DOM access +--- + +`ref`は、任意のHTML要素やコンポーネントの内部で、割り当てられているDOM`Element`を取得するために使用することができます。 +これは、`view` ライフサイクルメソッドの外でDOMに変更を加えるために使用できます。 + +これは、キャンバスの要素を取得したり、ページの異なるセクションにスクロールしたりするのに便利です。 + +構文は以下の通りです: + +```rust +// In create +self.node_ref = NodeRef::default(); + +// In view +html! { +
      +} + +// In update +let has_attributes = self.node_ref.try_into::().has_attributes(); +``` + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md new file mode 100644 index 000000000..c2a6f2265 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md @@ -0,0 +1,21 @@ +--- +title: Introduction +description: The procedural macro for generating HTML and SVG +--- + +`html!`マクロによってHTMLとSVGのコードを宣言的に書くことができます。 +JSX \(HTMLのようなコードをJavaScript内部に書くことができるJavaScriptの拡張\) に似ています。 + +**重要な注意** + +1. `html!`マクロはルートのHTMLノードのみ受け付けます \([フラグメントかイテレータを使う](html/lists.md)ことでやり取りできます\) +2. 空の`html! {}`の呼び出しは可能ですが何もレンダリングしません +3. リテラルはクオーテーションがつけられ、ブレースで囲う必要があります: `html! { "Hello, World" }` + +:::note +`html!`マクロはコンパイラのデフォルトの再帰の上限に簡単に達してしまいます。 +もしコンパイラエラーに遭遇した場合はその値を押し出すといいかもしれません。 +クレートのルート\(つまり、`lib.rs`か`main.rs`\)で`#![recursion_limit="1024"]`のような属性を使えば解決します。 + +詳しくは[公式ドキュメント](https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute)と[Stack Overflowの質問](https://stackoverflow.com/questions/27454761/what-is-a-crate-attribute-and-where-do-i-add-it)を見てみてください。 +::: \ No newline at end of file diff --git a/website/versioned_docs/version-0.17.3/concepts/html/components.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md similarity index 59% rename from website/versioned_docs/version-0.17.3/concepts/html/components.md rename to website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md index 2aa92f94b..ea9bf84c2 100644 --- a/website/versioned_docs/version-0.17.3/concepts/html/components.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md @@ -1,12 +1,10 @@ --- title: Components description: Create complex layouts with component hierarchies -id: version-0.17.3-components -original_id: components --- -## Basic +## 基本 -Any type that implements `Component` can be used in the `html!` macro: +`Component`を実装しているあらゆる型は`html!`マクロの中で使えます: ```rust html!{ @@ -23,9 +21,9 @@ html!{ } ``` -## Nested +## ネスト -Components can be passed children if they have a `children` field in their `Properties`. +`children`フィールドが`Properties`の中にある場合はコンポーネントは子に渡されます。 ```rust title="parent.rs" html! { @@ -60,12 +58,16 @@ impl Component for Container { ``` :::note -Types for which you derive `Properties` must also implement `Clone`. This can be done by either using `#[derive(Properties, Clone)]` or manually implementing `Clone` for your type. +`Properties`を継承した型は`Clone`を実装していなければいけません。 +これは`#[derive(Properties, Clone)]`を使うか手で`Clone`を実装すれば良いです。 ::: -## Nested Children with Props +## Propsとネストした子コンポーネント -Nested component properties can be accessed and mutated if the containing component types its children. In the following example, the `List` component can wrap `ListItem` components. For a real world example of this pattern, check out the `yew-router` source code. For a more advanced example, check out the `nested-list` example in the main yew repository. +ネストしたコンポーネントのプロパティは格納しているコンポーネントの型が子である場合はアクセス可能、または変更可能です。 +以下の例では`List`コンポーネントは`ListItem`コンポーネントをラップできています。 +実際の使用においてこのパターンの例については`yew-router`のソースコードを確認してみてください。 +より進んだ例としてはYewのメインのリポジトリにある`nested-list`を確認してみてください。 ```rust title="parent.rs" html! { diff --git a/website/versioned_docs/version-0.17.3/concepts/html/elements.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md similarity index 84% rename from website/versioned_docs/version-0.17.3/concepts/html/elements.md rename to website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md index a976b5c30..c8533e080 100644 --- a/website/versioned_docs/version-0.17.3/concepts/html/elements.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md @@ -1,12 +1,10 @@ --- title: Elements description: Both HTML and SVG elements are supported -id: version-0.17.3-elements -original_id: elements --- -## Tag Structure +## タグ構造 -Element tags must either self-close `<... />` or have a corresponding close tag for each open tag +要素のタグは`<... />`のような自己完結タグか、開始タグに対応した終了タグを持っている必要があります。 @@ -15,7 +13,6 @@ html! {
      } ``` - ```rust html! { @@ -39,13 +36,14 @@ html! { :::note -For convenience, elements which _usually_ require a closing tag are **allowed** to self-close. For example, writing `html! {
      }` is valid. +便利さのために、_普通は_終了タグを必要とする要素は自己完結タグとすることが**できます**。 +例えば`html! {
      }`と書くのは有効です。 ::: -## Children - -Create complex nested HTML and SVG layouts with ease: +## 子 +複雑にネストしたHTMLやSVGのレイアウトを書くのには以下のようにするのが楽です: +** @@ -91,9 +89,9 @@ html! { ``` -## Classes +## クラス -There are a number of convenient ways to specify classes for an element: +要素へのクラスを特定する便利なやり方はたくさんあります: @@ -139,9 +137,10 @@ html! { ``` -## Listeners +## リスナー -Listener attributes need to be passed a `Callback` which is a wrapper around a closure. How you create your callback depends on how you wish your app to react to a listener event: +リスナー属性はクロージャのラッパーである`Callback`に渡される必要があります。 +コールバックをどのように作るかはアプリをリスナーイベントにどう反応させたいかによります。 @@ -247,34 +246,35 @@ impl Component for MyComponent { ``` -## Event Types +## イベントの型 :::note -In the following table `web-sys`'s event types should only be used if you're using `yew` with `web-sys` -(this is enabled by default). Use `stdweb`'s event types if you're using the `yew-stdweb` crate. See -[the documentation page about whether to choose `web-sys` or `stdweb`](https://yew.rs/docs/getting-started/choose-web-library) for more information. +以下のテーブルでは`yew`を`web-sys`と使う場合 (デフォルトでは使うようになっている) `web-sys`のイベントの型が使われるべきです。 +`yew-stdweb`クレートを使う場合は`stdweb`のイベントの型を使用してください。 +詳細については[`web-sys`と`stdweb`をどちらを使うべきかについてのドキュメント](https://yew.rs/docs/getting-started/choose-web-library)をご確認ください。 ::: :::note +以下のテーブルにある全てのイベントの型は`yew::events`で再エクスポートされています。 All the event types mentioned in the following table are re-exported under `yew::events`. Using the types from `yew::events` makes it easier to ensure version compatibility than if you were to manually include `web-sys` or `stdweb` as dependencies in your crate because you won't end up using a version which conflicts with the version Yew specifies. ::: -| Event name | `web_sys` Event Type | `stdweb` Event Type | +| イベント名 | `web_sys` イベント型 | `stdweb` イベント型 | | ----------- | -------------------- | ------------------ | | `onabort` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [ResourceAbortEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ResourceAbortEvent.html) | | `onauxclick` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [AuxClickEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.AuxClickEvent.html) | | `onblur` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) | [BlurEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.BlurEvent.html) | -| `oncancel` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `oncanplay` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `oncanplaythrough` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `oncancel` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `oncanplay` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `oncanplaythrough` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onchange` | [ChangeData](https://docs.rs/yew/latest/yew/events/enum.ChangeData.html) | [ChangeData](https://docs.rs/yew-stdweb/latest/yew_stdweb/events/enum.ChangeData.html) | | `onclick` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [ClickEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ClickEvent.html) | -| `onclose` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onclose` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `oncontextmenu` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [ContextMenuEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ContextMenuEvent.html) | -| `oncuechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `oncuechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `ondblclick` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [DoubleClickEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DoubleClickEvent.html) | | `ondrag` | [DragEvent](https://docs.rs/web-sys/latest/web_sys/struct.DragEvent.html) | [DragEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DragEvent.html) | | `ondragend` | [DragEvent](https://docs.rs/web-sys/latest/web_sys/struct.DragEvent.html) | [DragEndEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DragEndEvent.html) | @@ -284,20 +284,20 @@ the version Yew specifies. | `ondragover` | [DragEvent](https://docs.rs/web-sys/latest/web_sys/struct.DragEvent.html) | [DragOverEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DragOverEvent.html) | | `ondragstart` | [DragEvent](https://docs.rs/web-sys/latest/web_sys/struct.DragEvent.html) | [DragStartEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DragStartEvent.html) | | `ondrop` | [DragEvent](https://docs.rs/web-sys/latest/web_sys/struct.DragEvent.html) | [DragDropEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.DragDropEvent.html) | -| `ondurationchange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onemptied` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onended` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `ondurationchange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onemptied` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onended` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onerror` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [ResourceErrorEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ResourceErrorEvent.html) | | `onfocus` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) | [FocusEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.FocusEvent.html) | -| `onformdata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onformdata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `oninput` | [InputData](https://docs.rs/yew/latest/yew/events/struct.InputData.html) | [InputData](https://docs.rs/yew-stdweb/latest/yew_stdweb/events/struct.InputData.html) | -| `oninvalid` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `oninvalid` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onkeydown` | [KeyboardEvent](https://docs.rs/web-sys/latest/web_sys/struct.KeyboardEvent.html) | [KeyDownEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.KeyDownEvent.html) | | `onkeypress` | [KeyboardEvent](https://docs.rs/web-sys/latest/web_sys/struct.KeyboardEvent.html) | [KeyPressEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.KeyPressEvent.html) | | `onkeyup` | [KeyboardEvent](https://docs.rs/web-sys/latest/web_sys/struct.KeyboardEvent.html) | [KeyUpEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.KeyUpEvent.html) | | `onload` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [ResourceLoadEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ResourceLoadEvent.html) | -| `onloadeddata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onloadedmetadata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onloadeddata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onloadedmetadata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onloadstart` | [ProgressEvent](https://docs.rs/web-sys/latest/web_sys/struct.ProgressEvent.html) | [LoadStartEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.LoadStartEvent.html) | | `onmousedown` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [MouseDownEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseDownEvent.html) | | `onmouseenter` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [MouseEnterEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseEnterEvent.html) | @@ -306,34 +306,34 @@ the version Yew specifies. | `onmouseout` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [MouseOutEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseOutEvent.html) | | `onmouseover` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [MouseOverEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseOverEvent.html) | | `onmouseup` | [MouseEvent](https://docs.rs/web-sys/latest/web_sys/struct.MouseEvent.html) | [MouseUpEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseUpEvent.html) | -| `onpause` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onplay` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onplaying` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onpause` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onplay` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onplaying` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onprogress` | [ProgressEvent](https://docs.rs/web-sys/latest/web_sys/struct.ProgressEvent.html) | [ProgressEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ProgressEvent.html) | -| `onratechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onreset` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onratechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onreset` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onresize` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [ResizeEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ResizeEvent.html) | | `onscroll` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [ScrollEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.ScrollEvent.html) | -| `onsecuritypolicyviolation` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onseeked` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onseeking` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onselect` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onsecuritypolicyviolation` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onseeked` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onseeking` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onselect` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onslotchange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [SlotChangeEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.SlotChangeEvent.html) | -| `onstalled` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onstalled` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onsubmit` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) | [SubmitEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.SubmitEvent.html) | -| `onsuspend` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `ontimeupdate` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `ontoggle` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onvolumechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onwaiting` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onsuspend` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `ontimeupdate` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `ontoggle` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onvolumechange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onwaiting` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `onwheel` | [WheelEvent](https://docs.rs/web-sys/latest/web_sys/struct.WheelEvent.html) | [MouseWheelEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.MouseWheelEvent.html) | -| `oncopy` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `oncut` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onpaste` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onanimationcancel` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | Unsupported | -| `onanimationend` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | Unsupported | -| `onanimationiteration` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | Unsupported | -| `onanimationstart` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | Unsupported | +| `oncopy` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `oncut` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onpaste` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onanimationcancel` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | サポート無し | +| `onanimationend` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | サポート無し | +| `onanimationiteration` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | サポート無し | +| `onanimationstart` | [AnimationEvent](https://docs.rs/web-sys/latest/web_sys/struct.AnimationEvent.html) | サポート無し | | `ongotpointercapture` | [PointerEvent](https://docs.rs/web-sys/latest/web_sys/struct.PointerEvent.html) | [GotPointerCaptureEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.GotPointerCaptureEvent.html) | | `onloadend` | [ProgressEvent](https://docs.rs/web-sys/latest/web_sys/struct.ProgressEvent.html) | [LoadEndEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.LoadEndEvent.html) | | `onlostpointercapture` | [PointerEvent](https://docs.rs/web-sys/latest/web_sys/struct.PointerEvent.html) | [LostPointerCaptureEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.LostPointerCaptureEvent.html) | @@ -348,13 +348,13 @@ the version Yew specifies. | `onpointerover` | [PointerEvent](https://docs.rs/web-sys/latest/web_sys/struct.PointerEvent.html) | [PointerOverEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.PointerOverEvent.html) | | `onpointerup` | [PointerEvent](https://docs.rs/web-sys/latest/web_sys/struct.PointerEvent.html) | [PointerUpEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.PointerUpEvent.html) | | `onselectionchange` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | [SelectionChangeEvent](https://docs.rs/stdweb/latest/stdweb/web/event/struct.SelectionChangeEvent.html) | -| `onselectstart` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | -| `onshow` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | Unsupported | +| `onselectstart` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | +| `onshow` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) | サポート無し | | `ontouchcancel` | [TouchEvent](https://docs.rs/web-sys/latest/web_sys/struct.TouchEvent.html) | [TouchCancel](https://docs.rs/stdweb/latest/stdweb/web/event/struct.TouchCancel.html) | | `ontouchend` | [TouchEvent](https://docs.rs/web-sys/latest/web_sys/struct.TouchEvent.html) | [TouchEnd](https://docs.rs/stdweb/latest/stdweb/web/event/struct.TouchEnd.html) | | `ontouchmove` | [TouchEvent](https://docs.rs/web-sys/latest/web_sys/struct.TouchEvent.html) | [TouchMove](https://docs.rs/stdweb/latest/stdweb/web/event/struct.TouchMove.html) | | `ontouchstart` | [TouchEvent](https://docs.rs/web-sys/latest/web_sys/struct.TouchEvent.html) | [TouchStart](https://docs.rs/stdweb/latest/stdweb/web/event/struct.TouchStart.html) | -| `ontransitioncancel` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | Unsupported | -| `ontransitionend` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | Unsupported | -| `ontransitionrun` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | Unsupported | -| `ontransitionstart` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | Unsupported | +| `ontransitioncancel` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | サポート無し | +| `ontransitionend` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | サポート無し | +| `ontransitionrun` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | サポート無し | +| `ontransitionstart` | [TransitionEvent](https://docs.rs/web-sys/latest/web_sys/struct.TransitionEvent.html) | サポート無し | diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/lists.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/lists.md new file mode 100644 index 000000000..7aa68c102 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/lists.md @@ -0,0 +1,55 @@ +--- +title: Lists +--- + +## フラグメント + +`html!`マクロは常にルートノードが1つであることを要求します。 +この制限のために、空のタグを使って内容をラップすると良いでしょう。 + + + +```rust +html! { + <> +
      +

      + +} +``` + + +```rust +/* error: only one root html element allowed */ + +html! { +
      +

      +} +``` + + + +## イテレータ + +YewはイテレータからHTMLをビルドするのに2つの方法をサポートしています。 + + + +```rust +html! { +
        + { self.props.items.iter().map(renderItem).collect::() } +
      +} +``` + + +```rust +html! { +
        + { for self.props.items.iter().map(renderItem) } +
      +} +``` + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md new file mode 100644 index 000000000..0d5c42e03 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/literals-and-expressions.md @@ -0,0 +1,59 @@ +--- +title: Literals and Expressions +--- +## リテラル + +式が`Display`を実装した型を解決する場合、文字列に変換されてDOMに[Text](https://developer.mozilla.org/en-US/docs/Web/API/Text)ノードとして挿入されます。 + +テキストは式として処理されるため、全ての表示される内容は`{}`ブロックによって囲まれる必要があります。 +これはYewのアプリと通常のHTMLの構文で最も異なる点です。 + +```rust +let text = "lorem ipsum"; +html!{ + <> +
      {text}
      +
      {"dolor sit"}
      + {42} + +} +``` + +## 式 + +HTMLに`{}`ブロックを使って式を挿入することができます。 + +```rust +html! { +
      + { + if show_link { + html! { + {"Link"} + } + } else { + html! {} + } + } +
      +} +``` + +式を関数やクロージャに分離するのはコードの可読性の観点から有効なことがあります。 + +```rust +let show_link = true; +let maybe_display_link = move || -> Html { + if show_link { + html! { + {"Link"} + } + } else { + html! {} + } +}; + +html! { +
      {maybe_display_link()}
      +} +``` diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md new file mode 100644 index 000000000..85c12ab85 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/router.md @@ -0,0 +1,94 @@ +--- +title: Router +description: Yew's official router +--- + +[crates.ioにあるルータ](https://crates.io/crates/yew-router) + +シングルページアプリケーション\(SPA\)におけるルータはURLよってページを出し分けます。 +リンクがクリックされたときに異なるリソースを要求するというデフォルトの動作の代わりに、ルータはアプリケーション内の有効なルートを指すように URL をローカルに設定します。 +ルータはこの変更を検出してから、何をレンダリングするかを決定します。 + +## コアとなる要素 + +### `Route` + +URL内のドメインの後のすべてを表す文字列と、オプションでhistory APIに保存されている状態を含みます。 + +### `RouteService` + +ブラウザとやりとりしてルーティングを決めます。 + +### `RouteAgent` + +RouteService を所有し、ルートが変更された際の更新を調整するために使用します。 + +### `Switch` + +`Switch`トレイトは`Route`をトレイトの実装する側の間で変換するために用いられます。 + +### `Router` + +RouterコンポーネントはRouteAgentとやり取りし、エージェントがどうスイッチするかRoutesを自動的に解決します。 +これは、結果として得られるスイッチがどのようにHtmlに変換されるかを指定できるようにするため、propsを介して公開されます。 + +## ルータをどのように使うか + +まず、アプリケーションのすべての状態を表す型を作成します。 +これは通常は列挙型ですが、構造体もサポートされており、`Switch` を実装した他のアイテムを内部に入れ子にすることができることに注意してください。 + +次に、`Switch`を型に継承させなければいけません。 +列挙型の場合は全てのvariantは`#[to = "/some/route"]`とアノテーションされている必要があり、代わり構造体を用いている場合は構造体宣言が外部から見えるようにしてなければいけません。 + +```rust +#[derive(Switch)] +enum AppRoute { + #[to="/login"] + Login, + #[to="/register"] + Register, + #[to="/delete_account"] + Delete, + #[to="/posts/{id}"] + ViewPost(i32), + #[to="/posts/view"] + ViewPosts, + #[to="/"] + Home +} +``` + +:::caution +`Switch`用の派生マクロによって生成された実装は、各variantを最初から最後までの順にマッチさせようとするので、指定した`to`アノテーションのうち 2 つのルートにマッチする可能性がある場合は、最初のルートがマッチし、2 つ目のルートは試行されないことに注意してください。例えば、以下の`Switch`を定義した場合、マッチするルートは`AppRoute::Home`だけになります。 + +```rust +#[derive(Switch)] +enum AppRoute { + #[to="/"] + Home, + #[to="/login"] + Login, + #[to="/register"] + Register, + #[to="/delete_account"] + Delete, + #[to="/posts/{id}"] + ViewPost(i32), + #[to="/posts/view"] + ViewPosts, +} +``` +::: + +また、`#[to = ""]`アノテーションの中で`{}`のバリエーションを使ってセクションをキャプチャすることもできます。 +`{}`は、次の区切り文字\(コンテキストに応じて "/", "?", "&", "#" のいずれか\) までのテキストをキャプチャします。 +`{*}`は、次の文字が一致するまでテキストをキャプチャすることを意味します。 +`{}`は、指定した数の区切り文字が見つかるまでテキストをキャプチャすることを意味します +\(例: `{2}`は区切り文字が2つ見つかるまでキャプチャします\)。 + +名前付きフィールドを持つ構造体や列挙型の場合は、キャプチャグループ内で以下のようにフィールドの名前を指定する必要があります。 +`{user_name}` または `{*:age}` のように、キャプチャグループ内でフィールドの名前を指定しなければなりません。 + +Switchトレイトは文字列よりも構造化されたキャプチャグループで動作します。 +`Switch`を実装した任意の型を指定することができます。 +そのため、キャプチャグループが `usize` であることを指定することができ、URLのキャプチャ部分がそれに変換できない場合、variantはマッチしません。 \ No newline at end of file diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md new file mode 100644 index 000000000..603a623f5 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services.md @@ -0,0 +1,10 @@ +--- +title: Introduction +description: Yew's glue to browser APIs +--- + +# サービス + +:::note +このセクションはまだWIPです。 +::: diff --git a/docs/concepts/services/format.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services/format.md similarity index 99% rename from docs/concepts/services/format.md rename to website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services/format.md index a43136458..269a73a2c 100644 --- a/docs/concepts/services/format.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/concepts/services/format.md @@ -1,6 +1,7 @@ --- title: Format --- + :::important contribute `Contribute to our docs:` [Explain the format module in depth](https://github.com/yewstack/docs/issues/24) ::: diff --git a/website/versioned_docs/version-0.17.3/getting-started/build-a-sample-app.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/build-a-sample-app.md similarity index 52% rename from website/versioned_docs/version-0.17.3/getting-started/build-a-sample-app.md rename to website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/build-a-sample-app.md index 7c7105e0a..ffb589e18 100644 --- a/website/versioned_docs/version-0.17.3/getting-started/build-a-sample-app.md +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/build-a-sample-app.md @@ -1,15 +1,14 @@ --- title: Build a sample app -id: version-0.17.3-build-a-sample-app -original_id: build-a-sample-app --- -First create a new Rust library \(**important:** create a _library_, not a _binary_ by passing the `--lib` flag\): + +はじめに、Rustの新規ライブラリを作りましょう(**重要:** `--lib`フラグを渡すことで_バイナリ_ではなく_ライブラリ_を作ってください) ```bash cargo new --lib yew-app && cd yew-app ``` -Add `yew` and `wasm-bindgen` to your dependencies \(refer [here](https://docs.rs/yew) for the latest version\) +依存ライブラリに`yew`と`wasm-bindgen`を追加してください \(最新バージョンについては[こちら](https://docs.rs/yew)を参照してください\) ```toml title="Cargo.toml" [package] @@ -23,10 +22,10 @@ crate-type = ["cdylib", "rlib"] [dependencies] yew = "0.17" -wasm-bindgen = "0.2.67" +wasm-bindgen = "0.2" ``` -Copy the following template into your `src/lib.rs` file: +以下のテンプレートを `src/lib.rs`ファイルにコピーしてください: ```rust title="src/lib.rs" use wasm_bindgen::prelude::*; @@ -81,9 +80,11 @@ pub fn run_app() { } ``` -This template sets up your root `Component`, called `Model` which shows a button that updates itself when you click it. Take special note of `App::::new().mount_to_body()` inside `main()` which starts your app and mounts it to the page's `` tag. If you would like to start your application with any dynamic properties, you can instead use `App::::new().mount_to_body_with_props(..)`. +このテンプレートはルートに`Component`をセットアップし、`Model`と呼ばれるクリックしたら更新するボタンを作ります。 +`main()`の中にある`App::::new().mount_to_body()`がアプリをスタートしてページの``タグをマウントすることに特に注意してください。 +動的なプロパティでアプリをスタートしたい場合は代わりに`App::::new().mount_to_body_with_props(..)`を使うことで実現できます。 -Finally, add an `index.html` file into a new folder named `static` in your app. +最後に、アプリの中の`static`という名前のフォルダに`index.html`ファイルを追加してください。 ```bash mkdir static @@ -104,17 +105,20 @@ mkdir static ``` -## Run your App! +## アプリを動かす! -Using [`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/) is the preferred way to get up and running. If you haven't already, install `wasm-pack` with `cargo install wasm-pack` and then build and start a development server by running: +[`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/)を使うのがアプリを動かすのに推奨される方法です。 +まだ`wasm-pack`をインストールしていない場合、`cargo install wasm-pack`でインストールして開発サーバーを動かしてみましょう: ```bash wasm-pack build --target web --out-name wasm --out-dir ./static ``` -`wasm-pack` generates a bundle in the `./static` directory with your app's compiled WebAssembly along with a JavaScript wrapper which will load your application's WebAssembly binary and run it. +`wasm-pack`はコンパイルされたWebAssemblyとJavaScriptラッパーをまとめたものを`./static`ディレクトリに作り、 +アプリのWebAssemblyバイナリを読み込んで動かします。 -Then, use your favorite web server to serve the files under `./static`. For example: +そして、`./static`以下で好きなサーバーをファイルをサーブしてみましょう。 +例えば: ```bash cargo +nightly install miniserve diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md new file mode 100644 index 000000000..58b3672fc --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/choose-web-library.md @@ -0,0 +1,123 @@ +--- +title: Choosing a web library +--- +## はじめに + +Yewアプリは[`web-sys`](https://docs.rs/web-sys)か[`stdweb`](https://docs.rs/stdweb)で作ることができます。 +これらのクレートはRustとWeb APIのバインディングを提供しています。 +Cargoの依存クレートに`yew`を追加する際はどちらかを選ばなければいけません: + +```toml +# Choose `web-sys` +yew = "0.17" + +# Choose `stdweb` +yew = { version = "0.17", package = "yew-stdweb" } +``` + +[Rust / Wasm 活動チーム](https://rustwasm.github.io/)のサポートがある`web-sys`が推奨です。 + +## 使用例 + +```rust +// web-sys +let window: web_sys::Window = web_sys::window().expect("window not available"); +window.alert_with_message("hello from wasm!").expect("alert failed"); + +// stdweb +let window: stdweb::web::Window = stdweb::web::window(); +window.alert("hello from wasm!"); + +// stdweb with js! macro +use stdweb::js; +use stdweb::unstable::TryFrom; +use stdweb::web::Window; + +let window_val: stdweb::Value = js!{ return window; }; // <- JS syntax inside! +let window = Window::try_from(window_val).expect("conversion to window failed"); +window.alert("hello from wasm!"); +``` + +2つのクレートのAPIはわずかに異なりますが、だいたい同じ目的で似た機能が提供されています。 + +## 一方を選ぶ + +アプリに`web-sys`と`stdweb`のどちらを選ぶかにおいてはいくつかの見方があります。 +注意として、一つのアプリに両方を用いることができるのですが、クレートをコンパイルした際にバイナリのサイズを小さくするには +一方だけを使用するのが良いです。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      web-sys + stdweb +
      プロジェクトの進捗状況 + Rust / Wasm 活動チームにより活発にメンテナンスされている + GitHubで8ヶ月間動きなし
      Web API のカバーRustのAPIはWeb IDLスペックから自動的に生成される。Browser APIはコミュニティにより追加。
      RustのAPIのデザイン + ほとんどのAPIコールおいてResultが返ってくるよう保守的なアプローチがとられている。 + しばしばResultを返さずpanicするようになっている。例えば stdweb::web::window()ワーカーの中で呼ばれるパニックする。
      サポートされているビルドツール +

      +
        +
      • wasm-bindgen +
      • +
      • wasm-pack +
      • +
      +
      +

      +
        +
      • cargo-web +
      • +
      • wasm-bindgen +
      • +
      • wasm-pack +
      • +
      +
      サポートされているターゲット +
        +
      • wasm32-unknown-unknown +
      • +
      +
      +
        +
      • wasm32-unknown-unknown +
      • +
      • wasm32-unknown-emscripten +
      • +
      • asmjs-unknown-emscripten +
      • +
      +
      + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md new file mode 100644 index 000000000..242702b52 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/examples.md @@ -0,0 +1,15 @@ +--- +title: Examples +--- + +Yewのリポジトリは[例](https://github.com/yewstack/yew/tree/v0.17/examples)がたくさんあります +\(メンテナンス状況は様々\)。 +様々なフレームワークの機能の使い方を知るのにはそれらの例に取り組むのを勧めます。 +プルリクエストやIssueはウェルカムです。 + +* [**Todoアプリ** ](https://github.com/yewstack/yew/tree/v0.17/examples/todomvc) +* [**カスタムコンポーネント**](https://github.com/yewstack/yew/tree/v0.17/examples/custom_components) +* [**マルチスレッド\(エージェント\)**](https://github.com/yewstack/yew/tree/v0.17/examples/multi_thread) +* [**タイマーサービス**](https://github.com/yewstack/yew/tree/v0.17/examples/timer) +* [**ネストしたコンポーネント**](https://github.com/yewstack/yew/tree/v0.16.0/examples/nested_list) + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md new file mode 100644 index 000000000..a34cd61b5 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup.md @@ -0,0 +1,142 @@ +--- +title: Introduction +description: Set yourself up for success +--- + +# 始める + +## Rust + +まずはじめにRustが必要です。Rustとビルドツールの`cargo`をインストールするために、以下の[公式サイト](https://www.rust-lang.org/tools/install) +を見てください。 + +## **Wasm ビルドツール** + +WebAssemblyとJavaScriptの互換を持たせるために他にツールが必要です。さらに、選んだツールに応じてブラウザでアプリから`.wasm`ファイルを実行するのに +必要なJavaScriptラッパーのコードを生成し、これによってデプロイやパッケージ化での頭痛の種を軽減させるのに役立ちます。 + +### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) + +Rust / Wasm活動チームによって開発されているCLIツールで、WebAssemblyをパッケージ化することができます。 +Webpackには[`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin)が最もよく使われています。 + +[`wasm-pack`で始める](project-setup/using-wasm-pack.md) + +### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/) + +Rust/Wasm活動チームによって開発されているライブラリとCLIツールで、JS / WebAssemblyの互換性を持たせるための低レベルなツールです +(`wasm-pack`で内部的に使われています)。 +`wasm-bindgen`は手書きのJavaScriptでWebAssemblyのバイナリを使う必要があるため、直接使うのは非推奨です。 +しかし、詳細な情報については[**`wasm-bindgen` ガイド**](https://rustwasm.github.io/docs/wasm-bindgen/)から得られます。 + +[`wasm-bindgen`で始める。](project-setup/using-wasm-bindgen.md) + +### [**`cargo-web`**](https://github.com/koute/cargo-web) + +`wasm-pack`と`wasm-bindgen`を導入する前は好まれたWebワークフローツールです。 +`wasm-pack`がサポートされていないサンプルを動かすのにインストールする価値があり、依然として**最もお手軽に**始められる方法です。 + +[`cargo web`で始める](project-setup/using-cargo-web.md) + +### 比較 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      wasm-pack + wasm-bindgen + cargo-web +
      プロジェクトの進行状況Rust / Wasm活動チームにより活発にメンテナンス + Rust / Wasm 活動チームにより活発にメンテナンス + 6ヶ月間GitHubでの活発な活動無し
      開発体験ほぼ大丈夫! webpackがあればなお良い。だいたい大丈夫。開発においては少し流れを書かないといけない。しっかり動く!完結していて、外部ライブラリに頼る必要無し。
      ローカルサーバーwebpackプラグインによるサポートありサポート無しサポートあり
      ローカル環境での変更による自動再ビルドwebpackプラグインによるサポートありサポート無しサポートあり
      ヘッドレスブラウザテストサポートあり + サポートあり + サポートあり +
      サポートされているターゲット +
        +
      • wasm32-unknown-unknown +
      • +
      +
      +
        +
      • wasm32-unknown-unknown +
      • +
      +
      +
        +
      • wasm32-unknown-unknown +
      • +
      • wasm32-unknown-emscripten +
      • +
      • asmjs-unknown-emscripten +
      • +
      +
      web-sys互換性あり互換性あり互換性無し
      stdweb互換性あり互換性あり互換性あり
      使用例入門用テンプレート + + Yewで作る例 + + Yewで作る例 +
      + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md new file mode 100644 index 000000000..6ada07b4c --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-cargo-web.md @@ -0,0 +1,36 @@ +--- +title: Using cargo-web +--- + +Cargo webはクライアントWebアプリを作るためのCargoサブコマンドです。 +これによりWebアプリのビルドとデプロイを驚くほど簡単にできます。 +そして同時にEmscriptenがターゲットなのを唯一サポートしているツールチェーンです。 +詳しくは[こちら](https://github.com/koute/cargo-web)。 + +**インストール** + +```bash +cargo install cargo-web +``` + +## ビルド + +```bash +cargo web build +``` + +## 動かす + +```bash +cargo web start +``` + +## サポートされているターゲット + +* `wasm32-unknown-unknown` +* `wasm32-unknown-emscripten` +* `asmjs-unknown-emscripten` + +:::注意 +`*-emscripten`をターゲットにする場合、Emscripten SDKをインストールする必要があります。 +::: diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md new file mode 100644 index 000000000..921a84276 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-bindgen.md @@ -0,0 +1,51 @@ +--- +title: Using wasm-bindgen +--- + +## インストール + +```bash +cargo install wasm-bindgen-cli +``` + +## ビルド + +はじめに、Wasmファイルを生成するアプリをビルドしましょう。 +[サンプルアプリをビルド](../build-a-sample-app.md)のアプリをビルドしたいとします。 +生成されたファイルのパスは`target/wasm32-unknown-unknown/debug/yew-app.wasm`にあるはずです。 +もしクレートに何か別の名前をつけた場合、Wasmファイルの名前は`yew-app.wasm`ではなく、`Cargo.toml`ファイルに +`package.name`として名前をつけたものになるでしょう。 + +```bash +cargo build --target wasm32-unknown-unknown +``` + +次に、wasm-bindgenのCLIを動かしましょう。 +このコマンドは`--out-dir`のディレクトリにいくつかのファイルを生成し、その中にはWasmバイナリを読み込んで動かすための +コンパイルされたWebAssemblyとJavaScriptのラッパーが入っています。 +現在のブラウザは直接WebAssemblyファイルを読み込むことができないため、代わりにJavaScript経由で読み込まれるなければならず、 +そのためにこれらのラッパーが必要となります。 +[サンプルアプリを作る(../build-a-sample-app.md)の例では`static`フォルダにファイルが生成されるようにしており +(そのために`wasm-bindgen`へ`--out-dir static`と渡す必要があります)、 +`wasm.js`と`wasm_bg.wasm`という名前になります(`wasm-bindgen`へ`--out-name wasm`と渡すことで実現できます) + +```bash +wasm-bindgen --target web --out-dir static --out-name wasm target/wasm32-unknown-unknown/debug/appname.wasm --no-typescript +``` + +## アプリをサーブする + +好きなサーバーを使ってください。 +ここではシンプルなPythonのサーバーを使います。 + +```bash +python -m http.server 8000 +``` + +## サポートされているターゲット + +* `wasm32-unknown-unknown` + +## 参考ドキュメント + +* [The `wasm-bindgen` docs](https://rustwasm.github.io/docs/wasm-bindgen/) diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md new file mode 100644 index 000000000..af67e25d1 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/project-setup/using-wasm-pack.md @@ -0,0 +1,49 @@ +--- +title: Using wasm-pack +--- + +このツールはRust / Wasm活動チームによって開発され、WebAssemblyのアプリを作るのに使われれるツールで最も活発に開発されているものです。 +コードを`npm`モジュールへパッケージ化するのをサポートし、既存のJavaScriptのアプリと簡単に統合できる +[Webpack plugin](https://github.com/wasm-tool/wasm-pack-plugin)がついています。 +詳しい情報は[the `wasm-pack` documentation](https://rustwasm.github.io/docs/wasm-pack/introduction.html)にあります。 + +:::注意 +`wasm-pack`を使う際は`Cargo.toml`のcrate-typeは`cdylib`である必要があります。 +::: + +## インストール + +```bash +cargo install wasm-pack +``` + +## ビルド + +このコマンドはJavaScriptラッパーとアプリのWebAssemblyをまとめたものを`./pkg`ディレクトリに生成し、アプリをスタートすることができます。 +This command will produce a bundle in the `./pkg` directory with your app's compiled WebAssembly +along with a JavaScript wrapper which can be used to start your application. + +```bash +wasm-pack build --target web +``` + +## バンドル + +ロールアップにについては詳しくは[ガイド](https://rollupjs.org/guide/en/#quick-start)をご覧ください。 + +```bash +rollup ./main.js --format iife --file ./pkg/bundle.js +``` + +## サーブ + +好きなサーバーを使ってください。 +ここではシンプルなPythonのサーバーを使ってアプリをサーブします。 + +```bash +python -m http.server 8000 +``` + +## サポートされているターゲット + +* `wasm32-unknown-unknown` diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md new file mode 100644 index 000000000..d2895e82d --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.md @@ -0,0 +1,42 @@ +--- +title: Starter templates +--- + +## `wasm-pack` + +* [ミニマルテンプレート](https://github.com/yewstack/yew-wasm-pack-minimal) - アプリをビルドするのに `wasm-pack`と + + `rollup`を使い、サーバーはアプリをサーブします. ベルや笛はここにはありません。 + +* [Webpackテンプレート](https://github.com/yewstack/yew-wasm-pack-template) - `wasm-pack`と + + [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin)を使い、Webpackが開発を滑らかにします。 + +これらのテンプレートを使うのと`cargo-web`を使用するのと重要な違いは、このアプローチは`bin`クレートではなく`lib`クレートを用いて +`#[wasm_bindgen]`によってエントリーポイントを指定できる点です。 + +また、`Cargo.toml`はクレートの種類が"cdylib"であると特定できるようにしましょう。 + +```text title="Cargo.toml" +[package] +name = "yew-app" +version = "0.1.0" +authors = ["Yew App Developer "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +# for web_sys +yew = "0.17" +# or for stdweb +# yew = { version = "0.17", package = "yew-stdweb" } +wasm-bindgen = "0.2" +``` + +## その他のテンプレート + +* [Parcel Template](https://github.com/spielrs/yew-parcel-template) - コミュニティのメンバーによって開発され、 +Parcel](https://parceljs.org/)を使っています。 + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/index.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/index.md new file mode 100644 index 000000000..70344d557 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/index.md @@ -0,0 +1,64 @@ +--- +title: Introduction +--- + +## Yewとは? + +**Yew** は [WebAssembly](https://webassembly.org/) によってマルチスレッドなWebアプリのフロントエンドを作ることができる、モダンな [Rust](https://www.rust-lang.org/) のフレームワークです。 + +* インタラクティブなUIを簡単に作ることができる、**コンポーネントベース** のフレームワークです. [React](https://reactjs.org/) や [Elm](https://elm-lang.org/) のようなフレームワークを使用したことがある開発者はYewを違和感なく使うことができるでしょう。 +* DOMのAPIを呼び出すのを最小化し、開発者がWebワーカーによって簡単に処理を軽量化できることで **素晴らしいパフォーマンス** を発揮します。 +* **JavaScriptとの互換性** をサポートし、開発者はnpmのパッケージを活用し既存のJavaScriptアプリと統合させることができます。 + +### コミュニティに参加する 😊 + +* [GitHub issues page](https://github.com/yewstack/yew/issues) でバグを報告したり機能について議論できます。 +* プルリクエストはぜひウェルカムです。ご協力いただけるなら [good first issues](https://github.com/yewstack/yew/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) をご確認ください。 +* 私たちの [Discord chat](https://discord.gg/VQck8X4) はとても活発で質問するのに良い場所です。 + +### 始める準備はいいですか? + +以下のリンクをクリックして初めてのYewアプリの作り方を学び、コミュニティのプロジェクト例を見てみましょう。 + +[始める](getting-started/project-setup.md) + +### まだ満足していませんか? + +このプロジェクトは先進的な技術によって成り立っており、これからの基礎となるプロジェクトを作っていきたい開発者にとっては素晴らしいものです。 +ここではYewのようなフレームワークがどうしてWeb開発における未来となると考えられるかについての理由を述べていきます。 + +#### 待って、どうしてWebAssembly? + +WebAssembly _\(Wasm\)_ はRustがコンパイル可能な軽量で低レベルな言語です。 +WebAssemblyはブラウザでネイティブ並の速度で動き、JavaScriptと互換性があり、そして全ての主要なブラウザでサポートされています。 +アプリでWebAssemblyをどう使いこなすかについては [use cases](https://webassembly.org/docs/use-cases/) のリストをご確認ください。 + +気をつけなければいけないこととして、Wasmは\(まだ\)Webアプリのパフォーマンスを改善する銀の弾丸ではありません。 +現時点では、DOMのAPIをWebAssemblyから使うのはまだJavaScriptから直接呼ぶよりも遅いのです。 +これは [WebAssembly Interface Types](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md) が解決しようとしている今のところの課題です。 +詳しい情報についてはMozillaの提案が書いてある [excellent article](https://hacks.mozilla.org/2019/08/webassembly-interface-types/) +をご確認ください。 + +#### わかった、でもどうしてRust? + +Rustは目まぐるしいほど高速に動作し、素晴らしい型と所有権モデルによって信頼性があります。 +Rustには厳しい学習曲線がありますが、努力するだけの十分な価値があります。 +RustはStack OverFlowによる開発者調査で5年連続で最も愛されている言語に選ばれています: +[2016](https://insights.stackoverflow.com/survey/2016#technology-most-loved-dreaded-and-wanted), +[2017](https://insights.stackoverflow.com/survey/2017#most-loved-dreaded-and-wanted), +[2018](https://insights.stackoverflow.com/survey/2018#technology-_-most-loved-dreaded-and-wanted-languages), +[2019](https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages), +[2020](https://insights.stackoverflow.com/survey/2020#most-loved-dreaded-and-wanted). + +同時にRustは素晴らしい型システムと所有権モデルによって開発者がより安全なコードを書くようサポートしてくれます。 +JavaScriptでの追跡するのが難しいバグよ、さよなら! +実際にRustではコードを走らせるまでもなくコンパイラによってバグのほとんどは捕捉されます。 +そして心配することなかれ、アプリを走らせてエラーになったとしてもブラウザのコンソールでRustのコードを完全に追跡することができます。 + +#### 代わりは? + +私たちは喜んで他のプロジェクトのアイデアを共有し、このワクワクする新たな技術のあらゆる可能性を実現できるよう皆が互いに助け合えると信じています。 +もしYewがグッとこない場合は以下のプロジェクトがいいかもしれません。 + +* [Percy](https://github.com/chinedufn/percy) - _"RustとWebAssemblyで同一なWebアプリを作る組み立てツール"_ +* [Seed](https://github.com/seed-rs/seed) - _"Webアプリを作るためのRustフレームワーク"_ diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/css.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/css.md new file mode 100644 index 000000000..424fabcd6 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/css.md @@ -0,0 +1,18 @@ +--- +title: CSS +--- + +# CSS + +<TODO> + +統合的なCSSサポートについての提案はこちらにあります: [https://github.com/yewstack/yew/issues/533](https://github.com/yewstack/yew/issues/533) + +## スタイルフレームワーク: + +今のところ、コミュニティメンバーは以下のスタイルフレームワークを開発しています。 + +* [yew_styles](https://github.com/spielrs/yew_styles) - JavaScriptに依存しないYewのスタイルフレームワーク +* [yew-mdc](https://github.com/Follpvosten/yew-mdc) - マテリアルデザインのコンポーネント +* [muicss-yew](https://github.com/AlephAlpha/muicss-yew) - MUIのCSSコンポーネント +* [Yewtify](https://github.com/yewstack/yewtify) – YewでVuetifyフレームワークで提供されている機能の実装 \ No newline at end of file diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/debugging.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/debugging.md new file mode 100644 index 000000000..9fc7ade49 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/debugging.md @@ -0,0 +1,58 @@ +--- +title: Debugging +--- + +# デバッグ + +## パニック + +Rustシンボルで良いスタックトレースをするには +[`console_error_panic`](https://github.com/rustwasm/console_error_panic_hook)クレートを使用してください。 +注意として、`cargo-web`でビルドされたものとは互換性がありません。 + +## コンソールでのログ + +一般的に、WasmのWebアプリはブラウザのAPIと連携することができ、`console.log`のAPIも例外ではありません。 +いつくかの選択肢があります: + +### [`wasm-logger`](https://crates.io/crates/wasm-logger) + +このクレートはRustの`log`クレートと親和性があります。 + +```rust +// セットアップ +fn main() { + wasm_logger::init(wasm_logger::Config::default()); +} + +// 使用方法 +log::info!("Update: {:?}", msg); +``` + +### [`ConsoleService`](https://docs.rs/yew/latest/yew/services/console/struct.ConsoleService.html) + +このサービスはYewに含まれており、`"services"`の機能が有効化されている場合は利用可能です。 + +```rust +// 使用方法 +ConsoleService::new()::info(format!("Update: {:?}", msg)); +``` + +## ソースマップ + +今のところはRust/WasmのWebアプリにはソースマップへの第一級のサポートがありません。 +もちろん、これは変更される可能性があります。これが当てはまらない場合、または進捗が見られる場合は、変更を提案してください! + +### 最新情報 + +\[2019年12月\] [Chrome DevTools update](https://developers.google.com/web/updates/2019/12/webassembly#the_future) + +> やらなければいけないことがまだたくさんあります。例えばツール側ではEmscripten\(Binaryen\)とwasm-pack\(wasm-bindgen\)がそれらが実行する変換に関するDWARF情報の更新をまだサポートしていません。 + +\[2020\] [Rust Wasm デバッグガイド](https://rustwasm.github.io/book/reference/debugging.html#using-a-debugger) + +> 残念なことに、WebAssemblyのデバッグの物語はまだ未成熟です。ほとんどのUnixのシステムでは[DWARF](http://dwarfstd.org/)は実行中のプログラムをソースレベルで検査するためにデバッガに必要な情報をエンコードするために使用されます。Windowsには同様の情報をエンコードする代替形式があります。現在、WebAssemblyに相当するものはありません。 + +\[2019\] [Rust Wasm ロードマップ](https://rustwasm.github.io/rfcs/007-2019-roadmap.html#debugging) + +> デバッグはトリッキーです。なぜなら、多くの話はこの活動チームの手の届かないところにあり、WebAssembly の標準化団体とブラウザ開発者ツールを実装している人たちの両方に依存しているからです。 diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md new file mode 100644 index 000000000..e2683a454 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/external-libs.md @@ -0,0 +1,27 @@ +--- +title: External libraries +description: Libraries that can help with yew development +--- + +# 外部ライブラリ + +### Yewtil + +YewtilはYewのプログラムを書きやすくするユーティリティ集です。 +含まれているのは: + +* NeqAssign - 先述の通り、再レンダリングを最小化するようpropsを割り当てる方法です +* PureComponents - 状態を更新しないコンポーネント。NeqAssignを使用するとマクロの中から通常のコンポーネントのように呼び出される関数がメモ化されます。 + +* Lrc - リンクされたリストは、`Rc`のようにカウントされたスマートポインタ関数を参照しますが、新しいデータ更新パターンを可能にします。 +* Mrc/Irc - Mutable/Immutable 参照カウントのスマートポインタは `Rc` のように機能しますが、`Mrc` に対して `DerefMut` と `BorrowMut` を実装しているため、Yew の中でより使いやすくなっています。これにより、`Mrc` を `NeqAssign` と一緒に使うことができます。`Irc` はデータに対する不変のビューとして機能するので、表示のみのタスクで使用されるデータを保持するのに理想的です。 + +* History - `VecDeque` を用いて、表示した過去の値を保持する履歴追跡ラッパーです。 +* Futures - コンポーネントの更新ループにメッセージを送信するのをサポートします。 +* Fetch - `web_sys` と前述のfuturesの機能を用いたフェッチリクエストを処理するための抽象化です。 + +## お探しのものは + +エコシステムが必要なライブラリですが、まだありません。 + +Bootstrap/MaterialUi/arbitraryといったCSSフレームワークのコンポーネントのラッパー。 \ No newline at end of file diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md new file mode 100644 index 000000000..37950c578 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/roadmap.md @@ -0,0 +1,46 @@ +--- +title: Roadmap +description: The planned feature roadmap for the Yew framework +--- + +# ロードマップ + +## 優先順位 + +フレームワークの今後の機能やフォーカスの優先順位は、コミュニティによって決定されます。2020年の春には、プロジェクトの方向性についてのフィードバックを集めるために開発者アンケートが行われました。その概要は [Yew Wiki](https://github.com/yewstack/yew/wiki/Dev-Survey-%5BSpring-2020%5D) で見ることができます。 + +:::note +主要な取り組みの状況は、YewのGithubの[Project board](https://github.com/yewstack/yew/projects)で確認できます。 +::: + +## 焦点 + +1. Top Requested Features +2. Production Readiness +3. Documentation +4. Pain Points + +### Top Requested Features + +1. [関数型コンポーネント](https://github.com/yewstack/yew/projects/3) +2. [Componentライブラリ](https://github.com/yewstack/yew/projects/4) +3. より良い状態管理 +4. [サーバーサイドでのレンダリング](https://github.com/yewstack/yew/projects/5) + +### Production Readiness + +* テストカバレッジの向上 +* バイナリサイズ +* [ベンチマークのパフォーマンス](https://github.com/yewstack/yew/issues/5) + +### Documentation + +* チュートリアルを作る +* プロジェクトのセットアップをシンプルにする + +### Pain Points + +* [Componentのボイラープレート](https://github.com/yewstack/yew/issues/830) +* Fetch API +* [エージェント](https://github.com/yewstack/yew/projects/6) + diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md new file mode 100644 index 000000000..9093d5b83 --- /dev/null +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.18.0/more/testing.md @@ -0,0 +1,12 @@ +--- +title: Testing apps +description: Testing your app +--- + +# Testing + +<TODO> + +## wasm\_bindgen\_test + +Rust Wasm ワーキンググループは wasm_bindgen_test というフレームワークをメンテナンスしており、組み込みの #[test] プロシージャルマクロの動作と同様の方法でブラウザでテストを実行することができます。詳細は、[Rust Wasm 活動グループのドキュメント](https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/index.html)に記載されています。 diff --git a/website/i18n/zh-CN.json b/website/i18n/zh-CN.json deleted file mode 100644 index 0b78580ef..000000000 --- a/website/i18n/zh-CN.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "localized-strings": { - "next": "Next", - "previous": "Previous", - "tagline": "Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.", - "docs": { - "advanced-topics/how-it-works": { - "title": "底层库的内部细节" - }, - "advanced-topics/optimizations": { - "title": "性能优化与最佳实践", - "sidebar_label": "性能优化" - }, - "concepts/agents": { - "title": "Agents" - }, - "concepts/components": { - "title": "组件(Components)" - }, - "concepts/components/callbacks": { - "title": "回调(Callbacks)" - }, - "concepts/components/properties": { - "title": "属性(Properties)" - }, - "concepts/components/refs": { - "title": "Refs" - }, - "concepts/html": { - "title": "使用 html! 宏", - "sidebar_label": "html!" - }, - "concepts/html/components": { - "title": "组件" - }, - "concepts/html/elements": { - "title": "元素" - }, - "concepts/html/lists": { - "title": "列表" - }, - "concepts/html/literals-and-expressions": { - "title": "常量和表达式" - }, - "concepts/router": { - "title": "Router" - }, - "concepts/services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "concepts/services/format": { - "title": "Format" - }, - "getting-started/build-a-sample-app": { - "title": "第一个简单的 App" - }, - "getting-started/choose-web-library": { - "title": "选择 web-sys 还是 stdweb" - }, - "getting-started/examples": { - "title": "例子" - }, - "getting-started/project-setup": { - "title": "项目设置", - "sidebar_label": "简介" - }, - "getting-started/project-setup/using-cargo-web": { - "title": "使用 cargo-web" - }, - "getting-started/project-setup/using-wasm-bindgen": { - "title": "使用 wasm-bindgen" - }, - "getting-started/project-setup/using-wasm-pack": { - "title": "使用 wasm-pack" - }, - "getting-started/starter-templates": { - "title": "新手模板" - }, - "index": { - "title": "简介" - }, - "more/css": { - "title": "CSS" - }, - "more/debugging": { - "title": "Debugging" - }, - "more/external-libs": { - "title": "外部库" - }, - "more/roadmap": { - "title": "路线图" - }, - "more/testing": { - "title": "测试" - }, - "README": { - "title": "README" - }, - "SUMMARY": { - "title": "SUMMARY" - }, - "version-0.17.3-advanced-topics/how-it-works": { - "title": "How it works" - }, - "version-0.17.3-advanced-topics/optimizations": { - "title": "Optimizations & Best Practices", - "sidebar_label": "Optimizations" - }, - "version-0.17.3-concepts/agents": { - "title": "Agents" - }, - "version-0.17.3-concepts/components": { - "title": "Introduction" - }, - "version-0.17.3-concepts/components/callbacks": { - "title": "Callbacks" - }, - "version-0.17.3-concepts/components/properties": { - "title": "Properties" - }, - "version-0.17.3-concepts/components/refs": { - "title": "Refs" - }, - "version-0.17.3-concepts/html": { - "title": "html!", - "sidebar_label": "Introduction" - }, - "version-0.17.3-concepts/html/components": { - "title": "Components" - }, - "version-0.17.3-concepts/html/elements": { - "title": "Elements" - }, - "version-0.17.3-concepts/html/lists": { - "title": "Lists" - }, - "version-0.17.3-concepts/html/literals-and-expressions": { - "title": "Literals and Expressions" - }, - "version-0.17.3-concepts/router": { - "title": "Router" - }, - "version-0.17.3-concepts/services": { - "title": "Services", - "sidebar_label": "Overview" - }, - "version-0.17.3-concepts/services/format": { - "title": "Format" - }, - "version-0.17.3-getting-started/build-a-sample-app": { - "title": "Build a sample app" - }, - "version-0.17.3-getting-started/choose-web-library": { - "title": "Choosing a web library" - }, - "version-0.17.3-getting-started/examples": { - "title": "Examples" - }, - "version-0.17.3-getting-started/project-setup": { - "title": "Project Setup", - "sidebar_label": "Introduction" - }, - "version-0.17.3-getting-started/project-setup/using-cargo-web": { - "title": "Using cargo-web" - }, - "version-0.17.3-getting-started/project-setup/using-wasm-bindgen": { - "title": "Using wasm-bindgen" - }, - "version-0.17.3-getting-started/project-setup/using-wasm-pack": { - "title": "Using wasm-pack" - }, - "version-0.17.3-getting-started/starter-templates": { - "title": "Starter templates" - }, - "version-0.17.3-index": { - "title": "Introduction" - }, - "version-0.17.3-more/css": { - "title": "CSS" - }, - "version-0.17.3-more/debugging": { - "title": "Debugging" - }, - "version-0.17.3-more/external-libs": { - "title": "External libraries" - }, - "version-0.17.3-more/roadmap": { - "title": "Roadmap" - }, - "version-0.17.3-more/testing": { - "title": "Testing apps" - } - }, - "links": { - "Changelog": "Changelog", - "API": "API", - "Discord": "Discord" - }, - "categories": { - "Getting Started": "从零开始", - "Concepts": "核心概念", - "Advanced topics": "高级主题", - "More": "更多" - } - }, - "pages-strings": { - "Help Translate|recruit community translators for your project": "Help Translate", - "Edit this Doc|recruitment message asking to edit the doc source": "Edit", - "Translate this Doc|recruitment message asking to translate the docs": "Translate" - } -} diff --git a/website/translated_docs/zh-CN/SUMMARY.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/SUMMARY.md similarity index 100% rename from website/translated_docs/zh-CN/SUMMARY.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/SUMMARY.md diff --git a/website/translated_docs/zh-CN/advanced-topics/how-it-works.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced-topics/how-it-works.md similarity index 100% rename from website/translated_docs/zh-CN/advanced-topics/how-it-works.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced-topics/how-it-works.md diff --git a/website/translated_docs/zh-CN/advanced-topics/optimizations.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced-topics/optimizations.md similarity index 100% rename from website/translated_docs/zh-CN/advanced-topics/optimizations.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced-topics/optimizations.md diff --git a/website/translated_docs/zh-CN/concepts/agents.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/agents.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/agents.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/agents.md diff --git a/website/translated_docs/zh-CN/concepts/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/components.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components.md diff --git a/website/translated_docs/zh-CN/concepts/components/callbacks.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/callbacks.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/components/callbacks.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/callbacks.md diff --git a/website/translated_docs/zh-CN/concepts/components/properties.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/properties.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/components/properties.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/properties.md diff --git a/website/translated_docs/zh-CN/concepts/components/refs.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/refs.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/components/refs.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/components/refs.md diff --git a/website/translated_docs/zh-CN/concepts/html.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/html.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html.md diff --git a/website/translated_docs/zh-CN/concepts/html/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/components.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/html/components.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/components.md diff --git a/website/translated_docs/zh-CN/concepts/html/elements.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/elements.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/html/elements.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/elements.md diff --git a/website/translated_docs/zh-CN/concepts/html/lists.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/lists.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/html/lists.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/lists.md diff --git a/website/translated_docs/zh-CN/concepts/html/literals-and-expressions.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/literals-and-expressions.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/html/literals-and-expressions.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/html/literals-and-expressions.md diff --git a/website/translated_docs/zh-CN/concepts/router.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/router.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/router.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/router.md diff --git a/website/translated_docs/zh-CN/concepts/services.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/services.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/services.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/services.md diff --git a/website/translated_docs/zh-CN/concepts/services/format.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/services/format.md similarity index 100% rename from website/translated_docs/zh-CN/concepts/services/format.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/concepts/services/format.md diff --git a/website/translated_docs/zh-CN/getting-started/build-a-sample-app.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/build-a-sample-app.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/build-a-sample-app.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/build-a-sample-app.md diff --git a/website/translated_docs/zh-CN/getting-started/choose-web-library.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md similarity index 63% rename from website/translated_docs/zh-CN/getting-started/choose-web-library.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md index 99e9aba94..4453e208b 100644 --- a/website/translated_docs/zh-CN/getting-started/choose-web-library.md +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/choose-web-library.md @@ -46,38 +46,38 @@ window.alert("hello from wasm!"); - - + - - - + + + style={{ textAlign: "left" }}>超过四个月没有 Github 活动 - - + - + - - + - - - + - - + -
      web-sys + web-sys stdweb + stdweb
      项目状态Rust / Wasm 工作组积极维护项目状态Rust / Wasm 工作组积极维护 超过四个月没有 Github 活动
      Web API 覆盖率Rust API 是从 Web IDL 规范自动生成,因此理论上有 + Web API 覆盖率Rust API 是从 Web IDL 规范自动生成,因此理论上有 100% 的覆盖率。浏览器 API 是根据需求由社区添加浏览器 API 是根据需求由社区添加
      Rust API 设计采取保守的方法,为大多数 + Rust API 设计采取保守的方法,为大多数 API 调用返回 Result 通常拒绝返回 Result 而更倾向于使用 + 通常拒绝返回 Result 而更倾向于使用 panic。例如,在 worker 中调用 stdweb::web::window() 将 panic。
      支持的构建工具 + 支持的构建工具
      • wasm-bindgen
      • @@ -85,7 +85,7 @@ window.alert("hello from wasm!");
      +
      • cargo-web
      • @@ -97,15 +97,15 @@ window.alert("hello from wasm!");
      支持生成的目标代码支持生成的目标代码 + style={{ textAlign: "left" }}>
      • wasm32-unknown-unknown
      +
      • wasm32-unknown-unknown
      • diff --git a/website/translated_docs/zh-CN/getting-started/examples.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/examples.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/examples.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/examples.md diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup.md new file mode 100644 index 000000000..2daf46a6b --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup.md @@ -0,0 +1,138 @@ +--- +description: 为成功做好准备 +--- + +# 项目设置 + +## Rust + +首先 ,你需要安装 Rust 。如何安装 Rust 和 `cargo` 构建工具,请参考[官方说明](https://www.rust-lang.org/tools/install)。 + +## **Wasm 构建工具** + +需要安装额外的工具以方便 WebAssembly 与 JavaScript 间的相互操作。此外,根据你选择的工具,他们可以生成所有必需的 JavaScript 包装代码来让你的应用程序中的 `.wasm` 文件运行在浏览器中,从而帮助减轻部署和打包的麻烦。 + +### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) + +一个由 Rust / Wasm 工作组开发的用于打包 WebAssembly 的 CLI 工具。与 Webpack 的 [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin) 插件搭配使用最佳。 + +[开始使用 wasm-pack](project-setup/using-wasm-pack.md) + +### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/) + +同时是一个库和一个 CLI 工具,也是由 Rust / Wasm 工作组开发。它是一个促进 JS 和 WebAssembly 之间互操作性的底层工具(在 `wasm-pack` 内部被用到)。我们不建议直接使用 `wasm-bindgen` 因为它需要手写一些 JavaScript 代码来引导你的 WebAssembly 二进制程序。但是,直接使用它也是可能的并且可以在 [**`wasm-bindgen` 指南**](https://rustwasm.github.io/docs/wasm-bindgen/) 上找到更多信息。 + +[开始使用 wasm-bindgen](project-setup/using-wasm-bindgen.md) + +### [**`cargo-web`**](https://github.com/koute/cargo-web) + +在 `wasm-pack` 和 `wasm-bindgen` 被介绍前的首选 web 工作流工具。它仍然是**最快捷**的启动和运行方式,值得安装以运行尚未迁移到支持 `wasm-pack` 的示例程序。 + +[开始使用 cargo-web](project-setup/using-cargo-web.md) + +### 对比 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        wasm-pack + wasm-bindgen + cargo-web +
        项目状态Rust / Wasm 工作组积极维护Rust / Wasm 工作组积极维护超过六个月没有 Github 活动
        开发体验接近完美!需要 webpack 以获得最佳体验。比较基础。你需要编写一些脚本来简化你的开发体验。管用!自带“电池”,不需要外部依赖。
        本地服务器通过 webpack 插件支持不支持支持
        根据本地更改自动重新构建通过 webpack 插件支持不支持支持
        无头浏览器测试支持 + 支持 + 支持 +
        支持生成的目标代码 +
          +
        • wasm32-unknown-unknown +
        • +
        +
        +
          +
        • wasm32-unknown-unknown +
        • +
        +
        +
          +
        • wasm32-unknown-unknown +
        • +
        • wasm32-unknown-emscripten +
        • +
        • asmjs-unknown-emscripten +
        • +
        +
        web-sys + 兼容兼容不兼容
        stdweb + 兼容兼容兼容
        示例用法新手模板 + Yew 示例程序的构建脚本 + Yew 示例程序的构建脚本 +
        diff --git a/website/translated_docs/zh-CN/getting-started/project-setup/using-cargo-web.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-cargo-web.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/project-setup/using-cargo-web.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-cargo-web.md diff --git a/website/translated_docs/zh-CN/getting-started/project-setup/using-wasm-bindgen.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-bindgen.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/project-setup/using-wasm-bindgen.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-bindgen.md diff --git a/website/translated_docs/zh-CN/getting-started/project-setup/using-wasm-pack.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-pack.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/project-setup/using-wasm-pack.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/project-setup/using-wasm-pack.md diff --git a/website/translated_docs/zh-CN/getting-started/starter-templates.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/starter-templates.md similarity index 100% rename from website/translated_docs/zh-CN/getting-started/starter-templates.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/starter-templates.md diff --git a/website/translated_docs/zh-CN/index.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/index.md similarity index 100% rename from website/translated_docs/zh-CN/index.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/index.md diff --git a/website/translated_docs/zh-CN/more/css.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/css.md similarity index 100% rename from website/translated_docs/zh-CN/more/css.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/css.md diff --git a/website/translated_docs/zh-CN/more/debugging.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/debugging.md similarity index 100% rename from website/translated_docs/zh-CN/more/debugging.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/debugging.md diff --git a/website/translated_docs/zh-CN/more/external-libs.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/external-libs.md similarity index 100% rename from website/translated_docs/zh-CN/more/external-libs.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/external-libs.md diff --git a/website/translated_docs/zh-CN/more/roadmap.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/roadmap.md similarity index 100% rename from website/translated_docs/zh-CN/more/roadmap.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/roadmap.md diff --git a/website/translated_docs/zh-CN/more/testing.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/testing.md similarity index 100% rename from website/translated_docs/zh-CN/more/testing.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/current/more/testing.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/SUMMARY.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/SUMMARY.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/SUMMARY.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/SUMMARY.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/advanced-topics/how-it-works.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/advanced-topics/how-it-works.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/advanced-topics/how-it-works.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/advanced-topics/how-it-works.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/advanced-topics/optimizations.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/advanced-topics/optimizations.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/advanced-topics/optimizations.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/advanced-topics/optimizations.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/agents.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/agents.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/agents.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/agents.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/components.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/components/callbacks.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/callbacks.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/components/callbacks.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/callbacks.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/components/properties.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/properties.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/components/properties.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/properties.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/components/refs.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/refs.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/components/refs.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/components/refs.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/html.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/html.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/html/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/components.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/html/components.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/components.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/html/elements.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/elements.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/html/elements.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/elements.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/html/lists.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/lists.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/html/lists.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/lists.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/html/literals-and-expressions.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/literals-and-expressions.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/html/literals-and-expressions.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/html/literals-and-expressions.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/router.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/router.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/router.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/router.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/services.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/services.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/services.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/services.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/concepts/services/format.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/services/format.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/concepts/services/format.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/concepts/services/format.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/build-a-sample-app.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/build-a-sample-app.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/build-a-sample-app.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/build-a-sample-app.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/choose-web-library.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/choose-web-library.md similarity index 63% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/choose-web-library.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/choose-web-library.md index 99e9aba94..4453e208b 100644 --- a/website/translated_docs/zh-CN/version-0.17.3/getting-started/choose-web-library.md +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/choose-web-library.md @@ -46,38 +46,38 @@ window.alert("hello from wasm!"); - - + - - - + + + style={{ textAlign: "left" }}>超过四个月没有 Github 活动 - - + - + - - + - - - + - - + -
        web-sys + web-sys stdweb + stdweb
        项目状态Rust / Wasm 工作组积极维护项目状态Rust / Wasm 工作组积极维护 超过四个月没有 Github 活动
        Web API 覆盖率Rust API 是从 Web IDL 规范自动生成,因此理论上有 + Web API 覆盖率Rust API 是从 Web IDL 规范自动生成,因此理论上有 100% 的覆盖率。浏览器 API 是根据需求由社区添加浏览器 API 是根据需求由社区添加
        Rust API 设计采取保守的方法,为大多数 + Rust API 设计采取保守的方法,为大多数 API 调用返回 Result 通常拒绝返回 Result 而更倾向于使用 + 通常拒绝返回 Result 而更倾向于使用 panic。例如,在 worker 中调用 stdweb::web::window() 将 panic。
        支持的构建工具 + 支持的构建工具
        • wasm-bindgen
        • @@ -85,7 +85,7 @@ window.alert("hello from wasm!");
        +
        • cargo-web
        • @@ -97,15 +97,15 @@ window.alert("hello from wasm!");
        支持生成的目标代码支持生成的目标代码 + style={{ textAlign: "left" }}>
        • wasm32-unknown-unknown
        +
        • wasm32-unknown-unknown
        • diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/examples.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/examples.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/examples.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/examples.md diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup.md new file mode 100644 index 000000000..2daf46a6b --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup.md @@ -0,0 +1,138 @@ +--- +description: 为成功做好准备 +--- + +# 项目设置 + +## Rust + +首先 ,你需要安装 Rust 。如何安装 Rust 和 `cargo` 构建工具,请参考[官方说明](https://www.rust-lang.org/tools/install)。 + +## **Wasm 构建工具** + +需要安装额外的工具以方便 WebAssembly 与 JavaScript 间的相互操作。此外,根据你选择的工具,他们可以生成所有必需的 JavaScript 包装代码来让你的应用程序中的 `.wasm` 文件运行在浏览器中,从而帮助减轻部署和打包的麻烦。 + +### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/) + +一个由 Rust / Wasm 工作组开发的用于打包 WebAssembly 的 CLI 工具。与 Webpack 的 [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin) 插件搭配使用最佳。 + +[开始使用 wasm-pack](project-setup/using-wasm-pack.md) + +### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/) + +同时是一个库和一个 CLI 工具,也是由 Rust / Wasm 工作组开发。它是一个促进 JS 和 WebAssembly 之间互操作性的底层工具(在 `wasm-pack` 内部被用到)。我们不建议直接使用 `wasm-bindgen` 因为它需要手写一些 JavaScript 代码来引导你的 WebAssembly 二进制程序。但是,直接使用它也是可能的并且可以在 [**`wasm-bindgen` 指南**](https://rustwasm.github.io/docs/wasm-bindgen/) 上找到更多信息。 + +[开始使用 wasm-bindgen](project-setup/using-wasm-bindgen.md) + +### [**`cargo-web`**](https://github.com/koute/cargo-web) + +在 `wasm-pack` 和 `wasm-bindgen` 被介绍前的首选 web 工作流工具。它仍然是**最快捷**的启动和运行方式,值得安装以运行尚未迁移到支持 `wasm-pack` 的示例程序。 + +[开始使用 cargo-web](project-setup/using-cargo-web.md) + +### 对比 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          wasm-pack + wasm-bindgen + cargo-web +
          项目状态Rust / Wasm 工作组积极维护Rust / Wasm 工作组积极维护超过六个月没有 Github 活动
          开发体验接近完美!需要 webpack 以获得最佳体验。比较基础。你需要编写一些脚本来简化你的开发体验。管用!自带“电池”,不需要外部依赖。
          本地服务器通过 webpack 插件支持不支持支持
          根据本地更改自动重新构建通过 webpack 插件支持不支持支持
          无头浏览器测试支持 + 支持 + 支持 +
          支持生成的目标代码 +
            +
          • wasm32-unknown-unknown +
          • +
          +
          +
            +
          • wasm32-unknown-unknown +
          • +
          +
          +
            +
          • wasm32-unknown-unknown +
          • +
          • wasm32-unknown-emscripten +
          • +
          • asmjs-unknown-emscripten +
          • +
          +
          web-sys + 兼容兼容不兼容
          stdweb + 兼容兼容兼容
          示例用法新手模板 + Yew 示例程序的构建脚本 + Yew 示例程序的构建脚本 +
          diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-cargo-web.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-cargo-web.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-cargo-web.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-cargo-web.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-wasm-bindgen.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-wasm-pack.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-wasm-pack.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/project-setup/using-wasm-pack.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/project-setup/using-wasm-pack.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/getting-started/starter-templates.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/starter-templates.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/getting-started/starter-templates.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/getting-started/starter-templates.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/index.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/index.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/index.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/index.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/more/css.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/css.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/more/css.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/css.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/more/debugging.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/debugging.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/more/debugging.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/debugging.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/more/external-libs.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/external-libs.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/more/external-libs.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/external-libs.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/more/roadmap.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/roadmap.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/more/roadmap.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/roadmap.md diff --git a/website/translated_docs/zh-CN/version-0.17.3/more/testing.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/testing.md similarity index 100% rename from website/translated_docs/zh-CN/version-0.17.3/more/testing.md rename to website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.17.3/more/testing.md diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md new file mode 100644 index 000000000..c1405191e --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/SUMMARY.md @@ -0,0 +1,44 @@ +# Table of contents + +* [简介](README.md) + +## 从零开始 + +* [项目设置](getting-started/project-setup.md) + * [使用 wasm-pack](getting-started/project-setup/using-wasm-pack.md) + * [使用 wasm-bindgen](getting-started/project-setup/using-wasm-bindgen.md) + * [使用 cargo-web](getting-started/project-setup/using-cargo-web.md) +* [新手模板](getting-started/starter-templates.md) +* [第一个简单的 App](getting-started/build-a-sample-app.md) +* [选择 web-sys 还是 stdweb](getting-started/choose-web-library.md) +* [通过例子学习](getting-started/examples.md) + +## 核心概念 + +* [使用 html! 宏](concepts/html.md) + * [列表](concepts/html/lists.md) + * [元素](concepts/html/elements.md) + * [常量和表达式](concepts/html/literals-and-expressions.md) + * [组件](concepts/html/components.md) +* [组件(Components)](concepts/components.md) + * [属性(Properties)](concepts/components/properties.md) + * [回调(Callbacks)](concepts/components/callbacks.md) + * [Refs](concepts/components/refs.md) +* [Agents](concepts/agents.md) +* [Services](concepts/services.md) + * [Format](concepts/services/format.md) +* [Router](concepts/router.md) + +## 高级主题 + +* [性能优化与最佳实践](advanced-topics/optimizations.md) +* [底层库的内部细节](advanced-topics/how-it-works.md) + +## 更多 + +* [CSS](more/css.md) +* [路线图](more/roadmap.md) +* [测试](more/testing.md) +* [Debugging](more/debugging.md) +* [外部库](more/external-libs.md) + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md new file mode 100644 index 000000000..859c9480d --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/how-it-works.md @@ -0,0 +1,8 @@ +--- +description: 有关框架的底层细节 +--- + +# 底层库的内部细节 + +组件生命周期状态机,虚拟 dom diff 算法。 + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md new file mode 100644 index 000000000..72b1f4dfb --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/advanced-topics/optimizations.md @@ -0,0 +1,104 @@ +--- +description: 加速你的应用程序 +--- + +# 性能优化与最佳实践 + +## neq\_assign + +当组件从它的父组件接收 props 时,`change` 方法将被调用。除了允许你更新组件的状态,还允许你返回一个布尔类型的值 `ShouldRender` 来指示组件是否应该响应 props 的更改而重新渲染自身。 + +重新渲染的开销很大,你应该尽量避免。一个通用的法则是,你只应该在 props 实际更改时重新渲染。以下代码块展示了此法则,如果 props 和先前的 props 不同,则返回 `true`: + +```rust +fn change(&mut self, props: Self::Properties) -> ShouldRender { + if self.props != &props { + *self.props = props; + true + } else { + false + } +} +``` + +但是我们可以更进一步!对于任何实现了 `PartialEq` 的项,可以使用一个 trait 和一个 blanket implementation 将这六行样板代码减少到一行。 + +{% code title="neq\_assign.rs" %} +```rust +pub trait NeqAssign { + fn neq_assign(&mut self, new: Self) -> ShouldRender; +} +impl NeqAssign for T { + fn neq_assign(&mut self, new: T) -> ShouldRender { + if self != &new { + *self = new; + true + } else { + false + } + } +} + +// ... +fn change(&mut self, props: Self::Properties) -> ShouldRender { + self.props.neq_assign(props) +} +``` +{% endcode %} + +该 trait 称为 `NeqAssign` 是因为如果目标值和新值不相等,它将赋为新值。 + +这比简单的实现还要短: + +```rust +// 不要这样做,除非你无法避免。 +fn change(&mut self, props: Self::Properties) -> ShouldRender { + self.props = props; + true +} +``` + +你不仅限在 `change` 函数中使用它。通常,在 `update` 函数中执行此操作也是有意义的,尽管性能提升在那里不太明显。 + +## wee\_alloc + +[wee\_alloc](https://github.com/rustwasm/wee_alloc) 是一个比 Rust 二进制文件中通常使用的分配器还小得多的微型分配器。用这个分配器来替代默认的分配器将使 Wasm 文件体积更小,但会牺牲速度和内存开销。 + +对比不包含默认分配器换取的体积大小,牺牲的速度和内存开销是微不足道的。较小的文件体积意味着你的页面将加载更快,因此通常建议使用此分配器而不是默认分配器,除非你的应用程序会执行一些繁重的内存分配任务。 + +```rust +// 将 `wee_alloc` 作为全局分配器 +#[global_allocator] +static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; +``` + +## RC + +为了避免在重新渲染时为了创建 props 而克隆大块数据,我们可以使用智能指针来只克隆指针。如果在 props 和子组件中使用 `Rc<_>` 而不是普通未装箱的值,则可以延迟克隆直到需要修改子组件中的数据为止,在该组件中可以使用 `Rc::make_mut` 来对要更改数据进行克隆和获取可变引用。通过在要修改前不进行克隆,子组件可以在几乎没有性能成本的情况下拒绝与它们在 `Component::change` 中拥有状态的 props 相同的 props,这与数据本身需要先复制到父级 props 结构体中,然后在子级中进行比较和拒绝的情况相反。 + +对于不是 `Copy` 类型的数据,这种优化是最有用的。如果你能轻松地拷贝数据,那么将其放入智能指针中可能是不值得的。对于可以包含大量数据的结构,例如 `Vec`,`HashMap` 和 `String`,这种优化应该是值得的。 + +如果子组件从不更新组件的值,则这种优化效果最好,如果父组件很少更新组件的值,则效果更好。这使得 `Rc<_>s` 是包装纯组件属性值的不错选择。 + +## 视图函数 + +出于代码可读性的原因,将 `html!` 各个部分的代码迁移到他们自己的函数中通常是有意义的,这样就可以避免在深层嵌套的 HTML 中出现代码块向右偏移。 + +## 纯组件 / 函数式组件 + +纯组件是不会修改它们状态的组件,它们仅展示内容和向普通可变组件传递消息。它们与视图函数不同之处在于他们可以使用组件语法(``)而不是表达式语法(`{some_view_function()}`)来在 `html!` 宏中使用,并且根据它们的实现,它们可以被记忆化 - 使用前面提到的 `neq_assign` 逻辑来防止因为相同的 props 而重新渲染。 + +Yew 没有原生支持纯组件或者函数式组件,但是可以通过外部库获取它们。 + +函数式组件尚不存在,但是从理论上来讲,可以通过使用 proc 宏和标注函数生成纯组件。 + +## Keyed DOM nodes when they arrive + +## 使用 Cargo Workspaces 进行编译速度优化 + +可以说,使用 Yew 的最大缺点是编译时间长。编译时间似乎与 `html!` 宏块中的代码量相关。对于较小的项目,这通常不是什么大问题,但是对于跨多个页面的 web 应用程序,将代码拆分为多个 crates 以最大程度地减少编译器要做的工作通常是有意义的。 + +你应该尝试让主 crate 处理路由和页面选择,将所有公用的代码移动到另一个 crate,然后为每一个页面创建一个不同的 crate,其中每个页面可能是一个不同的组件,或者只是一个产生 `Html` 的大函数。在最好的情况下,你将从重新构建所有代码到只重新构建主 crate 和一个页面的 crate。在最糟糕的情况下,当你在“公共” crate 中编辑内容时,你将回到起点:编译所有依赖此公用 crate 的代码,这可能就是除此之外的所有代码。 + +如果你的主 crate 过于庞大,或者你想在深层嵌套的页面(例如,在另一个页面顶部渲染的页面)中快速迭代,则可以使用一个示例 crate 创建一个更简单的主页面实现并在之上渲染你正在开发的组件。 + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md new file mode 100644 index 000000000..9e92b25ca --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/agents.md @@ -0,0 +1,41 @@ +--- +title: Agents +description: Yew 的 Actor 系统 +--- + +Agents 和 Angular 的 [Services](https://angular.io/guide/architecture-services) 相似(但没有依赖注入),给 Yew 提供了 [Actor 模型](https://en.wikipedia.org/wiki/Actor_model)。Agents 可以用于在组件之间路由消息,而与它们在组件层次结构中的位置无关,或者可以用于协调全局状态,或者可以用于从主 UI 线程上卸载计算密集型任务,或者在不同的标签页间通信(在未来)。 + +Agents 使用 [web-workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) 同时运行来实现并发。 + +## 生命周期 + +![Agent lifecycle](https://user-images.githubusercontent.com/42674621/79125224-b6481d80-7d95-11ea-8e6a-ab9b52d1d8ac.png) + +## Agents 的类型 + +#### Reaches + +* Job - 在 UI 线程上为每个新的 Bridge 生成一个新的 Agent。这对于将与浏览器通信的共享但独立的行为移出组件是很有用的。(待验证)任务完成后,Agent 将消失。 +* Context - Bridges 将生成或连接到 UI 线程上的 agent。这可用于在组件和其它 Agents 之间协调状态。当没有 Bridge 连接到该 Agent 时,Agent 将消失。 +* Private - 与 Job 相同,但运行在自己的 web worker 中。 +* Public - 与 Context 相同,但运行在自己的 web worker 中。 +* Global \(WIP\) + +## Agent 通信 + +### Bridges + +Bridges 将连接到一个 Agent 并且允许双向通信。 + +### Dispatchers + +Dispatchers 和 Bridges 类似,但是他们只能发送消息给 Agents。 + +## 开销 + +Agents 通过使用二进制码 bincode 序列化其消息来进行通信。因此,存在比仅调用函数相比更高的性能消耗。除非计算成本或者在任意组件间协调的需求超过消息传递的成本,否则你应该尽可能地在函数中包含你的应用逻辑。 + +## Further reading + +* The [pub\_sub](https://github.com/yewstack/yew/tree/master/examples/pub_sub) example shows how components can use agents to communicate with each other. + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md new file mode 100644 index 000000000..48c4bd829 --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components.md @@ -0,0 +1,171 @@ +--- +description: 组件及其生命周期钩子 +--- + +# 组件(Components) + +## 组件是什么? + +组件是 Yew 的基石。它们管理自己的状态,并可以渲染为 DOM。组件是通过实现描述组件生命周期的 `Component` trait 来创建的。 + +## 生命周期 + +:::note +`为我们的文档做出贡献:`[添加组件的生命周期图示](https://github.com/yewstack/docs/issues/22) +::: + +## 生命周期方法 + +### Create + +当一个组件被创建时,它会从其父组件以及一个 `ComponentLink` 接收属性(properties)。属性(properties)可用于初始化组件的状态,“link”可用于注册回调或向组件发送消息。 + +通常将 props 和 link 存储在组件的结构体中,如下所示: + +```rust +pub struct MyComponent { + props: Props, + link: ComponentLink, +} + +impl Component for MyComponent { + type Properties = Props; + // ... + + fn create(props: Self::Properties, link: ComponentLink) -> Self { + MyComponent { props, link } + } + + // ... +} +``` + +### View + +组件在 `view()` 方法中声明它的布局。Yew 提供了 `html!` 宏来声明 HTML 和 SVG 节点和它们的监听器及其子组件。这个宏的行为很像 React 中的 JSX,但是使用的是 Rust 表达式而不是 JavaScript。 + +```rust +impl Component for MyComponent { + // ... + + fn view(&self) -> Html { + let onclick = self.link.callback(|_| Msg::Click); + html! { + + } + } +} +``` + +有关用法的详细信息,请查看 [`html!` 宏指南](html.md)] + +### Mounted + +`mounted()` 组件生命周期方法调用是在 `view()` 被处理并且 Yew 已经把组件挂载到 DOM 上之后,浏览器刷新页面之前。组件通常希望实现此方法以执行只能在组件渲染元素之后才能执行的操作。如果你想在做出一些更改后重新渲染组件,返回 `true` 就可以了。 + +```rust +use stdweb::web::html_element::InputElement; +use stdweb::web::IHtmlElement; +use yew::prelude::*; + +pub struct MyComponent { + node_ref: NodeRef, +} + +impl Component for MyComponent { + // ... + + fn view(&self) -> Html { + html! { + + } + } + + fn mounted(&mut self) -> ShouldRender { + if let Some(input) = self.node_ref.cast::() { + input.focus(); + } + false + } +} +``` + +:::note +请注意,此生命周期方法不要求必须实现,默认情况下不会执行任何操作。 +::: + +### Update + +组件是动态的,可以注册以接收异步信息。`update()` 生命周期方法对于每个消息都会被调用。这使得组件可以根据消息的内容来更新自身,并决定是否需要重新渲染自己。消息可以由 HTML 元素监听器触发,或者由子组件,Agents,Services 或 Futures 发送。 + +`update()` 可能看起来像下面这个例子: + +```rust +pub enum Msg { + SetInputEnabled(bool) +} + +impl Component for MyComponent { + type Message = Msg; + + // ... + + fn update(&mut self, msg: Self::Message) -> ShouldRender { + match msg { + Msg::SetInputEnabled(enabled) => { + if self.input_enabled != enabled { + self.input_enabled = enabled; + true // 重新渲染 + } else { + false + } + } + } + } +} +``` + +### Change + +组件可能被其父节点重新渲染。发生这种情况时,它们可以接收新的属性(properties)并选择重新渲染。这种设计通过更改属性(properties)来促进父子组件之间的通信。你不是必须实现 `change()`,但是如果想在组件被创建后通过 props 来更新组件,则可能要这么做。 + +一个原始的实现可能看起来像: + +```rust +impl Component for MyComponent { + // ... + + fn change(&mut self, props: Self::Properties) -> ShouldRender { + self.props = props; + true // 当提供了新的 props 将始终重新渲染。 + } +} +``` + +### Destroy + +组件从 DOM 上被卸载后,Yew 调用 `destroy()` 生命周期方法来支持任何必要的清理操作。这个方法是可选的,默认情况下不执行任何操作。 + +## 关联类型 + +`Component` trait 有两个关联类型:`Message` 和 `Properties`。 + +```rust +impl Component for MyComponent { + type Message = Msg; + type Properties = Props; + + // ... +} +``` + +`Message` 表示组件可以处理以触发某些副作用的各种消息。例如,你可能有一条 `Click` 消息,该消息触发 API 请求或者切换 UI 组件的外观。通常的做法是在组件模块中创建一个叫做 `Msg` 的枚举并将其用作组件中的消息类型。通常将“message”缩写为“msg”。 + +```rust +enum Msg { + Click, +} +``` + +`Properties` 表示从父级传递到组件的信息。此类型必须实现 `Properties` trait(通常通过派生),并且可以指定某些属性(properties)是必需的还是可选的。创建和更新组件时使用此类型。通常的做法是在组件模块中创建一个叫做 `Props` 的结构体并将其用作组件的 `Properties` 类型。通常将“properties”缩写为“props”。由于 props 是从父组件传递下来的,因此应用程序的根组件通常有一个类型为 `()` 的 `Properties`。如果你希望为根组件指定属性(properties),请使用 `App::mount_with_props` 方法。 + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md new file mode 100644 index 000000000..dc09fa05d --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/callbacks.md @@ -0,0 +1,28 @@ +--- +description: ComponentLink 和 Callbacks. +--- + +# 回调(Callbacks) + +组件“link”是一种机制,通过该机制,组件可以注册回调并自行更新。 + +## ComponentLink API + +### callback + +注册一个回调,该回调将在执行时将消息发送到组件的更新机制。在内部,它将使用提供的闭包返回的消息调用 `send_self`。提供 `Fn(IN) -> Vec`,返回 `Callback`。 + +### send\_message + +当前循环结束后立即向组件发送消息,导致另一个更新循环启动。 + +### send\_message\_batch + +注册一个回调,该回调在执行时立即发送一批消息。如果其中任何一个消息将导致组件重新渲染,那么组件会在该批次所有消息被处理后重新渲染。提供 `Fn(IN) -> COMP::Message`,返回 `Callback`。 + +## Callbacks + +Callbacks 用于与 Yew 中的 services,agents 和父组件进行通信。它们仅仅是个 `Fn`,并由 `Rc` 包裹以允许被克隆。 + +它们有一个 `emit` 函数,该函数将它的 `` 类型作为参数并将其转换为目标所期望的消息。如果一个回调从父组件中通过 props 提供给子组件,则子组件可以在其 `update` 生命周期钩子中对该回调调用 `emit`,以将消息发送回父组件。在 `html!` 宏内被提供作为 props 的闭包或函数会自动转换为 Callbacks。 + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md new file mode 100644 index 000000000..e37fbbce7 --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/properties.md @@ -0,0 +1,73 @@ +--- +description: 父组件到子组件的通信 +--- + +# 属性(Properties) + +如“组件(Components)”页面所述,Properties 用于父级到子组件的通信。 + +## 派生宏 + +不要尝试自己去实现 `Properties`,而是通过使用 `#[derive(Properties)]` 来派生它。 + +### 必需属性 + +默认情况下,实现了 `Properties` 的结构体中的字段是必需的。当缺少了该字段并且在 `html!` 宏中创建了组件时,将返回编译错误。对于具有可选属性的字段,使用 `#[prop_or_default]` 来使用该类型的默认值。要指定一个值,请使用 `#[prop_or_else(value)]`,其中 value 是该属性的默认值。例如,要将一个布尔值的默认值设置为 `true`,请使用属性 `#[prop_or_else(true)]`。可选属性通常使用 `Option`,其默认值为 `None`。 + +### PartialEq + +如果可以的话,在你的 props 上派生 `PartialEq` 通常是很有意义的。这使用了一个**性能优化与最佳实践**部分解释了的技巧,可以更轻松地避免重新渲染。 + +## Properties 的内存/速度开销 + +记住组件的 `view` 函数签名: + +```rust +fn view(&self) -> Html +``` + +你对组件的状态取了一个引用,并用来创建 `Html`。但是 properties 是有所有权的值(owned values)。这意味着为了创造它们并且将它们传递给子组件,我们需要获取 `view` 函数里提供的引用的所有权。这是在将引用传递给组件时隐式克隆引用完成的,以获得构成其 props 的有所有权的值。 + +这意味着每个组件都有从其父级传递来的状态的独特副本,而且,每当你重新渲染一个组件时,该重新渲染组件的所有子组件的 props 都将被克隆。 + +这意味着如果你将 _大量_ 数据作为 props(大小为 10 KB 的字符串)向下传递,则可能需要考虑将子组件转换为在父级运行返回 `Html` 的函数,因为这样就不会被强制克隆你的数据。 + +另外,如果你不需要修改作为 props 传递的大数据,而只需要显示它,则可以将其包装在 `Rc` 中,以便仅克隆一个引用计数的指针,而不是数据本身。 + +## 示例 + +```rust +pub struct LinkColor { + Blue, + Red, + Green, + Black, + Purple, +} + +impl Default for LinkColor { + fn default() -> Self { + // 除非另有说明,否则链接的颜色将为蓝色 + LinkColor::Blue + } +} + +#[derive(Properties, PartialEq)] +pub struct LinkProps { + /// 链接必须有一个目标地址 + href: String, + /// 如果链接文本很大,这将使得复制字符串开销更小 + /// 除非有性能问题,否则通常不建议这么做 + text: Rc, + /// 链接的颜色 + #[prop_or_default] + color: LinkColor, + /// 如果为 None,则 view 函数将不指定大小 + #[prop_or_default] + size: Option + /// 当 view 函数没有指定 active,其默认为 true + #[prop_or_else(true)] + active: bool, +} +``` + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md new file mode 100644 index 000000000..88bad4d99 --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/components/refs.md @@ -0,0 +1,23 @@ +--- +title: Refs +description: 超出界限的 DOM 访问 +--- + +`ref` 关键词可被用在任何 HTML 元素或组件内部以获得该项所附加到的 DOM 元素。这可被用于在 `view` 生命周期方法之外来对 DOM 进行更改。 + +这对于获取 canvas 元素或者滚动到页面的不同部分是有用的。 + +语法如下: + +```rust +// 在 create 中 +self.node_ref = NodeRef::default(); + +// 在 view 中 +html! { +
          +} + +// 在 update 中 +let has_attributes = self.node_ref.cast::().unwrap().has_attributes(); +``` diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md new file mode 100644 index 000000000..c40d71cc7 --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html.md @@ -0,0 +1,13 @@ +--- +description: 用于生成 HTML 和 SVG 的宏程序 +--- + +# 使用 html! 宏 + +`html!` 宏允许你为组件编写声明式的 HTML 和 SVG。如果你使用过 React 的 JSX,将会感觉到非常熟悉。 + +**重要提示** + +1. `html!` 宏调用中只能有一个根节点 +2. 空的 `html! {}` 宏调用是有效的但不会渲染任何内容 +3. 常量必须始终被引号括起来并被包含在大括号里:`html! { "Hello, World" }` diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md new file mode 100644 index 000000000..f4b7f502e --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/components.md @@ -0,0 +1,107 @@ +--- +description: 使用具有层次结构的组件来创建复杂的布局 +--- + +# 组件 + +## 基础 + +任何实现了 `Component` trait 的类型都可被用在 `html!` 宏中: + +```rust +html!{ + <> + // 没有属性 + + + // 具有属性 + + + // 同时提供全套的 props + + +} +``` + +## 嵌套 + +如果组件的 `Properties` 中有 `children` 字段,则可以被传递子组件。 + +{% code title="parent.rs" %} +```rust +html! { + +

          { "Hi" }

          +
          { "Hello" }
          +
          +} +``` +{% endcode %} + +{% code title="container.rs" %} +```rust +pub struct Container(Props); + +#[derive(Properties)] +pub struct Props { + pub children: Children, +} + +impl Component for Container { + type Properties = Props; + + // ... + + fn view(&self) -> Html { + html! { +
          + { self.0.children.clone() } +
          + } + } +} +``` +{% endcode %} + +## 拥有 Props 的嵌套子组件 + +如果包含组件标注了 children 的类型,则可以访问和更改嵌套组件的属性。在下面的示例中,`List` 组件可以包含 `ListItem` 组件。有关此模式的真实示例,请查看 `yew-router` 的源码。有关更高级的示例,请在 yew 主仓库中查看 `nested-list` 示例代码。 + +{% code title="parent.rs" %} +```rust +html! { + + + + + +} +``` +{% endcode %} + +{% code title="list.rs" %} +```rust +pub struct List(Props); + +#[derive(Properties)] +pub struct Props { + pub children: ChildrenWithProps, +} + +impl Component for List { + type Properties = Props; + + // ... + + fn view(&self) -> Html { + html!{{ + for self.0.children.iter().map(|mut item| { + item.props.value = format!("item-{}", item.props.value); + item + }) + }} + } +} +``` +{% endcode %} + diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md new file mode 100644 index 000000000..de7098dd4 --- /dev/null +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.18.0/concepts/html/elements.md @@ -0,0 +1,246 @@ +--- +description: HTML 和 SVG 元素均受支持 +--- + +# 元素 + +## 标签结构 + +元素标签必须是自闭合的 `<... />`,或是每个标签都有一个对应的闭合标签。 + + + +```rust +html! { +
          +} +``` + + +```rust +html! { +
          // <- 缺少闭合标签 +} +``` + + +```rust +html! { + +} +``` + + +```rust +html! { + // <- 没有自闭合 +} +``` + + +:::note +为方便起见,一些 _通常_ 需要闭合标签的元素是被**允许**自闭合的。例如,`html! {
          }` 这样写是有效的。 +::: + +## Children + +轻松创建复杂的嵌套 HTML 和 SVG 布局: + + + +```rust +html! { +
          +
          +
          + + + + +