diff --git a/src/data/pages/shared/propTypes.js b/src/data/pages/shared/propTypes.js new file mode 100644 index 00000000..cf313621 --- /dev/null +++ b/src/data/pages/shared/propTypes.js @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +/** + * @file Provides shared prop types for pages. + * @author Arctic Ice Studio + * @author Sven Greb + * @see https://reactjs.org/docs/typechecking-with-proptypes.html + * @since 0.4.0 + */ + +import PropTypes from "prop-types"; + +const locationPropTypes = { + /** + * The `location` object provided by React/Reach Router. + * + * @see https://reach.tech/router/api/Router + */ + location: PropTypes.shape({ + /** + * The name of the current route/path. + */ + pathname: PropTypes.string + }).isRequired +}; + +/* eslint-disable-next-line import/prefer-default-export */ +export { locationPropTypes }; diff --git a/src/pages/404.jsx b/src/pages/404.jsx index b773fb1d..8080d11d 100644 --- a/src/pages/404.jsx +++ b/src/pages/404.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionLanding } from "organisms/page/404"; @@ -19,10 +20,12 @@ import { SectionLanding } from "organisms/page/404"; * @author Sven Greb * @since 0.3.0 */ -const Docs = props => ( - +const HttpStatus404 = ({ location: { pathname } }) => ( + ); -export default Docs; +HttpStatus404.propTypes = locationPropTypes; + +export default HttpStatus404; diff --git a/src/pages/blog.jsx b/src/pages/blog.jsx index 6ca16369..fca171d0 100644 --- a/src/pages/blog.jsx +++ b/src/pages/blog.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionBlogPosts } from "organisms/page/blog"; @@ -19,10 +20,12 @@ import { SectionBlogPosts } from "organisms/page/blog"; * @author Sven Greb * @since 0.3.0 */ -const Blog = props => ( - +const Blog = ({ location: { pathname } }) => ( + ); +Blog.propTypes = locationPropTypes; + export default Blog; diff --git a/src/pages/community.jsx b/src/pages/community.jsx index 2c8c479e..ec8348cd 100644 --- a/src/pages/community.jsx +++ b/src/pages/community.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionLanding } from "organisms/page/community"; @@ -19,10 +20,12 @@ import { SectionLanding } from "organisms/page/community"; * @author Sven Greb * @since 0.3.0 */ -const Community = props => ( - +const Community = ({ location: { pathname } }) => ( + ); +Community.propTypes = locationPropTypes; + export default Community; diff --git a/src/pages/docs.jsx b/src/pages/docs.jsx index 0728bff3..e649b054 100644 --- a/src/pages/docs.jsx +++ b/src/pages/docs.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionLanding } from "organisms/page/docs"; @@ -19,10 +20,12 @@ import { SectionLanding } from "organisms/page/docs"; * @author Sven Greb * @since 0.3.0 */ -const Docs = props => ( - +const Docs = ({ location: { pathname } }) => ( + ); +Docs.propTypes = locationPropTypes; + export default Docs; diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 5b05fdfb..9ebb2215 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionHero } from "organisms/page/landing"; @@ -19,10 +20,12 @@ import { SectionHero } from "organisms/page/landing"; * @author Sven Greb * @since 0.1.0 */ -const Landing = () => ( - +const Landing = ({ location: { pathname } }) => ( + ); +Landing.propTypes = locationPropTypes; + export default Landing; diff --git a/src/pages/ports.jsx b/src/pages/ports.jsx index 5e999dc1..f1bf15b9 100644 --- a/src/pages/ports.jsx +++ b/src/pages/ports.jsx @@ -9,6 +9,7 @@ import React from "react"; +import { locationPropTypes } from "data/pages/shared/propTypes"; import BaseLayout from "layouts/core/BaseLayout"; import { SectionLanding } from "organisms/page/ports"; @@ -19,10 +20,12 @@ import { SectionLanding } from "organisms/page/ports"; * @author Sven Greb * @since 0.3.0 */ -const Ports = props => ( - +const Ports = ({ location: { pathname } }) => ( + ); +Ports.propTypes = locationPropTypes; + export default Ports;