Skip to content

Commit 7647d55

Browse files
authored
Merge pull request #239 from filecoin-project/feat/154
feat: documentation navigation refactor
2 parents 5399a4a + a4cbcad commit 7647d55

File tree

9 files changed

+382
-228
lines changed

9 files changed

+382
-228
lines changed

docs/.vuepress/config.js

Lines changed: 178 additions & 196 deletions
Large diffs are not rendered by default.

docs/.vuepress/nav/en.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
module.exports = []
1+
module.exports = [
2+
{ text: 'Get Started', link: '/' },
3+
{ text: 'Mine', link: '/mine/' },
4+
{ text: 'Build', link: '/build/' },
5+
{ text: 'Reference', link: '/reference/' }
6+
]
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<template>
2+
<nav v-if="bread.length > 1" class="breadcrumbs fixed">
3+
<div class="nav-wrapper">
4+
<router-link
5+
class="breadcrumb"
6+
v-for="crumb in bread"
7+
:key="crumb.path"
8+
:to="crumb.path"
9+
>{{ crumb.title }}</router-link
10+
>
11+
</div>
12+
</nav>
13+
</template>
14+
15+
<script>
16+
export default {
17+
name: 'Breadcrumbs',
18+
computed: {
19+
bread() {
20+
const parts = this.$page.path.split('/')
21+
if (!parts[parts.length - 1].length) {
22+
parts.pop()
23+
}
24+
let link = ''
25+
const crumbs = []
26+
for (let i = 0; i < parts.length; i++) {
27+
link += parts[i]
28+
const page = this.$site.pages.find(
29+
el => el.path === link || el.path === link + '/'
30+
)
31+
link += '/'
32+
if (page != null) {
33+
crumbs.push({
34+
path: page.path,
35+
title: page.frontmatter.breadcrumb || page.title
36+
})
37+
}
38+
}
39+
return crumbs
40+
}
41+
}
42+
}
43+
</script>
44+
45+
<style lang="stylus" scoped>
46+
nav
47+
border-bottom 1px solid #eaecef
48+
font-size 0.9em
49+
padding: 1.5rem 2rem
50+
51+
@media (min-width: $MQNarrow)
52+
margin: 0 2.5rem
53+
padding: 1.5rem 0
54+
55+
&.fixed
56+
position fixed
57+
z-index 5
58+
background-color #fff
59+
width 100%
60+
max-width 740px
61+
display flex
62+
.breadcrumb
63+
margin-right: 0.5em
64+
color: $sidebarTextColor;
65+
opacity: 0.7;
66+
font-weight 600
67+
transition: opacity 0.5s;
68+
&:not(:first-child)::before
69+
margin-right: 0.5em
70+
content "/"
71+
font-family inherit
72+
font-size inherit
73+
74+
&:last-child
75+
&:hover
76+
opacity 1
77+
color: $accentColor
78+
</style>

docs/.vuepress/theme/components/Page.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<main class="page">
33
<slot name="top" />
4-
4+
<Breadcrumbs />
55
<Content v-if="!isHome" class="theme-default-content" />
66
<Home v-else-if="isHome" />
77
<div class="content-footer" v-if="!isContentStatus && !isHome">
@@ -26,6 +26,7 @@
2626
import PageEdit from '@parent-theme/components/PageEdit.vue'
2727
import PageNav from '@parent-theme/components/PageNav.vue'
2828
29+
import Breadcrumbs from './Breadcrumbs.vue'
2930
import Feedback from './Feedback.vue'
3031
import LegacyCallout from './LegacyCallout.vue'
3132
import Analytics from './Analytics.vue'
@@ -37,6 +38,7 @@ export default {
3738
components: {
3839
PageEdit,
3940
PageNav,
41+
Breadcrumbs,
4042
Feedback,
4143
LegacyCallout,
4244
Analytics,
@@ -54,18 +56,32 @@ export default {
5456
},
5557
methods: {
5658
smoothScroll: function () {
57-
var root = document.getElementsByTagName('html')[0]
59+
const root = document.getElementsByTagName('html')[0]
5860
// only enable smooth-scrolling on pages shorter that 15000 px
5961
return root.scrollHeight < 15000
6062
? root.classList.add('smooth-scroll')
6163
: root.classList.remove('smooth-scroll')
64+
},
65+
htmlRouteClass: function () {
66+
// patch to apply a root class for styling elements
67+
// any path that isn't a primary nav item will add the route-index class
68+
const root = document.getElementsByTagName('html')[0]
69+
const path = this.$page.path
70+
const navItems = this.$themeConfig.locales['/'].nav
71+
.slice(1)
72+
.map(a => a.link)
73+
navItems.some(i => path.includes(i))
74+
? root.classList.remove('route-index')
75+
: root.classList.add('route-index')
6276
}
6377
},
6478
mounted: function () {
6579
this.smoothScroll()
80+
this.htmlRouteClass()
6681
},
6782
updated: function () {
6883
this.smoothScroll()
84+
this.htmlRouteClass()
6985
}
7086
}
7187
</script>
@@ -76,6 +92,10 @@ export default {
7692
display: block;
7793
}
7894
95+
.breadcrumbs.fixed + .theme-default-content {
96+
padding-top: 6em;
97+
}
98+
7999
.content-footer {
80100
padding-top: 0;
81101
max-width: $contentWidth;

docs/.vuepress/theme/styles/header.styl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
@media (min-width: $MQNarrow) {
2-
header.navbar .links {
2+
header.navbar {
33
display: flex;
4-
flex-direction: row-reverse;
54

6-
input, .suggestions {
7-
width: 10em;
5+
.home-link {
6+
padding-right: 4rem;
87
}
98

10-
input:focus, .suggestions {
11-
width: 20em;
9+
.links {
10+
position: static;
11+
flex: 1 1 auto;
12+
justify-content: space-between;
13+
flex-direction: row-reverse;
14+
15+
input, .suggestions {
16+
width: 10em;
17+
}
18+
19+
input:focus, .suggestions {
20+
width: 20em;
21+
}
1222
}
1323
}
1424
}

docs/.vuepress/theme/styles/index.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
@import 'sidebar';
66
@import 'video';
77

8-
// stop sidebar taking up horizontal width and adjusting layout position
98
html {
10-
margin-left: calc(100vw - 100%);
9+
-webkit-font-smoothing: antialiased;
10+
-moz-osx-font-smoothing: grayscale;
1111
}
1212

1313
// apply scrolling by default excluding firefox due to trigger issues

docs/.vuepress/theme/styles/sidebar.styl

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,40 @@ ul > li > a.sidebar-link {
33
font-weight: 500;
44
}
55

6-
ul.sidebar-links > li > a {
7-
color: inherit;
6+
header.navbar .nav-links {
7+
display: none;
88
}
99

10-
.sidebar {
11-
.sidebar-heading {
12-
font-weight: 700 !important;
13-
}
10+
#app .sidebar {
11+
.nav-links {
12+
display: block !important;
1413

15-
.sidebar-group .arrow {
16-
display: none;
14+
.nav-item {
15+
margin-left: 0;
16+
font-size: 1em;
17+
}
1718
}
1819

19-
.sidebar-group.is-sub-group a.sidebar-link {
20-
margin-bottom: 0.2rem;
20+
.sidebar-group-items {
21+
font-size: 1em !important;
22+
23+
> li .sidebar-link {
24+
font-size: 0.95em !important;
25+
}
2126
}
2227

23-
.sidebar-group.is-sub-group {
24-
margin-bottom: 0.5rem;
28+
> .sidebar-links > li > a.sidebar-link, .sidebar-heading {
29+
font-weight: bold !important;
30+
font-size: 1em;
2531
}
2632

27-
.sidebar-links.sidebar-group-items li:last-child .sidebar-group.is-sub-group {
28-
margin-bottom: 0;
33+
.sidebar-group.is-sub-group a.sidebar-link {
34+
margin-bottom: 0.2rem;
2935
}
3036

3137
.sidebar-group.is-sub-group > .sidebar-heading:not(.clickable) {
32-
opacity: 1;
33-
font-weight: bold;
3438
text-transform: uppercase;
3539
font-size: 0.8rem;
36-
letter-spacing: 0.05em;
3740
line-height: 2em;
3841
}
3942
}
@@ -43,23 +46,77 @@ ul.sidebar-links > li > a {
4346
}
4447

4548
// sidebar scrollbar style
46-
.sidebar::-webkit-scrollbar {
49+
.sidebar-links::-webkit-scrollbar {
4750
width: 5px;
4851
position: fixed;
4952
right: 0;
5053
}
5154

52-
.sidebar::-webkit-scrollbar-thumb {
55+
.sidebar-links::-webkit-scrollbar-thumb {
5356
background: transparent;
5457
transition: background-color 2s;
5558
}
5659

57-
.sidebar::-webkit-scrollbar-thumb:hover, .sidebar:hover::-webkit-scrollbar-thumb {
60+
.sidebar-links::-webkit-scrollbar-thumb:hover, .sidebar-links:hover::-webkit-scrollbar-thumb {
5861
background: $borderColor;
5962
}
6063

6164
@media (max-width: $MQMobile) {
6265
.sidebar {
6366
width: 80vw;
6467
}
68+
}
69+
70+
// style selected sidebar item based on route class
71+
html.route-index {
72+
.sidebar .nav-links .nav-item:first-child {
73+
a.nav-link {
74+
color: $accentColor;
75+
}
76+
}
77+
}
78+
79+
@media (min-width: $MQMobile) {
80+
aside.sidebar {
81+
display: flex;
82+
flex-direction: column;
83+
height: 100vh;
84+
overflow: hidden;
85+
86+
> .sidebar-links {
87+
padding: 1rem 0;
88+
89+
a {
90+
&.active {
91+
opacity: 1;
92+
93+
a {
94+
opacity: 1;
95+
}
96+
}
97+
98+
opacity: 0.7;
99+
transition: opacity 0.5s;
100+
}
101+
102+
&:hover a {
103+
opacity: 1;
104+
}
105+
106+
overflow: auto;
107+
padding-bottom: 6em;
108+
}
109+
110+
.nav-links, .nav-links a {
111+
display: block;
112+
}
113+
114+
.nav-item > a:not(.external) {
115+
&:hover, &.router-link-active {
116+
margin-bottom: 0px;
117+
border-bottom: none;
118+
color: $accentColor;
119+
}
120+
}
121+
}
65122
}

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Filecoin Documentation
33
description: The homepage for Filecoin documentation.
44
homepage: true
5+
breadcrumb: Home
56
---
67

78
# Filecoin Documentation

docs/mine/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Mining in Filecoin
33
description: An overview of everything mining-related on the Filecoin network.
4+
breadcrumb: Mine
45
---
56

67
# Mining in Filecoin
@@ -67,11 +68,11 @@ In Filecoin, miners earn two different types of rewards for their efforts: stora
6768
**Block rewards** are large sums that are given to the miner credited for a new block. Unlike storage fees, these rewards do not come from an associated client; rather, the network "prints" new FIL as both an inflationary measure and an incentive to miners advancing the chain. All active miners on the network have a chance at recieving a block reward, their chance at such being directly proportional to the amount of storage space currently being contributed to the network.
6869

6970
### WinningPoSt
71+
7072
WinningPoSt is the mechanism by which storage miners are rewarded for their contributions. In the Filecoin network, time is discretized into a series of epochs – the blockchain’s height corresponds to the number of elapsed epochs. At the beginning of each epoch, a small number of storage miners are elected to mine new blocks (Filecoin utilizes tipsets, which permit multiple blocks to be mined at the same height). Each elected miner who successfully creates a block is granted FIL, as well as the opportunity to charge other nodes fees to include messages in the block.
7173

7274
To further incentivize the storage of “useful” data over simple capacity commitments, storage miners have the additional opportunity to compete for special deals offered by verified clients. Such clients are certified with respect to their intent to offer deals involving the storage of meaningful data, and the power a storage miner earns for these deals is augmented by a multiplier. The total amount of power a given storage miner has, after accounting for this multiplier, is known as **quality-adjusted power**.
7375

74-
7576
## Uptime, slashing and penalties
7677

7778
"Slashing" is a feature present in most blockchain protocols, and is used to penalise miners that either fail to provide reliable uptime or act maliciously against the network.

0 commit comments

Comments
 (0)