Skip to content

Commit

Permalink
feat: update sidebar
Browse files Browse the repository at this point in the history
* 玲珑文档新增,修改 sidebar
* 修改获取版本号的方式,以及默认版本号
* 删除获取1.4.3的工作流

Log: update sidebar
  • Loading branch information
chenchongbiao authored and black-desk committed May 15, 2024
1 parent b1a3712 commit 57d99ab
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 31 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['1.4.3'] # 定义版本数组
version: ['1.5.0'] # 定义版本数组
steps:
- uses: actions/checkout@v3
- name: Checkout linglong ${{ matrix.version }}
Expand All @@ -29,24 +29,20 @@ jobs:
sparse-checkout: |
docs/pages
sparse-checkout-cone-mode: false
- name: checkout 1.4.3 docs
- name: Checkout linglong release
uses: actions/checkout@v4
with:
ref: 2ba2407e1148b3a084f71269660272a9348360ab # homepage 项目的 v1.4.3
path: '1.4.3'
repository: linuxdeepin/linglong-homepage
sparse-checkout: |
en
guide
sparse-checkout-cone-mode: false
- name: Generate Versions JS File
ref: 450ed3185b889de0be5695649a580d50357bc07f # 指定玲珑项目的 commit 提交,可能文档有小部分修改,不需要从 tag 获取
path: tmp
repository: linuxdeepin/linglong
sparse-checkout: |
docs/pages
sparse-checkout-cone-mode: false
- name: set release version
run: |
verPath=".vitepress/theme/versions.js"
echo "const versions = [''];" > $verPath
for ver in "${{ matrix.version }}"; do
echo "versions.push('$ver');" >> $verPath
done
echo "exports.versions = versions;" >> $verPath
rm -rf en guide
mv tmp/docs/pages/guide .
mv tmp/docs/pages/en .
- uses: actions/setup-node@v3
with:
node-version: 16
Expand Down
45 changes: 44 additions & 1 deletion .vitepress/theme/components/NewLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ SPDX-License-Identifier: LGPL-3.0-or-later
-->

<template>
<Layout v-if="lay.isDefault" />
<Layout v-if="lay.isDefault">
<template #doc-before>
<div class="tip custom-block">
<p class="custom-block-title">TIP</p>
<p>{{tips}}</p>
</div>
<br/>
</template>
</Layout>
<Home v-if="lay.isHome" />
<EnHome v-if="lay.isEnHome" />
</template>
<script setup>
import Home from './zh/home/index.vue'
import EnHome from './en/home/index.vue'

import { generateVersions } from '../versions.js';

import { useRoute } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { onMounted, computed } from 'vue'
Expand All @@ -36,6 +46,39 @@ const lay = computed(() => {
return _lay
})

const tips = computed(() => {
const { defaultVersion } = generateVersions()
let pathParts = route.path.split('/')
let versionPart = pathParts.find(part => /^\d+\.\d+\.\d+$/.test(part))
let _tips = ""

if (route.path.includes('/en/')) {
_tips = "This document is applicable to version "

if (versionPart === undefined) {
_tips = _tips + defaultVersion
} else {
_tips = _tips + versionPart
}

_tips = _tips + ", Please use the command ll-cli --version to check your LingLong program version."
} else {
_tips = "此文档适用于 "

if (versionPart === undefined) {
_tips = _tips + defaultVersion
} else {
_tips = _tips + versionPart
}

_tips = _tips + ", 请使用 ll-cli --version 检查您的玲珑程序版本。"
}

return _tips
})

// console.log(tips)

// onMounted(() => {
// if (route.path === '/en/') {
// location.href = '/en/index.html'
Expand Down
11 changes: 6 additions & 5 deletions .vitepress/theme/nav.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const { versions } = require('./versions.js')
const { generateVersions } = require('./versions.js')
const { defaultVersion, versions } = generateVersions()

// 定义每个类别及其子项的映射
const categoryMappings = {
"zh": {
"item": "版本",
"defaultVersion": "主分支",
"item": "文档版本",
"defaultVersion": defaultVersion,
"link": "/start/install.md"
},
"en": {
"item": "Version",
"defaultVersion": "master",
"item": "Doc Version",
"defaultVersion": defaultVersion,
"link": "/start/install.md"
}
}
Expand Down
38 changes: 31 additions & 7 deletions .vitepress/theme/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const fs = require('fs');
const path = require('path');

const { versions } = require('./versions.js')
const { generateVersions } = require('./versions.js')
const { versions } = generateVersions()

const langs = ['zh', 'en']

// 所有版本和语言的指南结构
Expand All @@ -10,9 +12,6 @@ let sidebar = {};
// 定义每个类别及其子项的映射
const categoryMappings = {
"zh": {
"开始": {
"安装": "/start/install.md",
},
"命令行工具": {
"简介": "/ll-cli/introduction.md",
"列出已安装的应用": "/ll-cli/list.md",
Expand All @@ -30,20 +29,31 @@ const categoryMappings = {
"创建项目": "/ll-builder/create.md",
"构建应用": "/ll-builder/build.md",
"运行应用": "/ll-builder/run.md",
"转换 appimage": "/ll-builder/convert.md",
"导出uab格式应用": "/ll-builder/export.md",
"配置文件": "/ll-builder/manifests.md",
"上架应用到商店": "/ll-builder/github.md"
},
"转换工具": {
"ll-pica 简介": "/ll-pica/introduction.md",
"初始化配置": "/ll-pica/init.md",
"转换应用": "/ll-pica/convert.md",
"添加依赖": "/ll-pica/adep.md",
"转换配置文件简介": "/ll-pica/manifests.md",
"常见问题": "/ll-pica/faq.md",
},
"开始": {
"安装玲珑": "/start/install.md",
"安装 Pica": "/start/install_pica.md",
"从0开始构建": "/start/how_to_use.md",
},
"调试应用": {
"IDE中调试应用": "/debug/debug.md",
"常见构建问题": "/debug/ll-builder-faq.md",
"常见运行问题": "/debug/faq.md"
}
},
"en": {
"Getting Started": {
"Install Linglong Environment": "/start/install.md",
},
"Command Line Tools": {
"Introduction": "/ll-cli/introduction.md",
"List Installed Apps": "/ll-cli/list.md",
Expand All @@ -61,10 +71,24 @@ const categoryMappings = {
"Create Project": "/ll-builder/create.md",
"Build App": "/ll-builder/build.md",
"Run Compiled App": "/ll-builder/run.md",
"Convert AppImage": "/ll-builder/convert.md",
"Export Uab Format": "/ll-builder/export.md",
"Manifests": "/ll-builder/manifests.md",
"App To Store": "/ll-builder/github.md"
},
"Conversion application": {
"ll-pica Introduction": "/ll-pica/introduction.md",
"Initialization configuration": "/ll-pica/init.md",
"Conversion application": "/ll-pica/convert.md",
"Add dependency": "/ll-pica/adep.md",
"Manifests": "/ll-pica/manifests.md",
"FAQ": "/ll-pica/faq.md",
},
"Getting Started": {
"Install Linglong Environment": "/start/install.md",
"Install Pica": "/start/install_pica.md",
"Build from scratch": "/start/how_to_use.md",
},
"Debug App": {
"Debug App In IDE": "/debug/debug.md",
"Build FAQ": "/debug/ll-builder-faq.md",
Expand Down
9 changes: 7 additions & 2 deletions .vitepress/theme/versions.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
const versions = [''];
exports.versions = versions;
export function generateVersions() {
const versions = ['']; // 保留空用来判断默认路由
return {
defaultVersion: '1.5.0', // 默认显示版本号
versions: versions
};
}

0 comments on commit 57d99ab

Please sign in to comment.