Skip to content

Commit 54f2d7f

Browse files
committed
main app: remove noHeader prop
1 parent 8f79484 commit 54f2d7f

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

lib/withAuth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let globalUser = null;
66

77
export default function withAuth(
88
BaseComponent,
9-
{ loginRequired = true, logoutRequired = false, adminRequired = false, noHeader = false } = {},
9+
{ loginRequired = true, logoutRequired = false, adminRequired = false } = {},
1010
) {
1111
class App extends React.PureComponent {
1212
static propTypes = {
@@ -29,7 +29,7 @@ export default function withAuth(
2929
user._id = user._id.toString();
3030
}
3131

32-
const props = { user, isFromServer, noHeader };
32+
const props = { user, isFromServer };
3333

3434
if (BaseComponent.getInitialProps) {
3535
Object.assign(props, (await BaseComponent.getInitialProps(ctx)) || {});

pages/_app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class MyApp extends App {
4141
render() {
4242
const { Component, pageProps } = this.props;
4343

44-
// console.log(pageProps);
45-
// console.log(pageProps.noHeader);
44+
console.log(pageProps);
4645

4746
return (
4847
<Container>
@@ -51,7 +50,12 @@ class MyApp extends App {
5150
<ThemeProvider theme={theme}>
5251
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
5352
<CssBaseline />
54-
{pageProps.noHeader ? null : <Header {...pageProps} />}
53+
{pageProps.chapter ||
54+
pageProps.toc ||
55+
pageProps.tutorials ||
56+
pageProps.indexPage ? null : (
57+
<Header {...pageProps} />
58+
)}
5559
<Component {...pageProps} />
5660
<Notifier />
5761
</ThemeProvider>

pages/book.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const Book = ({ user, toc }) => (
4949
<p style={{ textAlign: 'center' }}>
5050
<Link
5151
prefetch
52-
as="/books/builder-book/introduction"
53-
href="/public/read-chapter?bookSlug=builder-book&chapterSlug=introduction"
52+
as="/books/demo-book/introduction"
53+
href="/public/read-chapter?bookSlug=demo-book&chapterSlug=introduction"
5454
>
5555
<Button variant="contained" color="primary" style={styleRaisedButton}>
5656
Read Preview
@@ -198,4 +198,4 @@ Book.getInitialProps = async function getInitialProps() {
198198
return { toc };
199199
};
200200

201-
export default withAuth(Book, { loginRequired: false, noHeader: true });
201+
export default withAuth(Book, { loginRequired: false });

pages/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,9 @@ Index.defaultProps = {
280280
user: null,
281281
};
282282

283-
export default withAuth(Index, { loginRequired: false, noHeader: true });
283+
Index.getInitialProps = function getInitialProps() {
284+
const indexPage = true;
285+
return { indexPage };
286+
};
287+
288+
export default withAuth(Index, { loginRequired: false });

pages/public/read-chapter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,5 +495,4 @@ class ReadChapter extends React.Component {
495495

496496
export default withAuth(withRouter(ReadChapter), {
497497
loginRequired: false,
498-
noHeader: true,
499498
});

pages/tutorials.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ Tutorials.getInitialProps = async function getInitialProps() {
7676
return { tutorials };
7777
};
7878

79-
export default withAuth(Tutorials, { loginRequired: false, noHeader: true });
79+
export default withAuth(Tutorials, { loginRequired: false });

server/routesWithSlug.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ function routesWithSlug({ server, app }) {
2020
}
2121

2222
module.exports = routesWithSlug;
23-

0 commit comments

Comments
 (0)