Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
fix(toc): fix issue with emojis not rendered in ToC
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jul 3, 2020
1 parent c045ed5 commit d7840e5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ module.exports = {
pathPrefix: '/',
gaTrackingId: null,
siteImage: null,
docsLocation: 'https://github.com/filipowm/boogi',
docsLocationType: 'github',
favicon: '/assets/favicon.png',
themeColor: '#',
},
Expand Down Expand Up @@ -49,6 +47,11 @@ module.exports = {
},
},
features: {
editOnRepo: {
editable: true,
location: 'https://github.com/filipowm/boogi',
type: 'github',
},
search: {
enabled: true,
indexName: 'docs',
Expand Down
6 changes: 3 additions & 3 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ module.exports = {
siteMetadata: {
title: config.metadata.name,
description: config.metadata.description,
docsLocation: config.metadata.docsLocation,
docsLocationType: config.metadata.docsLocationType,
editable: config.metadata.editable,
docsLocation: config.features.editOnRepo.location,
docsLocationType: config.features.editOnRepo.type,
editable: config.features.editOnRepo.editable,
siteImage: config.metadata.siteImage,
favicon: config.metadata.favicon,
logo: {
Expand Down
4 changes: 3 additions & 1 deletion src/components/TableOfContents/TableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import config from 'config';
import Scrollspy from 'react-scrollspy';
import { sleep } from '../../utils/utils';
import { scrollbar } from '../../styles'
import emoji from 'node-emoji';

const Sidebar = styled.aside`
background-color: ${(props) => props.theme.tableOfContents.background};
Expand Down Expand Up @@ -102,9 +103,10 @@ const buildToC = (item, items, maxDepth, depth) => {
return;
}
const itemId = innerItem.title ? innerItem.title.replace(/\s+/g, '').toLowerCase() : '#';
const title = emoji.emojify(innerItem.title, name => name);
let listItem = (
<ListItem key={items.length} to={`#${itemId}`} level={depth}>
{innerItem.title}
{title}
</ListItem>
);
items.push(listItem);
Expand Down
7 changes: 3 additions & 4 deletions src/templates/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ export default class MDXRuntimeTest extends React.Component {
const {
mdx,
site: {
siteMetadata: { docsLocation, docsLocationType, title },
siteMetadata: { docsLocation, docsLocationType, editable },
},
gitBranch,
} = data;

// meta tags
const metaTitle = mdx.frontmatter.metaTitle;
const description = mdx.frontmatter.description;
const docTitle = emoji.emojify(mdx.fields.title, (name) => name);
const headTitle = metaTitle ? metaTitle : emoji.strip(docTitle);
return (
Expand All @@ -117,7 +116,7 @@ export default class MDXRuntimeTest extends React.Component {
<PageTitle>
<TitleWrapper>
<Title>{docTitle}</Title>
{(config.metadata.editable && mdx.frontmatter.editable != false) ||
{(editable && mdx.frontmatter.editable != false) ||
mdx.frontmatter.editable ? (
<EditOnRepo
location={docsLocation}
Expand Down Expand Up @@ -171,6 +170,7 @@ export const pageQuery = graphql`
title
docsLocation
docsLocationType
editable
}
}
mdx(fields: { id: { eq: $id } }) {
Expand All @@ -194,7 +194,6 @@ export const pageQuery = graphql`
}
frontmatter {
metaTitle
description
showMetadata
editable
showPreviousNext
Expand Down

0 comments on commit d7840e5

Please sign in to comment.