Skip to content

Commit ce2aade

Browse files
author
Gasim Gasimzada
committed
Import header and footer nav YAML files directly
- Remove them from section list - Add keys to nav array items when mapping
1 parent 52fbfd0 commit ce2aade

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

src/components/LayoutFooter/Footer.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import MetaTitle from 'templates/components/MetaTitle';
1212
import SectionLinks from './SectionLinks';
1313
import React from 'react';
1414
import {colors, media} from 'theme';
15-
import {
16-
sectionListCommunity,
17-
sectionListDocs,
18-
sectionListFooter,
19-
} from 'utils/sectionList';
15+
import {sectionListCommunity, sectionListDocs} from 'utils/sectionList';
16+
17+
import navFooter from '../../../content/footerNav.yml';
2018

2119
import ossLogoPng from 'images/oss_logo.png';
2220

@@ -64,7 +62,7 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
6462
},
6563
}}>
6664
<FooterNav layoutHasSidebar={layoutHasSidebar}>
67-
<MetaTitle onDark={true}>{sectionListFooter.docs.title}</MetaTitle>
65+
<MetaTitle onDark={true}>{navFooter.docs.title}</MetaTitle>
6866
{sectionListDocs.map(section => {
6967
const defaultItem = section.items[0];
7068
return (
@@ -77,15 +75,11 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
7775
})}
7876
</FooterNav>
7977
<FooterNav layoutHasSidebar={layoutHasSidebar}>
80-
<MetaTitle onDark={true}>
81-
{sectionListFooter.channels.title}
82-
</MetaTitle>
83-
<SectionLinks links={sectionListFooter.channels.items} />
78+
<MetaTitle onDark={true}>{navFooter.channels.title}</MetaTitle>
79+
<SectionLinks links={navFooter.channels.items} />
8480
</FooterNav>
8581
<FooterNav layoutHasSidebar={layoutHasSidebar}>
86-
<MetaTitle onDark={true}>
87-
{sectionListFooter.community.title}
88-
</MetaTitle>
82+
<MetaTitle onDark={true}>{navFooter.community.title}</MetaTitle>
8983
{sectionListCommunity.map(section => (
9084
<FooterLink
9185
to={`/community/${section.items[0].id}.html`}
@@ -95,8 +89,8 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
9589
))}
9690
</FooterNav>
9791
<FooterNav layoutHasSidebar={layoutHasSidebar}>
98-
<MetaTitle onDark={true}>{sectionListFooter.more.title}</MetaTitle>
99-
<SectionLinks links={sectionListFooter.more.items} />
92+
<MetaTitle onDark={true}>{navFooter.more.title}</MetaTitle>
93+
<SectionLinks links={navFooter.more.items} />
10094
</FooterNav>
10195
</div>
10296
<section

src/components/LayoutFooter/SectionLinks.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ const SectionLinks = ({links}: Props) =>
66
links.map(item => {
77
if (item.external) {
88
return (
9-
<ExternalFooterLink href={item.to} target="_blank" rel="noopener">
9+
<ExternalFooterLink
10+
key={item.title}
11+
href={item.to}
12+
target="_blank"
13+
rel="noopener">
1014
{item.title}
1115
</ExternalFooterLink>
1216
);
1317
}
1418

15-
return <FooterLink to={item.to}>{item.title}</FooterLink>;
19+
return (
20+
<FooterLink key={item.title} to={item.to}>
21+
{item.title}
22+
</FooterLink>
23+
);
1624
});
1725

1826
export default SectionLinks;

src/components/LayoutHeader/Header.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {version} from 'site-constants';
1414
import ExternalLinkSvg from 'templates/components/ExternalLinkSvg';
1515
import DocSearch from './DocSearch';
1616

17-
import {sectionListHeader} from '../../utils/sectionList';
17+
import navHeader from '../../../content/headerNav.yml';
1818

1919
import logoSvg from 'icons/logo.svg';
2020

@@ -122,8 +122,9 @@ const Header = ({location}: {location: Location}) => (
122122
'linear-gradient(to right, transparent, black 20px, black 90%, transparent)',
123123
},
124124
}}>
125-
{sectionListHeader.items.map(link => (
125+
{navHeader.items.map(link => (
126126
<HeaderLink
127+
key={link.title}
127128
isActive={location.pathname.includes(link.activeSelector)}
128129
title={link.title}
129130
to={link.to}

src/utils/sectionList.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import navCommunity from '../../content/community/nav.yml';
1111
import navDocs from '../../content/docs/nav.yml';
1212
// $FlowExpectedError
1313
import navTutorial from '../../content/tutorial/nav.yml';
14-
// $FlowExpectedError
15-
import navFooter from '../../content/footerNav.yml';
16-
// $FlowExpectedError
17-
import navHeader from '../../content/headerNav.yml';
1814

1915
const sectionListDocs = navDocs.map(
2016
(item: Object): Object => ({
@@ -34,6 +30,4 @@ export {
3430
sectionListCommunity,
3531
sectionListDocs,
3632
navTutorial as sectionListTutorial,
37-
navFooter as sectionListFooter,
38-
navHeader as sectionListHeader,
3933
};

0 commit comments

Comments
 (0)