Skip to content

Commit c1921c9

Browse files
committed
update website style && hide symlink file on sidebar
1 parent 903a0ea commit c1921c9

File tree

5 files changed

+149
-34
lines changed

5 files changed

+149
-34
lines changed

.jekyll/sass/custom/custom.scss

+55-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
}
55

66
.site-logo-title {
7-
font-size: 0.6em;
8-
max-width: 60%;
7+
font-size: 18px;
98
line-height: 1.2;
109
}
1110

@@ -37,7 +36,7 @@
3736
.nav-list .nav-list-item {
3837
.nav-list-link:hover,
3938
.nav-list-link.active {
40-
color: #264aff !important;
39+
color: #3d89ff !important;
4140
background-image: linear-gradient(-90deg, #262831 0%, #1e2d4f 80%, rgba(32, 31, 35, 0) 100%);
4241
}
4342
}
@@ -48,7 +47,59 @@
4847

4948
.main-content {
5049
h1,h2,h3,h4,h5,h6 {
51-
margin-top: 1em;
50+
margin-top: 1.5em;
5251
margin-bottom: 0.5em;
5352
}
5453
}
54+
55+
.main-content {
56+
.anchor-heading,
57+
h2 > .anchor-heading,
58+
h3 > .anchor-heading,
59+
h4 > .anchor-heading,
60+
h5 > .anchor-heading,
61+
h6 > .anchor-heading {
62+
svg {
63+
visibility: visible;
64+
}
65+
}
66+
}
67+
68+
h1, .text-alpha {
69+
font-size: 1.7rem !important;
70+
font-weight: 500;
71+
}
72+
73+
h2, .text-beta, #toctitle {
74+
font-size: 1.5rem !important;
75+
font-weight: 500;
76+
}
77+
78+
h3, .text-gamma {
79+
font-size: 1.2rem !important;
80+
font-weight: 500;
81+
}
82+
83+
h4 {
84+
font-size: 1rem !important;
85+
font-weight: 500;
86+
}
87+
88+
.side-bar {
89+
@media (max-width: 900px) {
90+
border-bottom: 2px solid #323232;
91+
}
92+
}
93+
94+
.breadcrumb-nav-list-item {
95+
font-size: 0.8rem !important;
96+
}
97+
98+
.site-nav::-webkit-scrollbar-track {
99+
background-color: #2c2c2c;
100+
}
101+
102+
.site-nav {
103+
scrollbar-width: thin;
104+
scrollbar-color: #888888 #2c2c2c;
105+
}

_doc_builder/lib.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ export async function scanDir(dirName, nodeMap, parentPath, _parent, level = 3)
5353
const stats = await getStat(curPath)
5454

5555
if (stats.isSymbolicLink()) {
56+
children[index] = {
57+
name: dirName,
58+
path: curPath,
59+
title: '',
60+
isDir: false,
61+
isSymbolicLink: true,
62+
intro: undefined,
63+
level,
64+
children: [],
65+
parent: curNode,
66+
};
5667
return;
5768
}
5869

_doc_builder/update-meta.mjs

+82-25
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,99 @@ ${content}`)
3131
console.log(`Writed: ${indexFilepath}`)
3232
}
3333

34-
const debugHandle = _debug('update:meta:handle')
34+
const debugHandle = _debug('update:meta:handle');
35+
36+
const symlinkMap = {};
37+
38+
async function handleSymlinks(nodes) {
39+
await pMap(nodes, async (node) => {
40+
if (node.isDir) {
41+
return handleSymlinks(node.children);
42+
}
43+
if (!node.isSymbolicLink) { return ; }
44+
45+
symlinkMap[node.path] = true;
46+
47+
// https://just-the-docs.com/docs/navigation-structure/
48+
const ymlFrontRaw = [
49+
'---',
50+
'layout: default',
51+
'nav_exclude: true', // symlink document should hide in nav_bar
52+
]
53+
54+
if (node.parent) {
55+
ymlFrontRaw.push(`parent: ${node.parent.title}`);
56+
if (node.parent.parent) {
57+
ymlFrontRaw.push(`grand_parent: ${node.parent.parent.title}`);
58+
}
59+
}
60+
61+
ymlFrontRaw.push('---', '', '');
62+
63+
let fh = await FSP.open(node.path, 'r+'); // why readfile with "w+" return empty?
64+
const buffer = await fh.readFile();
65+
await fh.close()
66+
await FSP.unlink(node.path);
67+
fh = await FSP.open(node.path, 'w+');
68+
69+
try {
70+
const stream = fh.createWriteStream({start: 0});
71+
await new Promise((resolve) => {
72+
stream.write(ymlFrontRaw.join('\n'), 'utf8', resolve);
73+
})
74+
await new Promise((resolve) => {
75+
stream.write(buffer, 'utf8', resolve);
76+
})
77+
} finally {
78+
await fh.close();
79+
}
80+
81+
console.log(`Added YAML front: ${node.path}`)
82+
})
83+
}
3584

3685
async function handle(nodes) {
3786
debugHandle('nodes=%O', nodes)
3887

3988
await pMap(nodes, async (node) => {
4089
if (node.isDir) {
4190
await createIndexFileForJTD(node)
42-
} else {
43-
const fh = await FSP.open(node.path, 'r+'); // why readfile with "w+" return empty?
91+
return handle(node.children);
92+
}
4493

45-
// https://just-the-docs.com/docs/navigation-structure/
46-
const ymlFront = `---
47-
layout: default
48-
${node.parent ? `parent: ${node.parent.title}` : ''}
49-
${node?.parent.parent ? `grand_parent: ${node.parent.parent.title}` : ''}
50-
---
94+
if (symlinkMap[node.path]) { return ; }
5195

52-
`;
96+
// https://just-the-docs.com/docs/navigation-structure/
97+
const ymlFrontRaw = [
98+
'---',
99+
'layout: default',
100+
]
101+
102+
if (node.parent) {
103+
ymlFrontRaw.push(`parent: ${node.parent.title}`);
104+
if (node.parent.parent) {
105+
ymlFrontRaw.push(`grand_parent: ${node.parent.parent.title}`);
106+
}
107+
}
53108

54-
try {
55-
const buffer = await fh.readFile();
56-
const stream = fh.createWriteStream({start: 0});
57-
await new Promise((resolve) => {
58-
stream.write(ymlFront, 'utf8', resolve);
59-
})
60-
await new Promise((resolve) => {
61-
stream.write(buffer, 'utf8', resolve);
62-
})
63-
} finally {
64-
await fh.close();
65-
}
66-
67-
console.log(`Added YAML front: ${node.path}`)
109+
ymlFrontRaw.push('---', '', '');
110+
111+
const fh = await FSP.open(node.path, 'r+'); // why readfile with "w+" return empty?
112+
113+
try {
114+
const buffer = await fh.readFile();
115+
const stream = fh.createWriteStream({start: 0});
116+
await new Promise((resolve) => {
117+
stream.write(ymlFrontRaw.join('\n'), 'utf8', resolve);
118+
})
119+
await new Promise((resolve) => {
120+
stream.write(buffer, 'utf8', resolve);
121+
})
122+
} finally {
123+
await fh.close();
68124
}
69125

70-
return handle(node.children);
126+
console.log(`Added YAML front: ${node.path}`)
71127
})
72128
}
73129

@@ -107,6 +163,7 @@ run(async () => {
107163
debug('nodeMap=%O', nodeMap);
108164
debug('rootNodes=%O', rootNodes);
109165

166+
await handleSymlinks(rootNodes);
110167
await handle(rootNodes);
111168
await updateREADME();
112169

_doc_builder/update-readme.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function handle(nodes, levelStd, structure) {
2525
if (node.isDir) {
2626
dirNodes.push(node);
2727
} else {
28+
if (node.isSymbolicLink) { return; }
2829
fileNodes.push(node);
2930
}
3031
});
@@ -49,7 +50,6 @@ run(async () => {
4950
);
5051

5152
const structure = [
52-
{md: absPath('_docs/meta.md')},
5353
{h1: '今天我学了什么 (Today I Learned)'},
5454
{blockquote: PKG.description},
5555
{md: absPath('_docs/intro.md')},

_docs/meta.md

-4
This file was deleted.

0 commit comments

Comments
 (0)