Skip to content

Commit b0831ed

Browse files
authored
add map page (#13)
1 parent a486b73 commit b0831ed

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

gatsby-theme-woly/src/components/layout.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import styled from 'styled-components';
55

66
import { ComponentsMenu } from './components-menu';
77
import { paths } from '../paths';
8+
import { mapComponentName } from '../lib/constants';
89

910
export const Layout = ({ children }) => {
1011
const data = useStaticQuery(graphql`
@@ -52,12 +53,14 @@ function createMapping(data) {
5253
}
5354
const prefix = data.pathPrefix || '';
5455

55-
packages[component.meta.package].push({
56-
...component.meta,
57-
path: prefix + paths.componentUsage(component.meta),
58-
id: component.id,
59-
title: camelCase(component.meta.name),
60-
});
56+
if (component.meta.category !== mapComponentName) {
57+
packages[component.meta.package].push({
58+
...component.meta,
59+
path: prefix + paths.componentUsage(component.meta),
60+
id: component.id,
61+
title: camelCase(component.meta.name),
62+
});
63+
}
6164
}
6265

6366
return Object.keys(packages).reduce((list, name) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const mapComponentName = 'map';

gatsby-theme-woly/src/templates/usage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { graphql } from 'gatsby';
33
import { MDXRenderer } from 'gatsby-plugin-mdx';
44
import { pascalCase } from 'change-case';
55
import { Layout } from '../components/layout';
6+
import { mapComponentName } from '../lib/constants';
67

78
const installation = ({ package: p }) =>
89
`npm install ${p}
@@ -11,6 +12,9 @@ yarn add ${p}`;
1112

1213
const ComponentPage = ({ data, pageContext }) => {
1314
const { frontmatter, body } = data.usage;
15+
if (frontmatter.category === mapComponentName) {
16+
return <MDXRenderer>{body}</MDXRenderer>;
17+
}
1418
return (
1519
<Layout>
1620
<div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build": "yarn workspace example build",
1414
"deploy": "yarn workspace gatsby-theme-woly publish",
1515
"theme": "yarn workspace gatsby-theme-woly",
16-
"example": "yarn workspace example",
16+
"example": "yarn workspace example start",
1717
"clean": "yarn example gatsby clean && yarn theme gatsby clean"
1818
},
1919
"workspaces": [

0 commit comments

Comments
 (0)