mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
wrap pages in layout
This commit is contained in:
parent
038e63d94d
commit
aaed77eed1
@ -1,4 +1,6 @@
|
|||||||
import "firebase/database"
|
import "firebase/database"
|
||||||
|
import React from 'react';
|
||||||
|
import Layout from './src/components/Layout/Layout'
|
||||||
|
|
||||||
import "gatsby-remark-vscode/styles.css"
|
import "gatsby-remark-vscode/styles.css"
|
||||||
|
|
||||||
@ -25,3 +27,7 @@ export const shouldUpdateScroll = ({ routerProps: { location } }) => {
|
|||||||
|
|
||||||
return window.scrollTo(0, 0)
|
return window.scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const wrapPageElement = ({ element, props }) => {
|
||||||
|
return <Layout {...props}>{element}</Layout>;
|
||||||
|
};
|
||||||
@ -1,12 +1,13 @@
|
|||||||
import React from "react"
|
|
||||||
import "firebase/database"
|
import "firebase/database"
|
||||||
|
import React from "react"
|
||||||
|
import Layout from './src/components/Layout/Layout'
|
||||||
|
|
||||||
const OnDark = () => {
|
const OnDark = () => {
|
||||||
return (
|
return (
|
||||||
<script
|
<script
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: `
|
__html: `
|
||||||
(() => {
|
(function() {
|
||||||
window.__isDarkTheme = false
|
window.__isDarkTheme = false
|
||||||
|
|
||||||
window.__setTheme = function(theme) {
|
window.__setTheme = function(theme) {
|
||||||
@ -41,3 +42,7 @@ const OnDark = () => {
|
|||||||
export const onRenderBody = ({ setPreBodyComponents }) => {
|
export const onRenderBody = ({ setPreBodyComponents }) => {
|
||||||
setPreBodyComponents(<OnDark key="isDarkTheme" />)
|
setPreBodyComponents(<OnDark key="isDarkTheme" />)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const wrapPageElement = ({ element, props }) => {
|
||||||
|
return <Layout {...props}>{element}</Layout>;
|
||||||
|
};
|
||||||
@ -21,13 +21,19 @@ const Header = () => {
|
|||||||
const [isMobileOpen, setIsMobileOpen] = React.useState(false)
|
const [isMobileOpen, setIsMobileOpen] = React.useState(false)
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
|
|
||||||
|
const [ready, setReady] = React.useState(false)
|
||||||
|
const [isDark, setIsDark] = React.useState(false)
|
||||||
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
setIsDark(window.__isDarkTheme)
|
||||||
|
setReady(true)
|
||||||
isMobileOpen
|
isMobileOpen
|
||||||
? (document.body.style.overflowY = "hidden")
|
? (document.body.style.overflowY = "hidden")
|
||||||
: (document.body.style.overflowY = "")
|
: (document.body.style.overflowY = "")
|
||||||
document.body.onscroll = () =>
|
document.body.onscroll = () =>
|
||||||
window.pageYOffset >= 100 ? setIsScrolled(true) : setIsScrolled(false)
|
window.pageYOffset >= 100 ? setIsScrolled(true) : setIsScrolled(false)
|
||||||
}, [isMobileOpen])
|
}, [isMobileOpen, setIsDark, setReady])
|
||||||
|
|
||||||
const mobileHandler = () => {
|
const mobileHandler = () => {
|
||||||
setIsMobileOpen(!isMobileOpen)
|
setIsMobileOpen(!isMobileOpen)
|
||||||
@ -71,7 +77,7 @@ const Header = () => {
|
|||||||
<div className="header-nav__links">
|
<div className="header-nav__links">
|
||||||
<nav>{renderLinks()}</nav>
|
<nav>{renderLinks()}</nav>
|
||||||
</div>
|
</div>
|
||||||
<ThemeSwitcher />
|
<ThemeSwitcher ready={ready} isDark={isDark} setIsDark={setIsDark} />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
|
|||||||
@ -3,14 +3,14 @@ import React from 'react';
|
|||||||
import MoonIcon from "../../../images/moon-icon.svg"
|
import MoonIcon from "../../../images/moon-icon.svg"
|
||||||
import SunIcon from "../../../images/sun-icon.svg"
|
import SunIcon from "../../../images/sun-icon.svg"
|
||||||
|
|
||||||
const ThemeSwitcher = () => {
|
const ThemeSwitcher = ({ ready, isDark, setIsDark }) => {
|
||||||
const [ready, setReady] = React.useState(false)
|
// const [ready, setReady] = React.useState(false)
|
||||||
const [isDark, setIsDark] = React.useState(false)
|
// const [isDark, setIsDark] = React.useState(false)
|
||||||
|
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
setIsDark(window.__isDarkTheme)
|
// setIsDark(window.__isDarkTheme)
|
||||||
setReady(true)
|
// setReady(true)
|
||||||
}, [setIsDark, setReady])
|
// }, [setIsDark, setReady])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ready ? 'header-nav__theme ready' : 'header-nav__theme'}>
|
<div className={ready ? 'header-nav__theme ready' : 'header-nav__theme'}>
|
||||||
|
|||||||
@ -3,11 +3,10 @@ import { Main } from "../ui/ui"
|
|||||||
import { Grid } from "react-flexbox-grid"
|
import { Grid } from "react-flexbox-grid"
|
||||||
import { Link } from "gatsby"
|
import { Link } from "gatsby"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
|
|
||||||
const NotFound = () => {
|
const NotFound = () => {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO />
|
<SEO />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -18,7 +17,7 @@ const NotFound = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { Grid, Row, Col } from "react-flexbox-grid"
|
|||||||
import { Main } from "../ui/ui"
|
import { Main } from "../ui/ui"
|
||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Offers from "../components/Offers/Offers"
|
import Offers from "../components/Offers/Offers"
|
||||||
import About from "../components/About/About"
|
import About from "../components/About/About"
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ const AboutPage = () => {
|
|||||||
siteMetadata: { title, menuLinks, social },
|
siteMetadata: { title, menuLinks, social },
|
||||||
} = useSiteMetadataQuery()
|
} = useSiteMetadataQuery()
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO
|
<SEO
|
||||||
title="О сайте"
|
title="О сайте"
|
||||||
description="Этот сайт придуман для того, чтобы помочь вам разобраться с вашей проблемой и решить её. Сайт содержит в себе статьи и руководства."
|
description="Этот сайт придуман для того, чтобы помочь вам разобраться с вашей проблемой и решить её. Сайт содержит в себе статьи и руководства."
|
||||||
@ -35,7 +34,7 @@ const AboutPage = () => {
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import useCategoriesQuery from "../hooks/useCategoriesQuery"
|
|||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
|
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Articles from "../components/Articles/Articles"
|
import Articles from "../components/Articles/Articles"
|
||||||
import Categories from "../components/Articles/Categories/Categories"
|
import Categories from "../components/Articles/Categories/Categories"
|
||||||
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
||||||
@ -64,7 +63,7 @@ const ArticlesPage = ({ data: { allMarkdownRemark: edges } }) => {
|
|||||||
}, [setFiltredArticles, filterArticles, allArticles.edges, query, onPage])
|
}, [setFiltredArticles, filterArticles, allArticles.edges, query, onPage])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO title="Статьи" />
|
<SEO title="Статьи" />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -123,7 +122,7 @@ const ArticlesPage = ({ data: { allMarkdownRemark: edges } }) => {
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { Main } from "../ui/ui"
|
|||||||
import { Grid, Row, Col } from "react-flexbox-grid"
|
import { Grid, Row, Col } from "react-flexbox-grid"
|
||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Contacts from "../components/Contacts/Contacts"
|
import Contacts from "../components/Contacts/Contacts"
|
||||||
|
|
||||||
const ContactsPage = () => {
|
const ContactsPage = () => {
|
||||||
@ -13,7 +12,7 @@ const ContactsPage = () => {
|
|||||||
},
|
},
|
||||||
} = useSiteMetadataQuery()
|
} = useSiteMetadataQuery()
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO
|
<SEO
|
||||||
title="📝 Контакты"
|
title="📝 Контакты"
|
||||||
description="Для того чтобы задать вопрос, сообщить об ошибках или просто поздороваться, вы можете воспользоваться формой обратной связи или использовать контактные данные."
|
description="Для того чтобы задать вопрос, сообщить об ошибках или просто поздороваться, вы можете воспользоваться формой обратной связи или использовать контактные данные."
|
||||||
@ -27,7 +26,7 @@ const ContactsPage = () => {
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { Grid, Row, Col } from "react-flexbox-grid"
|
|||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
import useSnippetsQuery from "../hooks/useSnippetsQuery"
|
import useSnippetsQuery from "../hooks/useSnippetsQuery"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Articles from "../components/Articles/Articles"
|
import Articles from "../components/Articles/Articles"
|
||||||
import Snippets from "../components/Snippets/Snippets"
|
import Snippets from "../components/Snippets/Snippets"
|
||||||
import SnippetItem from "../components/Snippets/SnippetItem/SnippetItem"
|
import SnippetItem from "../components/Snippets/SnippetItem/SnippetItem"
|
||||||
@ -23,7 +22,7 @@ const IndexPage = ({ data: { allMarkdownRemark: edges } }) => {
|
|||||||
let [limit, setLimit] = React.useState(onPage)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO />
|
<SEO />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -59,7 +58,7 @@ const IndexPage = ({ data: { allMarkdownRemark: edges } }) => {
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { graphql } from "gatsby"
|
|||||||
import { Main } from "../ui/ui"
|
import { Main } from "../ui/ui"
|
||||||
import { Grid, Row, Col } from "react-flexbox-grid"
|
import { Grid, Row, Col } from "react-flexbox-grid"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Snippets from "../components/Snippets/Snippets"
|
import Snippets from "../components/Snippets/Snippets"
|
||||||
import SnippetItem from "../components/Snippets/SnippetItem/SnippetItem"
|
import SnippetItem from "../components/Snippets/SnippetItem/SnippetItem"
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ const SnippetsPage = ({
|
|||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO />
|
<SEO />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -39,7 +38,7 @@ const SnippetsPage = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { Main } from "../ui/ui"
|
import { Main } from "../ui/ui"
|
||||||
import { Grid, Row, Col } from "react-flexbox-grid"
|
import { Grid, Row, Col } from "react-flexbox-grid"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Article from "../components/Article/Article"
|
import Article from "../components/Article/Article"
|
||||||
import Offers from "../components/Offers/Offers"
|
import Offers from "../components/Offers/Offers"
|
||||||
import MoreArticles from "../components/Articles/MoreArticles/MoreArticles"
|
import MoreArticles from "../components/Articles/MoreArticles/MoreArticles"
|
||||||
@ -14,7 +13,7 @@ const articleTemplate = ({
|
|||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
<Row>
|
<Row>
|
||||||
@ -29,7 +28,7 @@ const articleTemplate = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { graphql } from "gatsby"
|
|||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
import useCategoriesQuery from "../hooks/useCategoriesQuery"
|
import useCategoriesQuery from "../hooks/useCategoriesQuery"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Articles from "../components/Articles/Articles"
|
import Articles from "../components/Articles/Articles"
|
||||||
import Categories from "../components/Articles/Categories/Categories"
|
import Categories from "../components/Articles/Categories/Categories"
|
||||||
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
||||||
@ -28,7 +27,7 @@ const CategoryPage = ({
|
|||||||
let [limit, setLimit] = React.useState(onPage)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO title={title} canonical={`${siteUrl}/articles`} />
|
<SEO title={title} canonical={`${siteUrl}/articles`} />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -63,7 +62,7 @@ const CategoryPage = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import React from "react"
|
|||||||
import { Main } from "../ui/ui"
|
import { Main } from "../ui/ui"
|
||||||
import { Grid, Row, Col } from "react-flexbox-grid"
|
import { Grid, Row, Col } from "react-flexbox-grid"
|
||||||
import Snippet from "../components/Snippet/Snippet"
|
import Snippet from "../components/Snippet/Snippet"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import { graphql } from "gatsby"
|
import { graphql } from "gatsby"
|
||||||
|
|
||||||
const snippetTemplate = ({
|
const snippetTemplate = ({
|
||||||
@ -11,7 +10,7 @@ const snippetTemplate = ({
|
|||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid style={{ maxWidth: 900 }}>
|
<Grid fluid style={{ maxWidth: 900 }}>
|
||||||
<Row>
|
<Row>
|
||||||
@ -21,7 +20,7 @@ const snippetTemplate = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { graphql } from "gatsby"
|
|||||||
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
import useSiteMetadataQuery from "../hooks/useSiteMetadataQuery"
|
||||||
import useCategoriesQuery from "../hooks/useCategoriesQuery"
|
import useCategoriesQuery from "../hooks/useCategoriesQuery"
|
||||||
import SEO from "../components/SEO/SEO"
|
import SEO from "../components/SEO/SEO"
|
||||||
import Layout from "../components/Layout/Layout"
|
|
||||||
import Articles from "../components/Articles/Articles"
|
import Articles from "../components/Articles/Articles"
|
||||||
import Categories from "../components/Articles/Categories/Categories"
|
import Categories from "../components/Articles/Categories/Categories"
|
||||||
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
import CategoryItem from "../components/Articles/Categories/CategoryItem"
|
||||||
@ -28,7 +27,7 @@ const TagPage = ({
|
|||||||
let [limit, setLimit] = React.useState(onPage)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<SEO title={title} canonical={`${siteUrl}/articles`} />
|
<SEO title={title} canonical={`${siteUrl}/articles`} />
|
||||||
<Main>
|
<Main>
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
@ -63,7 +62,7 @@ const TagPage = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Main>
|
</Main>
|
||||||
</Layout>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user