Skip to content

Commit

Permalink
docs: fix h1 css leaking into search results (#2643)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreialecu authored Mar 29, 2021
1 parent 9d7b6be commit 208c0dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions packages/gatsby/src/components/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const Container = styled.article`
line-height: 1.7;
`;

const TitleContainer = styled.div`
border-bottom: 1px solid;
display: flex;
align-items: baseline;
justify-content: space-between;
flex-wrap: wrap-reverse;
`;
const Title = styled.h1`
box-sizing: border-box;
margin: 0;
border-bottom: 1px solid;
font-weight: 600;
font-size: 2rem;
line-height: 4rem;
+ div > blockquote {
font-style: normal;
}
display: flex;
align-items: baseline;
justify-content: space-between;
flex-wrap: wrap-reverse;
`;

const EditLink = styled.a`
Expand Down Expand Up @@ -175,10 +175,12 @@ const Content = styled.div`

export const PrerenderedMarkdown = ({title, children, editUrl}) => <>
<Container>
<Title title={title}>
{title.match(/^`.*`$/) ? <code>{title.slice(1, -1)}</code> : title}
<TitleContainer>
<Title>
{title.match(/^`.*`$/) ? <code>{title.slice(1, -1)}</code> : title}
</Title>
{editUrl && <EditLink target="_blank" href={editUrl}>Edit this page on GitHub</EditLink>}
</Title>
</TitleContainer>
<Content dangerouslySetInnerHTML={{__html: children}} />
</Container>
</>;
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/components/toc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const Toc = ({ headingSelector, getTitle, getDepth, ...rest }) => {
headingSelector || Array.from({ length: 6 }, (_, i) => `article h` + (i + 1))
const nodes = Array.from(document.querySelectorAll(selector))
const titles = nodes.map(node => ({
title: getTitle ? getTitle(node) : (node.title || node.innerText || node.textContent),
title: getTitle ? getTitle(node) : (node.innerText || node.textContent),
depth: getDepth ? getDepth(node) : Number(node.nodeName[1]),
}))
// Compute the minimum heading depth. Will be subtracted from each heading's
Expand Down

0 comments on commit 208c0dc

Please sign in to comment.