mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
Update config
This commit is contained in:
parent
d97fbe723f
commit
ac1248f2c6
@ -8,3 +8,4 @@ language = "zh-CN"
|
||||
additional-css = ["ferris.css", "theme/2018-edition.css"]
|
||||
additional-js = ["ferris.js", "language.js"]
|
||||
git-repository-url = "https://github.com/rust-lang-cn/book-cn"
|
||||
edit-url-template = "https://github.com/rust-lang-cn/book-cn/edit/master/{path}"
|
||||
|
47
language.js
47
language.js
@ -16,58 +16,39 @@
|
||||
var link = "";
|
||||
var word = "";
|
||||
var home = "Home";
|
||||
|
||||
var edit_url = "https://github.com/rust-lang-cn"
|
||||
var github_id = document.getElementById("git-repository-button");
|
||||
if (github_id != null && github_id.parentNode.href != undefined) {
|
||||
edit_url = github_id.parentNode.href;
|
||||
var repo_name = edit_url.split('/').pop();
|
||||
var url_repo_name = repo_name.slice(0, -3);
|
||||
|
||||
if (url.indexOf(url_repo_name) > -1) {
|
||||
var html_file = url.split(url_repo_name).pop();
|
||||
} else if (url.indexOf(":3000") > -1) {
|
||||
var html_file = url.split(":3000").pop();
|
||||
} else {
|
||||
var html_file = '/';
|
||||
}
|
||||
|
||||
if (typeof default_homepage_md !== 'undefined') {
|
||||
edit_url += '/blob/master/src/' + default_homepage_md;
|
||||
} else if (html_file == '/') {
|
||||
edit_url += '/tree/master/src';
|
||||
} else {
|
||||
var md_len = html_file.indexOf('.html');
|
||||
if (md_len > -1) {
|
||||
var md_file = html_file.substring(0, md_len) + '.md';
|
||||
edit_url += '/blob/master/src' + md_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var edit_node = '<a href="' + edit_url + '" title="报告错误或改进本页翻译" aria-label="报告错误或改进本页翻译" target="_blank"><i id="go-back-homepage" class="fa fa-pencil-square-o"></i></a>';
|
||||
var lang = "zh-CN";
|
||||
var changeLang = "切换到英语";
|
||||
|
||||
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
|
||||
link = url.replace(search.en, replaceWith.en);
|
||||
word = "简体中文";
|
||||
edit_node = "";
|
||||
lang = "en";
|
||||
changeLang = "Switch to Chinese"
|
||||
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
|
||||
link = url.replace(search.zh_CN, replaceWith.zh_CN);
|
||||
word = "English";
|
||||
home = "首页";
|
||||
}
|
||||
|
||||
var edit_id = document.getElementById("git-edit-button");
|
||||
if (edit_id != null && edit_id.parentNode != null) {
|
||||
edit_id.parentNode.target = "_blank";
|
||||
if (lang != "en") {
|
||||
edit_id.parentNode.title = "报告错误或改进本页翻";
|
||||
}
|
||||
}
|
||||
|
||||
var home_node = '';
|
||||
if (window.location.protocol == 'http:' || window.location.protocol == 'https:') {
|
||||
home_node = '<a href="' + home_url + '" title="' + home + '" aria-label="' + home + '"><i id="go-back-homepage" class="fa fa-home"></i></a>';
|
||||
}
|
||||
var lang_node = '';
|
||||
if (link != '') {
|
||||
lang_node = '<a href="' + link + '"><i id="change-language" class="fa fa-language"> ' + word + '</i></a>';
|
||||
lang_node = '<a href="' + link + '" title="' + changeLang + '" aria-label="' + changeLang + '"><i id="change-language-button" class="fa fa-language"> ' + word + '</i></a>';
|
||||
}
|
||||
var insertNode = document.getElementsByClassName('right-buttons');
|
||||
if (insertNode.length > 0) {
|
||||
var html = insertNode[0].innerHTML;
|
||||
insertNode[0].innerHTML = home_node + html + edit_node + lang_node;
|
||||
insertNode[0].innerHTML = home_node + html + lang_node;
|
||||
}
|
||||
})()
|
||||
|
@ -35,7 +35,3 @@ HTML 格式可从 [https://rustwiki.org/zh-CN/book/](https://rustwiki.org/zh-CN/
|
||||
[install]: ch01-01-installation.html
|
||||
[editions]: appendix-05-editions.html
|
||||
[nsprust]: https://nostarch.com/rust
|
||||
|
||||
<script>
|
||||
var default_homepage_md = "title-page.md";
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user