mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
Add github link to website sidebar
This commit is contained in:
parent
85e6489666
commit
3415e6db31
1
book/.gitignore
vendored
1
book/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/build
|
||||
/mdbook
|
||||
/node_modules
|
||||
|
37
book/build.js
Executable file
37
book/build.js
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const githublink = `\
|
||||
<li class="part-title">\
|
||||
<a href="https://github.com/dtolnay/cxx">\
|
||||
<i class="fa fa-github" style="font-size:20px;padding-right:5px;padding-top:12px;position:relative;top:1px"></i>\
|
||||
https://github.com/dtolnay/cxx\
|
||||
</a>\
|
||||
</li>`;
|
||||
|
||||
const dirs = ['build'];
|
||||
while (dirs.length) {
|
||||
const dir = dirs.pop();
|
||||
fs.readdirSync(dir).forEach((entry) => {
|
||||
path = dir + '/' + entry;
|
||||
const stat = fs.statSync(path);
|
||||
if (stat.isDirectory()) {
|
||||
dirs.push(path);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path.endsWith('.html')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = fs.readFileSync(path, 'utf8');
|
||||
const $ = cheerio.load(index, { decodeEntities: false });
|
||||
|
||||
$('nav#sidebar ol.chapter').append(githublink);
|
||||
|
||||
const out = $.html();
|
||||
fs.writeFileSync(path, out);
|
||||
});
|
||||
}
|
@ -9,3 +9,9 @@ if [ -f ./mdbook ]; then
|
||||
else
|
||||
mdbook build
|
||||
fi
|
||||
|
||||
if [ ! -d node_modules ]; then
|
||||
npm install
|
||||
fi
|
||||
|
||||
./build.js
|
||||
|
11
book/package.json
Normal file
11
book/package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "cxx-book-build",
|
||||
"version": "0.0.0",
|
||||
"main": "build.js",
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.3"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user