Netlify CMS & Gatsby loop
I am attempting to loop through a Netlify CMS list widget, and receiving a graphQL error on build specific to the changes I've added to support workTags
.
config.yml:
fields:
- {label: "Tags", name: "workTags", widget: list, required: false}
page render js:
import React from "react";
import Link from "gatsby-link";
import PropTypes from "prop-types";
import Content, { HTMLContent } from "../components/Content";
import { DemoAndRepo } from "../components/Work";
import styles from "../components/Work/styles/WorkPage.module.css";
export const WorkPageTemplate = ({
title,
description,
demo,
repo,
content,
contentComponent,
image,
workTags
}) => {
const PageContent = contentComponent || Content;
return (
<section className={"scene_element--fadein "}>
<h1>{title}</h1>
<div className={styles.content}>{description}</div>
<DemoAndRepo demo={demo} repo={repo} />
<div style={{ marginTop: '25px'}}>
<PageContent className="content" content={content} />
{workTags && workTags.length ? (
<div style={{ marginTop: `4rem` }}>
<h4>Tags</h4>
<ul className="taglist">
{workTags.map(tag => (
<li key={tag + `tag`}>
{tag}
</li>
))}
</ul>
</div>
) : null}
</div>
</section>
);
};
WorkPageTemplate.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
demo: PropTypes.string,
repo: PropTypes.string,
image: PropTypes.string,
content: PropTypes.string,
contentComponent: PropTypes.func,
workTags: PropTypes.string
};
const WorkPage = ({ data }) => {
const { markdownRemark: work } = data;
return (
<WorkPageTemplate
contentComponent={HTMLContent}
title={work.frontmatter.title}
description={work.frontmatter.description}
demo={work.frontmatter.demoUrl}
repo={work.frontmatter.repoUrl}
content={work.html}
image={work.frontmatter.image},
workTags={work.frontmatter.workTags}
/>
);
};
WorkPage.propTypes = {
data: PropTypes.object.isRequired
};
export default WorkPage;
export const workPageQuery = graphql`
query WorkPage($id: String!) {
markdownRemark(id: { eq: $id }) {
html
fields {
slug
}
frontmatter {
title
description
image
repoUrl
demoUrl
workTags
}
}
}
`;
loops gatsby netlify yaml-front-matter netlify-cms
add a comment |
I am attempting to loop through a Netlify CMS list widget, and receiving a graphQL error on build specific to the changes I've added to support workTags
.
config.yml:
fields:
- {label: "Tags", name: "workTags", widget: list, required: false}
page render js:
import React from "react";
import Link from "gatsby-link";
import PropTypes from "prop-types";
import Content, { HTMLContent } from "../components/Content";
import { DemoAndRepo } from "../components/Work";
import styles from "../components/Work/styles/WorkPage.module.css";
export const WorkPageTemplate = ({
title,
description,
demo,
repo,
content,
contentComponent,
image,
workTags
}) => {
const PageContent = contentComponent || Content;
return (
<section className={"scene_element--fadein "}>
<h1>{title}</h1>
<div className={styles.content}>{description}</div>
<DemoAndRepo demo={demo} repo={repo} />
<div style={{ marginTop: '25px'}}>
<PageContent className="content" content={content} />
{workTags && workTags.length ? (
<div style={{ marginTop: `4rem` }}>
<h4>Tags</h4>
<ul className="taglist">
{workTags.map(tag => (
<li key={tag + `tag`}>
{tag}
</li>
))}
</ul>
</div>
) : null}
</div>
</section>
);
};
WorkPageTemplate.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
demo: PropTypes.string,
repo: PropTypes.string,
image: PropTypes.string,
content: PropTypes.string,
contentComponent: PropTypes.func,
workTags: PropTypes.string
};
const WorkPage = ({ data }) => {
const { markdownRemark: work } = data;
return (
<WorkPageTemplate
contentComponent={HTMLContent}
title={work.frontmatter.title}
description={work.frontmatter.description}
demo={work.frontmatter.demoUrl}
repo={work.frontmatter.repoUrl}
content={work.html}
image={work.frontmatter.image},
workTags={work.frontmatter.workTags}
/>
);
};
WorkPage.propTypes = {
data: PropTypes.object.isRequired
};
export default WorkPage;
export const workPageQuery = graphql`
query WorkPage($id: String!) {
markdownRemark(id: { eq: $id }) {
html
fields {
slug
}
frontmatter {
title
description
image
repoUrl
demoUrl
workTags
}
}
}
`;
loops gatsby netlify yaml-front-matter netlify-cms
1
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16
add a comment |
I am attempting to loop through a Netlify CMS list widget, and receiving a graphQL error on build specific to the changes I've added to support workTags
.
config.yml:
fields:
- {label: "Tags", name: "workTags", widget: list, required: false}
page render js:
import React from "react";
import Link from "gatsby-link";
import PropTypes from "prop-types";
import Content, { HTMLContent } from "../components/Content";
import { DemoAndRepo } from "../components/Work";
import styles from "../components/Work/styles/WorkPage.module.css";
export const WorkPageTemplate = ({
title,
description,
demo,
repo,
content,
contentComponent,
image,
workTags
}) => {
const PageContent = contentComponent || Content;
return (
<section className={"scene_element--fadein "}>
<h1>{title}</h1>
<div className={styles.content}>{description}</div>
<DemoAndRepo demo={demo} repo={repo} />
<div style={{ marginTop: '25px'}}>
<PageContent className="content" content={content} />
{workTags && workTags.length ? (
<div style={{ marginTop: `4rem` }}>
<h4>Tags</h4>
<ul className="taglist">
{workTags.map(tag => (
<li key={tag + `tag`}>
{tag}
</li>
))}
</ul>
</div>
) : null}
</div>
</section>
);
};
WorkPageTemplate.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
demo: PropTypes.string,
repo: PropTypes.string,
image: PropTypes.string,
content: PropTypes.string,
contentComponent: PropTypes.func,
workTags: PropTypes.string
};
const WorkPage = ({ data }) => {
const { markdownRemark: work } = data;
return (
<WorkPageTemplate
contentComponent={HTMLContent}
title={work.frontmatter.title}
description={work.frontmatter.description}
demo={work.frontmatter.demoUrl}
repo={work.frontmatter.repoUrl}
content={work.html}
image={work.frontmatter.image},
workTags={work.frontmatter.workTags}
/>
);
};
WorkPage.propTypes = {
data: PropTypes.object.isRequired
};
export default WorkPage;
export const workPageQuery = graphql`
query WorkPage($id: String!) {
markdownRemark(id: { eq: $id }) {
html
fields {
slug
}
frontmatter {
title
description
image
repoUrl
demoUrl
workTags
}
}
}
`;
loops gatsby netlify yaml-front-matter netlify-cms
I am attempting to loop through a Netlify CMS list widget, and receiving a graphQL error on build specific to the changes I've added to support workTags
.
config.yml:
fields:
- {label: "Tags", name: "workTags", widget: list, required: false}
page render js:
import React from "react";
import Link from "gatsby-link";
import PropTypes from "prop-types";
import Content, { HTMLContent } from "../components/Content";
import { DemoAndRepo } from "../components/Work";
import styles from "../components/Work/styles/WorkPage.module.css";
export const WorkPageTemplate = ({
title,
description,
demo,
repo,
content,
contentComponent,
image,
workTags
}) => {
const PageContent = contentComponent || Content;
return (
<section className={"scene_element--fadein "}>
<h1>{title}</h1>
<div className={styles.content}>{description}</div>
<DemoAndRepo demo={demo} repo={repo} />
<div style={{ marginTop: '25px'}}>
<PageContent className="content" content={content} />
{workTags && workTags.length ? (
<div style={{ marginTop: `4rem` }}>
<h4>Tags</h4>
<ul className="taglist">
{workTags.map(tag => (
<li key={tag + `tag`}>
{tag}
</li>
))}
</ul>
</div>
) : null}
</div>
</section>
);
};
WorkPageTemplate.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
demo: PropTypes.string,
repo: PropTypes.string,
image: PropTypes.string,
content: PropTypes.string,
contentComponent: PropTypes.func,
workTags: PropTypes.string
};
const WorkPage = ({ data }) => {
const { markdownRemark: work } = data;
return (
<WorkPageTemplate
contentComponent={HTMLContent}
title={work.frontmatter.title}
description={work.frontmatter.description}
demo={work.frontmatter.demoUrl}
repo={work.frontmatter.repoUrl}
content={work.html}
image={work.frontmatter.image},
workTags={work.frontmatter.workTags}
/>
);
};
WorkPage.propTypes = {
data: PropTypes.object.isRequired
};
export default WorkPage;
export const workPageQuery = graphql`
query WorkPage($id: String!) {
markdownRemark(id: { eq: $id }) {
html
fields {
slug
}
frontmatter {
title
description
image
repoUrl
demoUrl
workTags
}
}
}
`;
loops gatsby netlify yaml-front-matter netlify-cms
loops gatsby netlify yaml-front-matter netlify-cms
edited Jan 1 at 3:49
Jason
asked Jan 1 at 3:38
JasonJason
5,1141062114
5,1141062114
1
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16
add a comment |
1
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16
1
1
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992874%2fnetlify-cms-gatsby-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992874%2fnetlify-cms-gatsby-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What is the error that you received? If you didn't provide a default in config.yml, the empty array won't be included in graphql
– Derek Nguyen
Jan 2 at 5:16