Skip to content

Commit dd29a75

Browse files
committed
Fix docs navigation and branding issues
1 parent 47dc348 commit dd29a75

3 files changed

Lines changed: 129 additions & 40 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineConfig } from "vitepress";
33
import { withMermaid } from "vitepress-plugin-mermaid";
44

55
const docsBase = "/learn-harness-engineering/";
6+
const starLogo = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23F5C542" stroke="%23D49B00" stroke-width="1.2" d="M12 2.8l2.68 5.43 5.99.87-4.34 4.23 1.02 5.97L12 16.64 6.65 19.3l1.02-5.97-4.34-4.23 5.99-.87L12 2.8Z"/></svg>';
67

78
const zhLectureItems = [
89
{ text: "欢迎", link: "/zh/" },
@@ -84,10 +85,10 @@ export default withMermaid(
8485
srcExclude: ["temp/**"],
8586
ignoreDeadLinks: true,
8687
head: [
87-
['link', { rel: 'icon', type: 'image/svg+xml', href: 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="4" fill="%23FFFFFF" /><path d="M12 4L13.4 8.6L18 10L13.4 11.4L12 16L10.6 11.4L6 10L10.6 8.6L12 4Z" fill="%23D95C41"/></svg>' }]
88+
['link', { rel: 'icon', type: 'image/svg+xml', href: starLogo }]
8889
],
8990
themeConfig: {
90-
logo: 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="4" fill="%231A1A1A" /><path d="M12 4L13.4 8.6L18 10L13.4 11.4L12 16L10.6 11.4L6 10L10.6 8.6L12 4Z" fill="%23D95C41"/></svg>',
91+
logo: starLogo,
9192
search: {
9293
provider: "local"
9394
},
@@ -113,6 +114,12 @@ export default withMermaid(
113114
root: {
114115
label: "English",
115116
lang: "en",
117+
link: "/en/"
118+
},
119+
en: {
120+
label: "English",
121+
lang: "en",
122+
link: "/en/",
116123
themeConfig: {
117124
nav: [
118125
{ text: "Lectures", link: enLectureItems[1].link, activeMatch: '^/en/(lectures/.*)?$' },
@@ -140,32 +147,27 @@ export default withMermaid(
140147
{ text: "Try Harness ↗", link: "https://github.com/walkinglabs/learn-harness-engineering/blob/main/docs/zh/resources/templates/index.md", target: "_blank", rel: "noopener noreferrer" }
141148
],
142149
sidebar: {
143-
'/zh/projects/': [{ text: "项目", items: zhProjectItems }],
144-
'/zh/resources/': [{ text: "资料库", items: zhResourceItems }],
145-
'/zh/': [{ text: "讲义", items: zhLectureItems }]
146-
},
147-
outline: {
148-
level: [2, 3]
149-
},
150-
docFooter: {
151-
prev: "上一篇",
152-
next: "下一篇"
153-
},
154-
lastUpdated: {
155-
text: "最后更新于"
156-
},
157-
returnToTopLabel: "回到顶部",
158-
sidebarMenuLabel: "菜单",
159-
darkModeSwitchLabel: "主题",
160-
lightModeSwitchTitle: "切换到浅色模式",
161-
darkModeSwitchTitle: "切换到深色模式",
162-
socialLinks: [{ icon: "github", link: "https://github.com/walkinglabs/learn-harness-engineering" }]
150+
'/zh/projects/': [{ text: "项目", items: zhProjectItems }],
151+
'/zh/resources/': [{ text: "资料库", items: zhResourceItems }],
152+
'/zh/': [{ text: "讲义", items: zhLectureItems }]
153+
},
154+
outline: {
155+
level: [2, 3]
156+
},
157+
docFooter: {
158+
prev: "上一篇",
159+
next: "下一篇"
160+
},
161+
lastUpdated: {
162+
text: "最后更新于"
163+
},
164+
returnToTopLabel: "回到顶部",
165+
sidebarMenuLabel: "菜单",
166+
darkModeSwitchLabel: "主题",
167+
lightModeSwitchTitle: "切换到浅色模式",
168+
darkModeSwitchTitle: "切换到深色模式",
169+
socialLinks: [{ icon: "github", link: "https://github.com/walkinglabs/learn-harness-engineering" }]
170+
}
163171
}
164-
},
165-
en: {
166-
label: "English",
167-
lang: "en",
168-
link: "/en/"
169172
}
170-
}
171173
}));

docs/.vitepress/theme/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
import DefaultTheme from 'vitepress/theme'
22
import './style.css'
33

4+
let rootEnglishLabel = 'English'
5+
46
function syncRootLocaleLabel(siteData, href = '') {
57
const locales = siteData.value?.locales
6-
if (!locales?.root || !locales.en || !locales.zh) return
8+
if (!locales?.root || !locales?.zh) return
9+
10+
if (locales.root.label && locales.root.label !== locales.zh.label) {
11+
rootEnglishLabel = locales.root.label
12+
}
13+
14+
if (locales.en?.label) {
15+
rootEnglishLabel = locales.en.label
16+
}
717

818
const base = siteData.value.base || '/'
919
const normalized = href || (typeof window !== 'undefined' ? window.location.pathname : '')
1020
const relative = normalized.startsWith(base)
1121
? normalized.slice(base.length - 1)
1222
: normalized
1323

14-
locales.root.label = relative.startsWith('/en/') ? locales.en.label : locales.zh.label
24+
locales.root.label = relative.startsWith('/zh/') ? locales.zh.label : rootEnglishLabel
1525
}
1626

1727
export default {

docs/.vitepress/theme/style.css

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,79 @@
253253
background-color: rgba(255, 255, 255, 0.08) !important;
254254
}
255255

256+
@media (min-width: 768px) and (max-width: 959px) {
257+
.VPNavBar.has-sidebar .container {
258+
max-width: 100%;
259+
}
260+
261+
.VPNavBar.has-sidebar .title {
262+
position: absolute;
263+
top: 0;
264+
left: 0;
265+
z-index: 2;
266+
padding: 0 32px;
267+
width: var(--vp-sidebar-width);
268+
height: var(--vp-nav-height);
269+
background-color: transparent;
270+
}
271+
272+
.VPNavBar.has-sidebar .content {
273+
position: relative;
274+
z-index: 1;
275+
padding-right: 32px;
276+
padding-left: var(--vp-sidebar-width);
277+
}
278+
279+
.VPNavBar.has-sidebar .divider {
280+
padding-left: var(--vp-sidebar-width);
281+
}
282+
283+
.VPNavBar:not(.home.top) .content-body {
284+
position: relative;
285+
background-color: var(--vp-nav-bg-color);
286+
}
287+
288+
.VPNavBar:not(.has-sidebar):not(.home.top) .content-body {
289+
background-color: transparent;
290+
}
291+
292+
.VPContent {
293+
padding-top: var(--vp-nav-height);
294+
}
295+
296+
.VPContent.has-sidebar {
297+
margin: var(--vp-layout-top-height, 0px) 0 0;
298+
padding-left: var(--vp-sidebar-width);
299+
}
300+
301+
.VPSidebar {
302+
z-index: 25;
303+
padding-top: var(--vp-nav-height);
304+
width: var(--vp-sidebar-width);
305+
max-width: 100%;
306+
opacity: 1;
307+
visibility: visible;
308+
box-shadow: none;
309+
transform: translateX(0);
310+
}
311+
312+
.VPSidebar .curtain {
313+
position: sticky;
314+
top: -64px;
315+
left: 0;
316+
z-index: 1;
317+
margin-top: calc(var(--vp-nav-height) * -1);
318+
margin-right: -32px;
319+
margin-left: -32px;
320+
height: var(--vp-nav-height);
321+
background-color: var(--vp-sidebar-bg-color);
322+
}
323+
324+
.VPLocalNav {
325+
display: none;
326+
}
327+
}
328+
256329
/* ---------- Navigation ---------- */
257330
.VPNav {
258331
background-color: var(--vp-nav-bg-color);
@@ -264,29 +337,31 @@
264337
}
265338

266339
.VPNavBarTitle {
267-
font-family: 'Newsreader', serif;
268-
font-size: 1.25rem;
340+
font-family: 'Newsreader', ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
341+
font-size: 1.45rem;
269342
font-weight: 500;
343+
letter-spacing: -0.01em;
270344
color: var(--vp-c-text-1);
271345
}
272346

273347
.VPNavBarTitle .title {
274348
display: flex;
275349
align-items: center;
276-
gap: 8px;
350+
gap: 10px;
277351
}
278352

279353
/* Nav Logo Fix */
280354
.VPNavBarTitle .logo {
281-
height: 24px;
282-
width: 24px;
283-
margin-right: 6px;
284-
border-radius: 4px;
355+
height: 28px;
356+
width: 28px;
357+
margin-right: 2px;
358+
border-radius: 0;
285359
}
286360

287-
.dark .VPNavBarTitle .logo {
288-
filter: invert(1);
361+
.VPNavBarMenu {
362+
align-items: center;
289363
}
364+
290365
.VPNavBarMenuLink {
291366
position: relative;
292367
color: var(--vp-c-text-2) !important;
@@ -308,11 +383,13 @@
308383
border-radius: 20px !important;
309384
padding: 0 16px !important;
310385
margin: 0 4px 0 12px !important;
311-
height: 32px !important;
386+
height: 36px !important;
387+
line-height: 1 !important;
312388
transition: background-color 0.2s ease;
313389
display: flex !important;
314390
align-items: center;
315391
justify-content: center;
392+
align-self: center;
316393
}
317394

318395
.VPNavBarMenuLink[href*="learn-harness-engineering/blob/main/docs/"]:hover {

0 commit comments

Comments
 (0)