fix: add 'rel' attirubte to edit link (#3293)

This commit is contained in:
Erez Rokah
2020-02-20 16:38:34 +01:00
committed by GitHub
parent 783440e370
commit 5ea1554a07
5 changed files with 21 additions and 24 deletions

View File

@ -12,7 +12,10 @@ import Widgets from '../components/widgets';
import Markdown from '../components/markdown';
function filenameFromPath(p) {
return p.split('/').slice(-1)[0].split('.')[0];
return p
.split('/')
.slice(-1)[0]
.split('.')[0];
}
const toMenu = (menu, nav) =>
@ -40,13 +43,9 @@ export const DocsTemplate = ({
group,
}) => (
<Container size="md">
<SidebarLayout
sidebar={showSidebar && <DocsSidebar docsNav={docsNav} location={location} />}
>
<SidebarLayout sidebar={showSidebar && <DocsSidebar docsNav={docsNav} location={location} />}>
<article data-docs-content>
{filename && (
<EditLink collection={`docs_${group}`} filename={filename} />
)}
{filename && <EditLink collection={`docs_${group}`} filename={filename} />}
<h1>{title}</h1>
<Markdown body={body} html={html} />
{showWidgets && <Widgets widgets={widgets} />}
@ -56,8 +55,13 @@ export const DocsTemplate = ({
);
const DocPage = ({ data, location }) => {
const { nav, page: { frontmatter, html, fields }, widgets, menu } = data;
const { title, group } = frontmatter
const {
nav,
page: { frontmatter, html, fields },
widgets,
menu,
} = data;
const { title, group } = frontmatter;
const docsNav = toMenu(menu.siteMetadata.menu.docs, nav);
const showWidgets = location.pathname.indexOf('/docs/widgets') !== -1;