Skip to content

Commit 60a24b5

Browse files
authored
Merge pull request #16 from jdestefano-mongo/gen-toc
DOCSP-709 - Generate ToC at renderer level.
2 parents f46c38b + d4a30d0 commit 60a24b5

File tree

10 files changed

+2651
-3185
lines changed

10 files changed

+2651
-3185
lines changed

themes/mongodb-tutorials/src/single.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,56 +45,25 @@ class Single extends React.Component {
4545
constructor (props) {
4646
super(props)
4747
this.state = {
48-
searchResults: null,
49-
sections: this._getSections(),
48+
searchResults: null
5049
}
5150
}
5251

5352
componentDidMount() {
5453
setupCopyButtons()
5554
}
5655

57-
_getSections () {
58-
const sectionElements = document.querySelectorAll('.single h2')
59-
let sections = []
60-
61-
sectionElements.forEach((el) => {
62-
sections.push({
63-
name: el.innerHTML,
64-
link: `#${el.id}`,
65-
})
66-
})
67-
68-
return sections
69-
}
70-
7156
onResults = (results) => {
7257
this.setState({searchResults: results})
7358
}
7459

7560
render () {
76-
const sections = this._getSections().map((section, i) => {
77-
return (
78-
<li key={i} className="menu__item"><a href={section.link} className="menu__link">{section.name}</a></li>
79-
)
80-
})
8161

8262
return (
8363
<div>
8464
<Navbar baseURL={baseURL}>
8565
<Search baseURL={baseURL} onResults={this.onResults} />
8666
</Navbar>
87-
88-
<div className="main">
89-
<aside className="main__sidebar main__sidebar--single">
90-
<div className="main__sidebar__header">
91-
MongoDB Manual Sections:
92-
</div>
93-
<Menu>
94-
{ sections }
95-
</Menu>
96-
</aside>
97-
</div>
9867
</div>
9968
)
10069
}

themes/mongodb-tutorials/src/styles/bem-components/main.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,9 @@ $sidebar-width: 330px;
3939
flex: 1;
4040
margin-left: $sidebar-width;
4141
max-width: 900px; // TODO: Check with Melissa
42+
43+
&--single {
44+
margin-left: 410px; // Add 80px to space nav and content
45+
}
4246
}
4347
}

themes/mongodb-tutorials/src/styles/bem-components/single.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
@import '../colors';
22

33
.single {
4-
margin-left: 330px;
54
margin-top: 45px;
6-
max-width: 990px;
7-
padding: 20px 80px;
5+
max-width: 1260px; // 990px +330px(nav in single div) - 80px (content padding)
6+
padding: 20px 0px;
87

98
h1 {
109
border-bottom: 1px solid $light-grey-primary;

themes/mongodb-tutorials/src/styles/bem-components/toc.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,19 @@
1010
&__item:last-child {
1111
border-bottom: 1px solid $light-grey-primary;
1212
}
13+
14+
&__link {
15+
color: $black-primary;
16+
display: inline-block;
17+
font-family: Akzidenz;
18+
outline: none;
19+
padding: 20px;
20+
text-decoration: none;
21+
width: 100%;
22+
}
23+
24+
&__nestedlist {
25+
list-style: none;
26+
padding: 0px;
27+
}
1328
}

themes/mongodb-tutorials/static/css/app.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)