Skip to content

Extracting Header and Footer Links from source into content #2270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions content/footerNav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
community:
title: Community

docs:
title: Docs

more:
title: More
items:
- title: Tutorial
to: /tutorial/tutorial.html
- title: Blog
to: /blog
- title: Acknowledgements
to: /acknowledgements.html
- title: React Native
to: https://facebook.github.io/react-native/
external: true

channels:
title: Channels
items:
- title: Github
to: https://github.com/facebook/react
external: true
- title: Stack Overflow
to: https://stackoverflow.com/questions/tagged/reactjs
external: true
- title: Discussion Forums
to: https://reactjs.org/community/support.html#popular-discussion-forums
external: true
- title: Reactiflux Chat
to: https://discord.gg/0ZcbPKXt5bZjGY5n
external: true
- title: DEV Community
to: https://dev.to/t/react
external: true
- title: Facebook
to: https://www.facebook.com/react
external: true
- title: Twitter
to: https://twitter.com/reactjs
external: true
13 changes: 13 additions & 0 deletions content/headerNav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
items:
- title: Docs
to: /docs/getting-started.html
activeSelector: /docs/
- title: Tutorial
to: /tutorial/tutorial.html
activeSelector: /tutorial
- title: Blog
to: /blog/
activeSelector: /blog
- title: Community
to: /community/support.html
activeSelector: /community
75 changes: 16 additions & 59 deletions src/components/LayoutFooter/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
*/

import Container from 'components/Container';
import ExternalFooterLink from './ExternalFooterLink';
import FooterLink from './FooterLink';
import FooterNav from './FooterNav';
import MetaTitle from 'templates/components/MetaTitle';
import SectionLinks from './SectionLinks';
import React from 'react';
import {colors, media} from 'theme';
import {sectionListCommunity, sectionListDocs} from 'utils/sectionList';
import {
sectionListCommunity,
sectionListDocs,
sectionListFooter,
} from 'utils/sectionList';

import ossLogoPng from 'images/oss_logo.png';

Expand Down Expand Up @@ -60,7 +64,7 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
},
}}>
<FooterNav layoutHasSidebar={layoutHasSidebar}>
<MetaTitle onDark={true}>Docs</MetaTitle>
<MetaTitle onDark={true}>{sectionListFooter.docs.title}</MetaTitle>
{sectionListDocs.map(section => {
const defaultItem = section.items[0];
return (
Expand All @@ -73,52 +77,15 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
})}
</FooterNav>
<FooterNav layoutHasSidebar={layoutHasSidebar}>
<MetaTitle onDark={true}>Channels</MetaTitle>
<ExternalFooterLink
href="https://github.com/facebook/react"
target="_blank"
rel="noopener">
GitHub
</ExternalFooterLink>
<ExternalFooterLink
href="https://stackoverflow.com/questions/tagged/reactjs"
target="_blank"
rel="noopener">
Stack Overflow
</ExternalFooterLink>
<ExternalFooterLink
href="https://reactjs.org/community/support.html#popular-discussion-forums"
target="_blank"
rel="noopener">
Discussion Forums
</ExternalFooterLink>
<ExternalFooterLink
href="https://discord.gg/0ZcbPKXt5bZjGY5n"
target="_blank"
rel="noopener">
Reactiflux Chat
</ExternalFooterLink>
<ExternalFooterLink
href="https://dev.to/t/react"
target="_blank"
rel="noopener">
DEV Community
</ExternalFooterLink>
<ExternalFooterLink
href="https://www.facebook.com/react"
target="_blank"
rel="noopener">
Facebook
</ExternalFooterLink>
<ExternalFooterLink
href="https://twitter.com/reactjs"
target="_blank"
rel="noopener">
Twitter
</ExternalFooterLink>
<MetaTitle onDark={true}>
{sectionListFooter.channels.title}
</MetaTitle>
<SectionLinks links={sectionListFooter.channels.items} />
</FooterNav>
<FooterNav layoutHasSidebar={layoutHasSidebar}>
<MetaTitle onDark={true}>Community</MetaTitle>
<MetaTitle onDark={true}>
{sectionListFooter.community.title}
</MetaTitle>
{sectionListCommunity.map(section => (
<FooterLink
to={`/community/${section.items[0].id}.html`}
Expand All @@ -128,18 +95,8 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
))}
</FooterNav>
<FooterNav layoutHasSidebar={layoutHasSidebar}>
<MetaTitle onDark={true}>More</MetaTitle>
<FooterLink to="/tutorial/tutorial.html">Tutorial</FooterLink>
<FooterLink to="/blog/">Blog</FooterLink>
<FooterLink to="/acknowledgements.html">
Acknowledgements
</FooterLink>
<ExternalFooterLink
href="https://facebook.github.io/react-native/"
target="_blank"
rel="noopener">
React Native
</ExternalFooterLink>
<MetaTitle onDark={true}>{sectionListFooter.more.title}</MetaTitle>
<SectionLinks links={sectionListFooter.more.items} />
</FooterNav>
</div>
<section
Expand Down
18 changes: 18 additions & 0 deletions src/components/LayoutFooter/SectionLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import ExternalFooterLink from './ExternalFooterLink';
import FooterLink from './FooterLink';

const SectionLinks = ({links}: Props) =>
links.map(item => {
if (item.external) {
return (
<ExternalFooterLink href={item.to} target="_blank" rel="noopener">
{item.title}
</ExternalFooterLink>
);
}

return <FooterLink to={item.to}>{item.title}</FooterLink>;
});

export default SectionLinks;
29 changes: 9 additions & 20 deletions src/components/LayoutHeader/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {version} from 'site-constants';
import ExternalLinkSvg from 'templates/components/ExternalLinkSvg';
import DocSearch from './DocSearch';

import {sectionListHeader} from '../../utils/sectionList';

import logoSvg from 'icons/logo.svg';

const Header = ({location}: {location: Location}) => (
Expand Down Expand Up @@ -120,26 +122,13 @@ const Header = ({location}: {location: Location}) => (
'linear-gradient(to right, transparent, black 20px, black 90%, transparent)',
},
}}>
<HeaderLink
isActive={location.pathname.includes('/docs/')}
title="Docs"
to="/docs/getting-started.html"
/>
<HeaderLink
isActive={location.pathname.includes('/tutorial/')}
title="Tutorial"
to="/tutorial/tutorial.html"
/>
<HeaderLink
isActive={location.pathname.includes('/blog')}
title="Blog"
to="/blog/"
/>
<HeaderLink
isActive={location.pathname.includes('/community/')}
title="Community"
to="/community/support.html"
/>
{sectionListHeader.items.map(link => (
<HeaderLink
isActive={location.pathname.includes(link.activeSelector)}
title={link.title}
to={link.to}
/>
))}
</nav>

<DocSearch />
Expand Down
6 changes: 6 additions & 0 deletions src/utils/sectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import navCommunity from '../../content/community/nav.yml';
import navDocs from '../../content/docs/nav.yml';
// $FlowExpectedError
import navTutorial from '../../content/tutorial/nav.yml';
// $FlowExpectedError
import navFooter from '../../content/footerNav.yml';
// $FlowExpectedError
import navHeader from '../../content/headerNav.yml';

const sectionListDocs = navDocs.map(
(item: Object): Object => ({
Expand All @@ -30,4 +34,6 @@ export {
sectionListCommunity,
sectionListDocs,
navTutorial as sectionListTutorial,
navFooter as sectionListFooter,
navHeader as sectionListHeader,
};