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

Loading markdown #3025

Closed
kennetpostigo opened this issue Aug 29, 2017 · 2 comments
Closed

Loading markdown #3025

kennetpostigo opened this issue Aug 29, 2017 · 2 comments

Comments

@kennetpostigo
Copy link

kennetpostigo commented Aug 29, 2017

Hey,

So I'm building a simple doc site at the moment and using CRA for this. I'm using react-markdown which depends on json-loader to do it's job. json-loader is enabled by default in webpack 2+ so CRA should work without a problem, but instead of printing the contents as it should I get the following printed out:
/static/media/path.e4d613b6.md

thats the path to the markdown file.

This is the code importing the markdown:

const loadMd = m => {
  var Markdown = asyncMarkdown(() =>
    import(`./../markdown/${m}.md`).then(
      module => console.log(module),
      err => console.log(err)
    )
  );
  return <loadMd />;
};

function Content(props) {
  return (
    <div>
      {loadMd("path")}
    </div>
  );
}

I've used this same code and it works outside of CRA so I'm not exactly sure why it is loading the path now instead of the content. Any clues?

@viankakrisna
Copy link
Contributor

Hi! You can use fetch instead of dynamic import to read the contents of the file. Read more here #2961 (comment)

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

New thoughts on how we could handle this: #3722.

@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants