Start working on transferring to VuePress

This commit is contained in:
Oleg Kalachev
2022-04-09 07:32:58 +04:00
parent 84bbe2e565
commit 241b766bad
8 changed files with 136 additions and 2 deletions

2
.gitignore vendored
View File

@@ -7,3 +7,5 @@ package-lock.json
clover_blocks/programs/*.*
!clover_blocks/programs/examples/*
/.vscode/
docs/.vuepress/.cache/
docs/.vuepress/.temp/

56
docs/.vuepress/config.js Normal file
View File

@@ -0,0 +1,56 @@
const glob = require('glob');
const sidebar = require('./sidebar');
console.log(__dirname + '/..');
let markdownFiles = glob.sync('ru/*.md', { cwd: __dirname + '/..' }).map(f => '/' + f);
module.exports = {
// site config
lang: 'en-US',
title: 'Clover',
description: 'Clover Drone Kit',
// theme and its config
theme: '@vuepress/theme-default',
themeConfig: {
logo: 'https://vuejs.org/images/logo.png',
// sidebar: markdownFiles
sidebar: {
'/ru/': sidebar.readSummary("./ru/SUMMARY.md"),
'/en/': sidebar.readSummary("./en/SUMMARY.md"),
},
sidebarDepth: 0,
locales: {
'/en/': { selectLanguageName: 'English' },
'/ru/': { selectLanguageName: 'Русский' },
}
},
locales: {
// The key is the path for the locale to be nested under.
// As a special case, the default locale can use '/' as its path.
// '/en': {
// lang: 'en-US',
// title: 'Clover',
// description: 'Clover Drone Kit'
// },
'/en/': {
lang: 'en',
title: 'Clover',
description: 'Clover Drone Kit'
},
'/ru/': {
lang: 'ru',
title: 'Клевер',
description: 'Конструктор квадрокоптера «Клевер»'
}
},
markdown: {
code: {
lineNumbers: false
}
},
plugins: [
'@vuepress/plugin-search',
'vuepress-plugin-copy-code2'
// ['@vuepress/plugin-search', {}]
]
}

47
docs/.vuepress/sidebar.js Normal file
View File

@@ -0,0 +1,47 @@
const fs = require('fs')
const regex = /(\s*?)\*\s\[(.*?)\]\((.*?)\)/;
exports.readSummary = function (path) {
let sidebar = [];
let lines = fs.readFileSync(path).toString().split('\n');
let item = {};
for (let line of lines) {
if (line.startsWith('#')) continue;
if (!line.trim()) continue;
let match = regex.exec(line);
if (!match) {
console.log('cannot parse', line);
continue;
}
level = match[1].length / 2;
text = match[2];
path = match[3].trim();
if (level == 0) {
if (item.path) {
// push new item
if (item.children) {
sidebar.push(item);
} else {
sidebar.push(item.path)
}
item = {};
}
item.text = text;
item.path = path;
item.collapsible = true;
} else if (level == 1) {
if (!item.children) item.children = [];
item.children.push(path);
} else {
console.log('skip', text);
}
}
return sidebar;
}

View File

@@ -0,0 +1,11 @@
.big-clover {
max-width: 80% !important;
display: block;
margin-left: auto;
margin-right: auto;
}
/* change image for dark theme */
html .big-clover.dark { display: none; }
html.dark .big-clover { display: none; }
html.dark .big-clover.dark { display: block; }

4
docs/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Languages
* [English](en/)
* [Русский](ru/)

View File

@@ -1,6 +1,7 @@
# COEX Clover
<img class="center zoom big-clover" src="../assets/clover42-main.png" width="80%" alt="Clover 4.2">
<img class="big-clover light" src="../assets/clover42-main.png" alt="Clover 4.2">
<img class="big-clover dark" src="../assets/clover42-black.png" alt="Clover 4.2">
**Clover** is an educational kit of a programmable quadcopter that consists of popular open source components, and a set of necessary documentation and libraries for working with it.

13
docs/package.json Normal file
View File

@@ -0,0 +1,13 @@
{
"devDependencies": {
"@vuepress/plugin-search": "^2.0.0-beta.38",
"glob": "^7.2.0",
"vuepress": "^2.0.0-beta.38",
"vuepress-plugin-copy-code2": "^2.0.0-beta.36"
},
"scripts": {
"dev": "vuepress dev .",
"build": "vuepress build .",
"clear": "vuepress clear ."
}
}

View File

@@ -1,6 +1,6 @@
# Клевер
<img class="center zoom big-clover" src="../assets/clover42-main.png" width="80%" alt="Клевер 4.2">
<img class="center zoom big-clover" src="../assets/clover42-main.png" _width="80%" alt="Клевер 4.2">
**«Клевер»** — это учебный конструктор программируемого квадрокоптера, состоящего из популярных открытых компонентов, а также набор необходимой документации и библиотек для работы с ним.