Skip to content

Commit 1ca134c

Browse files
EugeneHlushkomontogeek
authored andcommitted
fix(links) fix hydration overriding wrong elements of the ssr html (#3288)
* fix(links) fix hydration overriding wrong elements of the ssr html * fix(links) fix hydration overriding, remove fragment usage * misc(sorting) fix the bug with sorting * Update src/utilities/content-tree-enhancers.js
1 parent d7d3f51 commit 1ca134c

File tree

13 files changed

+65
-55
lines changed

13 files changed

+65
-55
lines changed

src/components/Sidebar/Sidebar.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default ({
3232
group = page.group;
3333

3434
return (
35-
<React.Fragment key={`sidebar-item-${index}`}>
35+
<div key={page.url}>
3636
{displayGroup ? <h4 className="sidebar__group">{group}</h4> : null}
3737

3838
<SidebarItem
@@ -42,7 +42,7 @@ export default ({
4242
anchors={page.anchors}
4343
currentPage={currentPage}
4444
/>
45-
</React.Fragment>
45+
</div>
4646
);
4747
})}
4848
</div>

src/components/SidebarItem/SidebarItem.jsx

+18-17
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,43 @@ export default class SidebarItem extends React.Component {
1010
};
1111

1212
render() {
13-
let { title, anchors = [] } = this.props;
13+
let {title, anchors = []} = this.props;
1414
let openMod = this.state.open ? `${block}--open` : '';
1515
let disabledMod = anchors.length == 0 ? `${block}--disabled` : '';
1616

1717
return (
18-
<div className={ `${block} ${openMod} ${disabledMod}` }>
19-
{ anchors.length > 0 ? (
18+
<div className={`${block} ${openMod} ${disabledMod}`}>
19+
{anchors.length > 0 ? (
2020
<i
21-
className={ `${block}__toggle icon-chevron-right` }
22-
onClick={ this._toggle.bind(this) } />
21+
className={`${block}__toggle icon-chevron-right`}
22+
onClick={this._toggle.bind(this)} />
2323
) : (
24-
<i className={ `${block}__toggle icon-vertical-bar` } />
24+
<i className={`${block}__toggle icon-vertical-bar`} />
2525
)}
2626

2727
<Link
28-
className={ `${block}__title` }
29-
to={ this.props.url }>
30-
{ title }
28+
key={this.props.url}
29+
className={`${block}__title`}
30+
to={this.props.url}>
31+
{title}
3132
</Link>
3233

33-
{ anchors.length > 0 ? (
34-
<ul className={ `${block}__anchors` }>
34+
{anchors.length > 0 ? (
35+
<ul className={`${block}__anchors`}>
3536
{
3637
anchors.map((anchor, i) => (
3738
<li
38-
key={ `anchor-${title}-${i}` }
39-
className={ `${block}__anchor` }
40-
title={ anchor.title }>
41-
<a href={ this._generateAnchorURL(anchor) }>
42-
{ anchor.title }
39+
key={this._generateAnchorURL(anchor)}
40+
className={`${block}__anchor`}
41+
title={anchor.title}>
42+
<a href={this._generateAnchorURL(anchor)}>
43+
{anchor.title}
4344
</a>
4445
</li>
4546
))
4647
}
4748
</ul>
48-
) : null }
49+
) : null}
4950
</div>
5051
);
5152
}

src/components/SidebarMobile/SidebarMobile.jsx

+25-25
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ export default class SidebarMobile extends React.Component {
99
_lastTouchPosition = {}
1010

1111
render() {
12-
let { isOpen, toggle } = this.props;
12+
let {isOpen, toggle} = this.props;
1313
let openMod = isOpen ? ' sidebar-mobile--visible' : '';
1414

1515
this._toggleBodyListener(isOpen);
1616

1717
return (
1818
<nav
19-
className={ `sidebar-mobile${openMod}` }
20-
ref={ ref => this._container = ref }
21-
onTouchStart={ this._handleTouchStart }
22-
onTouchMove={ this._handleTouchMove }
23-
onTouchEnd={ this._handleTouchEnd }>
19+
className={`sidebar-mobile${openMod}`}
20+
ref={ref => this._container = ref}
21+
onTouchStart={this._handleTouchStart}
22+
onTouchMove={this._handleTouchMove}
23+
onTouchEnd={this._handleTouchEnd}>
2424

2525
<div
2626
className="sidebar-mobile__toggle"
27-
onTouchStart={ this._handleTouchStart }
28-
onTouchMove={ this._handleOpenerTouchMove }
29-
onTouchEnd={ this._handleTouchEnd } />
27+
onTouchStart={this._handleTouchStart}
28+
onTouchMove={this._handleOpenerTouchMove}
29+
onTouchEnd={this._handleTouchEnd} />
3030

3131
<div className="sidebar-mobile__content">
3232
<i
3333
className="sidebar-mobile__close icon-cross"
34-
onClick={ toggle.bind(null, false) } />
34+
onClick={toggle.bind(null, false)} />
3535

36-
{ this._getSections() }
36+
{this._getSections()}
3737
</div>
3838
</nav>
3939
);
@@ -62,17 +62,17 @@ export default class SidebarMobile extends React.Component {
6262

6363
return (
6464
<div
65-
className={ `sidebar-mobile__section ${active ? 'sidebar-mobile__section--active' : ''}` }
66-
key={ section.url }>
65+
className={`sidebar-mobile__section ${active ? 'sidebar-mobile__section--active' : ''}`}
66+
key={section.url}>
6767
<Link
6868
className="sidebar-mobile__section-header"
69-
key={ section.url }
70-
to={ section.url }
71-
onClick={ this.props.toggle.bind(null, false) }>
72-
<h3>{ section.title || section.url }</h3>
69+
key={section.url}
70+
to={section.url}
71+
onClick={this.props.toggle.bind(null, false)}>
72+
<h3>{section.title || section.url}</h3>
7373
</Link>
7474

75-
{ this._getPages(section.children) }
75+
{this._getPages(section.children)}
7676
</div>
7777
);
7878
});
@@ -97,11 +97,11 @@ export default class SidebarMobile extends React.Component {
9797

9898
return (
9999
<Link
100-
key={ url }
101-
className={ `sidebar-mobile__page sidebar-mobile__section-child ${active ? 'sidebar-mobile__page--active' : ''}` }
102-
to={ url }
103-
onClick={ this.props.toggle.bind(null, false) }>
104-
{ page.title }
100+
key={url}
101+
className={`sidebar-mobile__page sidebar-mobile__section-child ${active ? 'sidebar-mobile__page--active' : ''}`}
102+
to={url}
103+
onClick={this.props.toggle.bind(null, false)}>
104+
{page.title}
105105
</Link>
106106
);
107107
});
@@ -113,7 +113,7 @@ export default class SidebarMobile extends React.Component {
113113
* @param {object} e - Native click event
114114
*/
115115
_handleBodyClick = e => {
116-
const { isOpen, toggle } = this.props;
116+
const {isOpen, toggle} = this.props;
117117
if (isOpen && !this._container.contains(e.target)) {
118118
toggle(false);
119119
}
@@ -156,7 +156,7 @@ export default class SidebarMobile extends React.Component {
156156
}
157157

158158
_handleTouchEnd = e => {
159-
const { isOpen } = this.props;
159+
const {isOpen} = this.props;
160160
const threshold = 20;
161161

162162
// Free up all the inline styling

src/content/api/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Introduction
3-
sort: 0
3+
sort: -1
44
contributors:
55
- tbroadley
66
---

src/content/concepts/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Concepts
3-
sort: 0
3+
sort: -1
44
contributors:
55
- TheLarkInn
66
- jhnns

src/content/contribute/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Contribute
3-
sort: 0
3+
sort: -1
44
contributors:
55
- rouzbeh84
66
- scottdj92

src/content/guides/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Guides
3-
sort: 0
3+
sort: -1
44
contributors:
55
- skipjack
66
- EugeneHlushko

src/content/guides/scaffolding.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Scaffolding
3+
sort: 14
34
contributors:
45
- evenstensberg
56
- pranshuchittora
67
- EugeneHlushko
7-
sort: 14
88
---
99

1010
It can be hard to set up a complex webpack configuration for the first time. Writing advanced configurations to optimize performance is quite hard. The `init` feature is designed to support people that want to create their own configuration or initializing projects that other people create.

src/content/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: webpack
3-
sort: 0
3+
sort: -1
44
---
55

66
## Write Your Code

src/content/loaders/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Loaders
3-
sort: 0
3+
sort: -1
44
contributors:
55
- simon04
66
- bajras

src/content/migrate/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Migrate
3-
sort: 0
3+
sort: -1
44
contributors:
55
- EugeneHlushko
66
---
77

8-
This section contains information about migrating from older versions of webpack to newer ones.
8+
This section contains information about migrating from older versions of webpack to newer ones.

src/content/plugins/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Plugins
3-
sort: 0
3+
sort: -1
44
contributors:
55
- simon04
66
- gonzoyumo

src/scripts/concatenate-docs.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ function getDirectoryRecursive(basePath) {
4949
}
5050

5151
// write compound target file
52-
const targetFile = fs.createWriteStream(targetFilePath);
52+
const targetFile = fs.createWriteStream(targetFilePath);
53+
54+
targetFile.write(`---
55+
title: Printable
56+
sort: 999
57+
contributors:
58+
- webpack
59+
---
60+
61+
`);
5362

5463
targetFile.on('error', (error) => {
5564
throw error;

0 commit comments

Comments
 (0)