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

Commit

Permalink
feat(components): support emojis in left navigation sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 1, 2020
1 parent c657838 commit 3023e1f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{
"order": 3,
"path": "/developing",
"title": "Developing"
"title": ":computer: Developing"
}
],
"links": [
Expand Down
2 changes: 1 addition & 1 deletion content/syntax/custom_components.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: ""
title: ":package: Custom Components"
order: 2
---

Expand Down
4 changes: 3 additions & 1 deletion src/components/sidebar/contentTreeGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import ContentTreeNode from "./contentTreeNode";
import config from "../../../config";
import styled from "@emotion/styled";
import emoji from "node-emoji"

const ContentTreeGroup = styled(({className, treeState, title, icon, location, children}) => {
children.forEach(item => {
Expand All @@ -19,11 +20,12 @@ const ContentTreeGroup = styled(({className, treeState, title, icon, location, c
[url]: !treeState.collapsed[url],
});
};
const emojified = emoji.emojify(title, (name) => name)
return (
<div className={className}>
{title ?
<>
<span>{icon ? <img src={icon}/> : null} {title}</span></>
<span>{icon ? <img src={icon}/> : null} {emojified}</span></>
: null}
<ul>
{children.map((child) => (
Expand Down
4 changes: 3 additions & 1 deletion src/components/sidebar/contentTreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {css} from "@emotion/core";
import styled from "@emotion/styled";
import Slide from "react-reveal/Slide";
import {useTheme} from "emotion-theming";
import emoji from "node-emoji"


// If you want to have a css call based on props, create a function that returns a css call like this
Expand Down Expand Up @@ -131,9 +132,10 @@ const ContentTreeNode = ({className, toggle, collapsed, url, title, location, ch
};
const theme = useTheme();
let isCollapsed = collapsed[url];
const text = emoji.emojify(title, (name) => name)
return (
<>
<NodeContent text={title} link={url} className={className} css={active ? activeNode(theme) : '' }>
<NodeContent text={text} link={url} className={className} css={active ? activeNode(theme) : '' }>
{ title && hasChildren ? (
<>
<NodeCollapseButton isCollapsed={isCollapsed} collapse={collapse} />
Expand Down
14 changes: 8 additions & 6 deletions src/templates/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Layout} from "$components";
import NextPrevious from '$components/nextPrevious';
import config from 'config';
import EditOnRepo from '$components/gitlab'
import emoji from 'node-emoji'

const forcedNavOrder = config.sidebar.forcedNavOrder;

Expand Down Expand Up @@ -103,24 +104,25 @@ export default class MDXRuntimeTest extends React.Component {
let canonicalUrl = config.metadata.url;
canonicalUrl = config.metadata.pathPrefix !== '/' ? canonicalUrl + config.metadata.pathPrefix : canonicalUrl;
canonicalUrl = canonicalUrl + mdx.fields.slug;

const docTitle = emoji.emojify(mdx.fields.title, (name) => name);
const headTitle = metaTitle ? metaTitle : emoji.strip(docTitle);
return (
<Layout {...this.props}>
<Helmet>
{metaTitle ? <title>{metaTitle}</title> : null}
{metaTitle ? <meta name="title" content={metaTitle} /> : null}
<title>{headTitle}</title>
<meta name="title" content={headTitle} />
<meta property="og:title" content={headTitle} />
<meta property="twitter:title" content={headTitle} />
{metaDescription ? <meta name="description" content={metaDescription} /> : null}
{metaTitle ? <meta property="og:title" content={metaTitle} /> : null}
{metaDescription ? <meta property="og:description" content={metaDescription} /> : null}
{metaTitle ? <meta property="twitter:title" content={metaTitle} /> : null}
{metaDescription ? (
<meta property="twitter:description" content={metaDescription} />
) : null}
<link rel="canonical" href={canonicalUrl} />
</Helmet>
<PageTitle>
<TitleWrapper>
<Title>{mdx.fields.title}</Title>
<Title>{docTitle}</Title>
{(config.metadata.editable && mdx.frontmatter.editable != false)
|| (mdx.frontmatter.editable) ?
<EditOnRepo location={docsLocation}
Expand Down

0 comments on commit 3023e1f

Please sign in to comment.