Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my inline image of markdown from cockpit cms is not transformed by gatsby-remark-image or by gatsby-remark-images-anywhere #52

Open
muhzulzidan opened this issue Mar 19, 2020 · 1 comment

Comments

@muhzulzidan
Copy link

my config :

module.exports = {
siteMetadata: {
title: muhzulzidan,
author: muhzulzidan,
description: A student,
siteUrl: https://muhzulzidan.com/,
social: {
twitter: muhzulzidan,
},
},
plugins: [
gatsby-plugin-react-helmet,
{
resolve: gatsby-source-filesystem,
options: {
name: images,
path: ${__dirname}/src/images,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'src',
path: ${__dirname}/src/,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'src',
path: ${__dirname}/public/static/,
},
},
my blog-post template :
import React from 'react'
import { graphql } from 'gatsby'
import Helmet from 'react-helmet'
import get from 'lodash/get'
// import Img from 'gatsby-image'
import Layout from '../components/layout'

class BlogPostTemplate extends React.Component {
render() {
const post = get(this.props, 'data.cockpitMarkdown.childMarkdownRemark')

const siteTitle = get(this.props, 'data.site.siteMetadata.title')

return (
  <Layout location={this.props.location}>
    <div style={{ background: '#fff' }}>
      <Helmet title={`${post.frontmatter.title} | ${siteTitle}`} />
      <div >
        {/* <Img
         
          alt={post.title.value}
          fluid={post.image.value.childImageSharp.fluid}
        /> */}
      </div>
      <div >
        <h1 >{post.frontmatter.title}</h1>
        <p
          style={{
            display: 'block',
          }}
        >
          {post.frontmatter.date}
        </p>
        <div
          dangerouslySetInnerHTML={{
            __html: post.html,
          }}
        />
      </div>
    </div>
  </Layout>
)

}
}

export default BlogPostTemplate

export const pageQuery = graphql`
query MyQuery ($slug: String!){
site {
siteMetadata {
title
}
}
cockpitMarkdown(childMarkdownRemark: {frontmatter: {slug: {eq:$slug }}}) {
childMarkdownRemark {
html
frontmatter {
slug
title
tags
date (formatString: "MMMM DD, YYYY")
}
}
}

}

`

and i get
Screenshot from 2020-03-19 17-10-56

@muhzulzidan
Copy link
Author

const copyFileToStaticFolder = ({ absolutePath, name, ext, internal }) => {
const localPath = path.join(
'/',
'static',
${name}-${internal.contentDigest}${ext}
)

// fs.copyFileSync(absolutePath, path.join(process.cwd(), 'public', localPath))
fs.copyFileSync(absolutePath, path.join(process.cwd(), 'static', localPath))

return localPath
}

btw by change your gastby-node.js to above and use gatsby remark image i can fix the issue

and i make this repo because i can't contact you... it may be better if you can just add a comment of it so we can choose to uncomment it iin the real repo

https://github.com/muhzulzidan/gatsby-source-cockpit-imgremarkanywhere-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant