Skip to content

Commit

Permalink
[part-10] Added frontmatter images for the designs
Browse files Browse the repository at this point in the history
- Added "uploads" folder to the filesystem sources
- Added image field to the NetlifyCMS config
- Removed general "public_folder" config and added it to collection itself to manually control image relative paths
- Added sample images to the "design"s
- Updated GraphQL query in the design detail template and added markup to represent images
  • Loading branch information
xkema committed Aug 19, 2022
1 parent de8f972 commit bdf33a0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions gatsby-config.js
Expand Up @@ -2,6 +2,13 @@

module.exports = {
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/uploads/`,
name: `uploads`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
Expand Down
1 change: 1 addition & 0 deletions src/content/designs/hello-from-design-01.md
Expand Up @@ -2,4 +2,5 @@
contentKey: design
title: hello from design 01
description: design 01 description
image: ../../../uploads/irene-kredenets-tcvh_bwhtrc-unsplash.jpg
---
1 change: 1 addition & 0 deletions src/content/designs/hello-from-design-02.md
Expand Up @@ -2,4 +2,5 @@
contentKey: design
title: hello from design 02
description: design 02 description
image: ../../../uploads/sarah-dorweiler-gupitdbdre4-unsplash.jpg
---
7 changes: 7 additions & 0 deletions src/templates/design-template.js
Expand Up @@ -14,6 +14,10 @@ const DesignTemplate = (props) => {
<h1>Design Content Template</h1>
<div>{props.data.markdownRemark.frontmatter.title}</div>
<div>{props.data.markdownRemark.frontmatter.description}</div>
<img
src={props.data.markdownRemark.frontmatter.image.publicURL}
alt={"Please always fill the alternative text attributes!"}
/>
</div>
</Layout>
)
Expand All @@ -28,6 +32,9 @@ export const query = graphql`
frontmatter {
title
description
image {
publicURL
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion static/admin/config.yml
Expand Up @@ -8,7 +8,6 @@ backend:
local_backend: true

media_folder: uploads
public_folder: /uploads

slug:
encoding: "ascii"
Expand All @@ -28,8 +27,10 @@ collections:
- name: designs
label: Designs
folder: "src/content/designs"
public_folder: ../../../uploads
create: true
fields:
- {label: "Content Key", name: "contentKey", widget: "hidden", default: "design", required: true}
- {label: "Title", name: "title", widget: "string"}
- {label: "Description", name: "description", widget: "text"}
- {label: "Image", name: "image", widget: "image", allow_multiple: false, choose_url: false}
Binary file added uploads/irene-kredenets-tcvh_bwhtrc-unsplash.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/sarah-dorweiler-gupitdbdre4-unsplash.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bdf33a0

Please sign in to comment.