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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 24 deletions

View File

@ -25,9 +25,7 @@ function getEmotionCache() {
const PreviewContainer = ({ children, highlight }) => (
<CacheProvider value={getEmotionCache()}>
<Layout>
{highlight ? <Highlight>{children}</Highlight> : children}
</Layout>
<Layout>{highlight ? <Highlight>{children}</Highlight> : children}</Layout>
</CacheProvider>
);
@ -42,7 +40,7 @@ class Highlight extends React.Component {
if (this.ref.current) {
Prism.highlightAllUnder(this.ref.current);
}
})
});
}
componentDidMount() {
@ -54,13 +52,9 @@ class Highlight extends React.Component {
}
render() {
return (
<div ref={this.ref}>
{this.props.children}
</div>
);
return <div ref={this.ref}>{this.props.children}</div>;
}
};
}
const BlogPostPreview = ({ entry, widgetFor }) => {
const data = entry.get('data');
@ -121,8 +115,7 @@ const NotificationPreview = ({ entry }) => (
<Notification key={idx} url={notif.get('url')} loud={notif.get('loud')}>
{notif.get('message')}
</Notification>
))
}
))}
</PreviewContainer>
);

View File

@ -15,7 +15,7 @@ const EditLink = ({ collection, filename }) => (
}
`}
>
<a href={`/admin/#/edit/${collection}/${filename}`} target="_blank">
<a href={`/admin/#/edit/${collection}/${filename}`} target="_blank" rel="noopener noreferrer">
<svg
version="1.1"
id="pencil"

View File

@ -33,7 +33,7 @@ export const LayoutTemplate = ({ children }) => (
<GlobalStyles />
{children}
</ThemeProvider>
)
);
const Layout = ({ hasPageHero, children }) => {
return (

View File

@ -127,7 +127,7 @@ const StyledMarkdown = styled.div`
const Markdown = ({ body, html }) => {
if (body) {
return <StyledMarkdown>{body}</StyledMarkdown>
return <StyledMarkdown>{body}</StyledMarkdown>;
}
return <StyledMarkdown dangerouslySetInnerHTML={{ __html: html }} />;
};

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;