Skip to content

Commit

Permalink
update media config
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Brandão committed Jun 5, 2018
1 parent f1675e0 commit 427496f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/data/home/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"hello": "Hello world",
"image": "/static/media/cat.jpg"
"image": "/media/cat.jpg"
}
20 changes: 10 additions & 10 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import PropTypes from 'prop-types'
import Layout from '../components/layouts'

const IndexPage = ({ pathContext: { locale }, ...props }) => {
const { childHomeJson: data } = props.data.allFile.edges[0].node
const { node: data } = props.data.allHomeJson.edges[0]

return (
<Layout locale={locale}>
<div>{data.hello}</div>
<img alt="little cat" src={data.fields.image.publicURL} />
{data.fields.image && (
<img alt="little cat" src={data.fields.image.publicURL} />
)}
</Layout>
)
}

export const query = graphql`
query HomeContent($locale: String) {
allFile(filter: { name: { eq: $locale } }) {
allHomeJson(filter: { fields: { locale: { eq: $locale } } }) {
edges {
node {
childHomeJson {
hello
fields {
image {
publicURL
}
id
fields {
image {
publicURL
}
}
}
Expand All @@ -37,7 +37,7 @@ IndexPage.propTypes = {
pathContext: PropTypes.shape({
locale: PropTypes.string.isRequired,
}).isRequired,
data: PropTypes.shape({ allFile: PropTypes.object }).isRequired,
data: PropTypes.shape({ allHomeJson: PropTypes.object }).isRequired,
}

export default IndexPage
3 changes: 2 additions & 1 deletion static/admin/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ backend:
repo: pbrandone/netlify-cms-i18n
branch: master # Branch to update

media_folder: "static/media/"
media_folder: static/media
public_folder: /media

collections:
- label: "Pages"
Expand Down

0 comments on commit 427496f

Please sign in to comment.