Add docusaurus and crowdin integration (#1391)

This commit is contained in:
Justin Starry 2020-07-09 20:49:07 +08:00 committed by GitHub
parent 0717d90aa0
commit deb6a2b1c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 776 additions and 6 deletions

53
crowdin.yaml Normal file
View File

@ -0,0 +1,53 @@
project_identifier_env: CROWDIN_DOCUSAURUS_PROJECT_ID
api_key_env: CROWDIN_DOCUSAURUS_API_KEY
base_path: "./"
preserve_hierarchy: true
files:
-
source: '/docs/*.md'
translation: '/website/translated_docs/%locale%/%original_file_name%'
languages_mapping: &anchor
locale:
'af': 'af'
'ar': 'ar'
'bs-BA': 'bs-BA'
'ca': 'ca'
'cs': 'cs'
'da': 'da'
'de': 'de'
'el': 'el'
'es-ES': 'es-ES'
'fa': 'fa-IR'
'fi': 'fi'
'fr': 'fr'
'he': 'he'
'hu': 'hu'
'id': 'id-ID'
'it': 'it'
'ja': 'ja'
'ko': 'ko'
'mr': 'mr-IN'
'nl': 'nl'
'no': 'no-NO'
'pl': 'pl'
'pt-BR': 'pt-BR'
'pt-PT': 'pt-PT'
'ro': 'ro'
'ru': 'ru'
'sk': 'sk-SK'
'sr': 'sr'
'sv-SE': 'sv-SE'
'tr': 'tr'
'uk': 'uk'
'vi': 'vi'
'zh-CN': 'zh-CN'
'zh-TW': 'zh-TW'
-
source: '/website/i18n/en.json'
translation: '/website/i18n/%locale%.json'
languages_mapping: *anchor
-
source: '/website/versioned_docs/**/*.md'
translation: '/website/translated_docs/%locale%/**/%original_file_name%'
languages_mapping: *anchor

View File

@ -1,4 +1,7 @@
# Introduction ---
id: intro
title: Introduction
---
## What is Yew? ## What is Yew?
@ -11,22 +14,20 @@
### Join Us 😊 ### Join Us 😊
* You can report bugs and discuss features on the [GitHub issues page](https://github.com/yewstack/yew/issues) * You can report bugs and discuss features on the [GitHub issues page](https://github.com/yewstack/yew/issues)
* We ❤️pull requests. Check out [good first issues](https://github.com/yewstack/yew/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) if you'd like to help out! * We love pull requests. Check out [good first issues](https://github.com/yewstack/yew/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) if you'd like to help out!
* Our [Discord chat](https://discord.gg/VQck8X4) is very active and is a great place to ask questions * Our [Discord chat](https://discord.gg/VQck8X4) is very active and is a great place to ask questions
![Our community is thriving!](https://img.shields.io/github/stars/yewstack/yew?color=009A5B&label=Github%20stars)
### Ready to dive in? ### Ready to dive in?
Click the link below to learn how to build your first Yew app and learn from community example projects Click the link below to learn how to build your first Yew app and learn from community example projects
{% page-ref page="getting-started/project-setup/" %} {% page-ref page="getting-started/project-setup/" %}
### **Still not convinced?** ### Still not convinced?
This project is built on cutting edge technology and is great for developers who like to develop the foundational projects of tomorrow. Here are some reasons why we believe that frameworks like Yew are the future of web development. This project is built on cutting edge technology and is great for developers who like to develop the foundational projects of tomorrow. Here are some reasons why we believe that frameworks like Yew are the future of web development.
#### **Wait, why WebAssembly?** #### Wait, why WebAssembly?
WebAssembly _\(Wasm\)_ is a portable low-level language that Rust can compile into. It runs at native speeds in the browser and is interoperable with JavaScript and supported in all major browsers. For ideas on how to get the most out of WebAssembly for your app, check out this list of [Use Cases](https://webassembly.org/docs/use-cases/). WebAssembly _\(Wasm\)_ is a portable low-level language that Rust can compile into. It runs at native speeds in the browser and is interoperable with JavaScript and supported in all major browsers. For ideas on how to get the most out of WebAssembly for your app, check out this list of [Use Cases](https://webassembly.org/docs/use-cases/).

3
website/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build
node_modules
package-lock.json

143
website/README.md Normal file
View File

@ -0,0 +1,143 @@
This website was created with [Docusaurus](https://docusaurus.io/).
# What's In This Document
- [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)
# Get Started in 5 Minutes
1. Make sure all the dependencies for the website are installed:
```sh
# Install dependencies
$ npm install
```
2. Run your dev server:
```sh
# Start the site
$ npm start
```
## Directory Structure
Your project file structure should look something like this
```
yew/
docs/
website/
core/
node_modules/
static/
css/
img/
package.json
sidebars.json
siteConfig.js
```
# Editing Content
## Editing an existing docs page
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...
```
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/).

92
website/core/Footer.js Normal file
View File

@ -0,0 +1,92 @@
/**
* 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 (
<footer className="nav-footer" id="footer">
<section className="sitemap">
<a href={this.props.config.baseUrl} className="nav-home">
{this.props.config.footerIcon && (
<img
src={this.props.config.baseUrl + this.props.config.footerIcon}
alt={this.props.config.title}
width="66"
height="58"
/>
)}
</a>
<div>
<h5>Support</h5>
<a
href="https://issuehunt.io/r/yewstack/yew"
target="_blank"
rel="noreferrer noopener">
Fund Issues
</a>
<a
href="https://opencollective.com/yew"
target="_blank"
rel="noreferrer noopener">
Sponsor Project
</a>
</div>
<div>
<h5>Participate</h5>
<a
href={this.props.config.repoUrl}
target="_blank"
rel="noreferrer noopener">
Github
</a>
<a
href="https://discord.gg/VQck8X4"
target="_blank"
rel="noreferrer noopener">
Discord
</a>
<a
href="https://twitter.com/"
target="_blank"
rel="noreferrer noopener">
Twitter
</a>
</div>
<div>
<h5>More</h5>
<a
href="https://github.com/jetli/awesome-yew"
target="_blank"
rel="noreferrer noopener">
Yew Awesome
</a>
</div>
</section>
</footer>
);
}
}
module.exports = Footer;

113
website/i18n/en.json Normal file
View File

@ -0,0 +1,113 @@
{
"_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": "advanced-topics/how-it-works"
},
"advanced-topics/optimizations": {
"title": "advanced-topics/optimizations"
},
"concepts/agents": {
"title": "concepts/agents"
},
"concepts/components/callbacks": {
"title": "concepts/components/callbacks"
},
"concepts/components/properties": {
"title": "concepts/components/properties"
},
"concepts/components/README": {
"title": "concepts/components/README"
},
"concepts/components/refs": {
"title": "concepts/components/refs"
},
"concepts/html/components": {
"title": "concepts/html/components"
},
"concepts/html/elements": {
"title": "concepts/html/elements"
},
"concepts/html/lists": {
"title": "concepts/html/lists"
},
"concepts/html/literals-and-expressions": {
"title": "concepts/html/literals-and-expressions"
},
"concepts/html/README": {
"title": "concepts/html/README"
},
"concepts/router": {
"title": "concepts/router"
},
"concepts/services/format": {
"title": "concepts/services/format"
},
"concepts/services/README": {
"title": "concepts/services/README"
},
"getting-started/build-a-sample-app": {
"title": "getting-started/build-a-sample-app"
},
"getting-started/choose-web-library": {
"title": "getting-started/choose-web-library"
},
"getting-started/examples": {
"title": "getting-started/examples"
},
"getting-started/project-setup/README": {
"title": "getting-started/project-setup/README"
},
"getting-started/project-setup/using-cargo-web": {
"title": "getting-started/project-setup/using-cargo-web"
},
"getting-started/project-setup/using-wasm-bindgen": {
"title": "getting-started/project-setup/using-wasm-bindgen"
},
"getting-started/project-setup/using-wasm-pack": {
"title": "getting-started/project-setup/using-wasm-pack"
},
"getting-started/starter-templates": {
"title": "getting-started/starter-templates"
},
"intro": {
"title": "Introduction"
},
"more/css": {
"title": "more/css"
},
"more/debugging": {
"title": "more/debugging"
},
"more/external-libs": {
"title": "more/external-libs"
},
"more/roadmap": {
"title": "more/roadmap"
},
"more/testing": {
"title": "more/testing"
},
"summary": {
"title": "Summary"
}
},
"links": {
"Changelog": "Changelog",
"API": "API",
"Discord": "Discord"
},
"categories": {
"Getting Started": "Getting Started"
}
},
"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"
}
}

181
website/languages.js Normal file
View File

@ -0,0 +1,181 @@
/**
* 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 languages = [
{
enabled: true,
name: 'English',
tag: 'en',
},
{
enabled: false,
name: '日本語',
tag: 'ja',
},
{
enabled: false,
name: 'العربية',
tag: 'ar',
},
{
enabled: false,
name: 'Bosanski',
tag: 'bs-BA',
},
{
enabled: false,
name: 'Català',
tag: 'ca',
},
{
enabled: false,
name: 'Čeština',
tag: 'cs',
},
{
enabled: false,
name: 'Dansk',
tag: 'da',
},
{
enabled: false,
name: 'Deutsch',
tag: 'de',
},
{
enabled: false,
name: 'Ελληνικά',
tag: 'el',
},
{
enabled: false,
name: 'Español',
tag: 'es-ES',
},
{
enabled: false,
name: 'فارسی',
tag: 'fa-IR',
},
{
enabled: false,
name: 'Suomi',
tag: 'fi',
},
{
enabled: false,
name: 'Français',
tag: 'fr',
},
{
enabled: false,
name: 'עִברִית',
tag: 'he',
},
{
enabled: false,
name: 'Magyar',
tag: 'hu',
},
{
enabled: false,
name: 'Bahasa Indonesia',
tag: 'id-ID',
},
{
enabled: false,
name: 'Italiano',
tag: 'it',
},
{
enabled: false,
name: 'Afrikaans',
tag: 'af',
},
{
enabled: false,
name: '한국어',
tag: 'ko',
},
{
enabled: false,
name: 'मराठी',
tag: 'mr-IN',
},
{
enabled: false,
name: 'Nederlands',
tag: 'nl',
},
{
enabled: false,
name: 'Norsk',
tag: 'no-NO',
},
{
enabled: false,
name: 'Polskie',
tag: 'pl',
},
{
enabled: false,
name: 'Português',
tag: 'pt-PT',
},
{
enabled: false,
name: 'Português (Brasil)',
tag: 'pt-BR',
},
{
enabled: false,
name: 'Română',
tag: 'ro',
},
{
enabled: false,
name: 'Русский',
tag: 'ru',
},
{
enabled: false,
name: 'Slovenský',
tag: 'sk-SK',
},
{
enabled: false,
name: 'Српски језик (Ћирилица)',
tag: 'sr',
},
{
enabled: false,
name: 'Svenska',
tag: 'sv-SE',
},
{
enabled: false,
name: 'Türkçe',
tag: 'tr',
},
{
enabled: false,
name: 'Українська',
tag: 'uk',
},
{
enabled: false,
name: 'Tiếng Việt',
tag: 'vi',
},
{
enabled: true,
name: '中文',
tag: 'zh-CN',
},
{enabled: true, name: '繁體中文', tag: 'zh-TW'},
];
module.exports = languages;

14
website/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"scripts": {
"examples": "docusaurus-examples",
"start": "docusaurus-start",
"build": "docusaurus-build",
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "docusaurus-version",
"rename-version": "docusaurus-rename-version"
},
"devDependencies": {
"docusaurus": "^1.14.4"
}
}

5
website/sidebars.json Normal file
View File

@ -0,0 +1,5 @@
{
"docs": {
"Getting Started": ["intro"]
}
}

98
website/siteConfig.js Normal file
View File

@ -0,0 +1,98 @@
/**
* 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.
*/
// See https://docusaurus.io/docs/site-config for all the possible
// site configuration options.
const siteConfig = {
title: 'Yew Docs', // Title for your website.
tagline: 'Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.',
url: 'https://yew.rs', // Your website URL
baseUrl: '/', // Base URL for your project */
// For github.io type URLs, you would set the url and baseUrl like:
// url: 'https://facebook.github.io',
// baseUrl: '/test-site/',
// Used for publishing and more
projectName: 'docs',
organizationName: 'yewstack',
// For top-level user or org sites, the organization is still the same.
// e.g., for the https://JoelMarcey.github.io site, it would be set like...
// organizationName: 'JoelMarcey'
// For no header links in the top nav bar -> headerLinks: [],
headerLinks: [
{href: 'https://github.com/yewstack/yew/releases', label: 'Changelog'},
{href: 'https://docs.rs/yew', label: 'API'},
{href: 'https://discord.gg/VQck8X4', label: 'Discord'},
{search: true},
{languages: true},
],
/* path to images for header/footer */
headerIcon: 'img/logo.png',
// footerIcon: 'img/logo.png',
favicon: 'img/logo.png',
/* Colors for website */
colors: {
primaryColor: '#008F53',
secondaryColor: '#A4DDC8',
},
/* Custom fonts for website */
/*
fonts: {
myFont: [
"Times New Roman",
"Serif"
],
myOtherFont: [
"-apple-system",
"system-ui"
]
},
*/
highlight: {
// Highlight.js theme to use for syntax highlighting in code blocks.
theme: 'default',
},
// Add custom scripts here that would be placed in <script> tags.
// scripts: ['https://buttons.github.io/buttons.js'],
stylesheets: [
'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700',
],
// On page navigation for the current documentation page.
onPageNav: 'separate',
// No .html extensions for paths.
cleanUrl: true,
// Open Graph and Twitter card images.
ogImage: 'img/Rollup.jpg',
twitterImage: 'img/Rollup.jpg',
twitterUsername: 'yewstack',
// For sites with a sizable amount of content, set collapsible to true.
// Expand/collapse the links and subcategories under categories.
// docsSideNavCollapsible: true,
// Show documentation's last contributor's name.
// enableUpdateBy: true,
// Show documentation's last update time.
enableUpdateTime: true,
// You may provide arbitrary config keys to be used as needed by your
// template. For example, if you need your repo's URL...
repoUrl: 'https://github.com/yewstack/yew',
};
module.exports = siteConfig;

View File

@ -0,0 +1,31 @@
/**
* 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.
*/
/* your custom css */
h1, h2, h3, h4, h5, h6 {
font-weight: 500;
}
body {
font-family: 'Roboto', sans-serif;
}
@media only screen and (min-device-width: 360px) and (max-device-width: 736px) {
}
@media only screen and (min-width: 1024px) {
}
@media only screen and (max-width: 1023px) {
}
@media only screen and (min-width: 1400px) {
}
@media only screen and (min-width: 1500px) {
}

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta
http-equiv="refresh"
content="0; url=/docs/intro"
/>
<script type="text/javascript">
window.location.href = '/docs/intro';
</script>
<title>Yew Docs</title>
</head>
<body>
If you are not redirected automatically, follow this
<a href="/docs/intro">link</a>.
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
website/static/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

18
website/static/index.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta
http-equiv="refresh"
content="0; url=docs"
/>
<script type="text/javascript">
window.location.href = 'docs';
</script>
<title>Yew Docs</title>
</head>
<body>
If you are not redirected automatically, follow this
<a href="docs">link</a>.
</body>
</html>