GithubHelp home page GithubHelp logo

Comments (10)

mxstbr avatar mxstbr commented on July 19, 2024 1

They're still .js files as far as I can tell 🤔

from styled-components-website.

SaraVieira avatar SaraVieira commented on July 19, 2024

I think this: https://www.npmjs.com/package/markdown-loader

Could be okay , it transforms stuff into html and then we can just import it on the page

from styled-components-website.

mxstbr avatar mxstbr commented on July 19, 2024

We can't just transform it to HTML though since we have React components in our markdown, that's why we use react-markings.

I think what we'd rather do is use wrapper-webpack-plugin to wrap each .md file with this boilerplate:

import md from 'components/md'

export default () => md`
  ${MARKDOWN_CONTENT}
`

What I'm unsure about after that is how we get webpack to treat these files as JavaScript, what they are at that point. 🤔

from styled-components-website.

SaraVieira avatar SaraVieira commented on July 19, 2024

But doing that would still have the problem with the escaping :(

from styled-components-website.

kitten avatar kitten commented on July 19, 2024

@kentcdodds has posted me a link to their loader on Twitter, which does what you're talking about. https://twitter.com/kentcdodds/status/902262231374716928

The problem with going down this route is that we also lose interpolations. Those are important to have some flexibility to what we can render: https://github.com/styled-components/styled-components-website/blob/master/sections/basics/motivation.js

We could also just try to find a different set of characters for code blocks? Albeit that being a bit clunky as well, I know 😆

from styled-components-website.

kentcdodds avatar kentcdodds commented on July 19, 2024

Also linked in that tweet thread: Custom markdown syntax for interpolations and the implementation.

I've considered making this a pluggable standalone project to clean up the implementation a bit. It's actually pretty great 😄

I think the core piece you want with next.js is a solution that works at the babel level rather than the webpack level. It'll make everything much snappier, especially with SSR and static extract. So you may also consider a simpler approach using something like babel-plugin-preval. Which would require a little more boilerplate, but would be pretty simple.

Good luck friends! Feel free to ping me if you need me for anything (I'm going to unsubscribe). I'm happy to help! 😄

from styled-components-website.

SaraVieira avatar SaraVieira commented on July 19, 2024

Guys! Isn't this already done?

from styled-components-website.

SaraVieira avatar SaraVieira commented on July 19, 2024

Mhmm, I'll check it out and paste a list here for easy changing

from styled-components-website.

mxstbr avatar mxstbr commented on July 19, 2024

I just found reactdown by @andreypopp which looks perfect for our purpose? https://www.npmjs.com/package/reactdown (he wrote that four years ago...) It's basically what we're using right now BUT let's your write your stuff as external .md files.

Also found https://github.com/mapbox/jsxtreme-markdown, which is similar but looks a bit more like a templating language, and https://github.com/cerebral/marksy#custom-components which seems similar to reactdown?

from styled-components-website.

imbhargav5 avatar imbhargav5 commented on July 19, 2024

This has been fixed by @mxstbr . We now use .md|.mdxfiles.

from styled-components-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.