-
Notifications
You must be signed in to change notification settings - Fork 249
Use JS instead of JSON for pages #434
Comments
Is there any progress on this? How close are we to being able to use react in md? I have a Link component I use to wrap anchor tags with styling + other stuff. Would love to be able to use it in markdown files. In the mean time, is there a way to catch the anchor tags in markdown files and replace with my own implementation? |
Some people did this by parsing the markdown in there react components, not using the loader preset. |
nope for me. pages need to be serialisable, we can think later about a markdown plugin that compiles the body to a serialised object that a component can use to make an element tree out of it. |
Pretty sure we need to address the "markdown to react" somehow. But if you have an idea to handle this using json, I am listening :) |
Is this in progress still? I want to be able to render a React component within markdown. Thanks :) |
Looking for the best way to integrate custom components in posts as well... |
v1 branch is getting support by default of markdown to react compo using remark + lowlight. |
Not an option, but we already have a solution for v1 to render markdown into a tree, so no more dangerousinnerhtml :) |
Pardon if I'm being ignorant here, but @MoOx how do we use this feature? Thanks, |
Still on the old version of phenomic, but I used cmichel.io's approach for solving the problem of custom components defined in the markdown files. Works well. |
Ok @haywirez that was a good starting point, thanks! I found this d3500ae in the meanwhile, appears to be a commit done by @MoOx which allows Is there a small example available (or perhaps a .md file that is being used somewhere) for how to use this feature from the .md file side? P.S. I would be happy to contribute to the documentation once figuring it out as it appears to be a common use case (I read about such missing features in static site generators e.g. on the Hackernews thread from where I discovered this lovely project in the first place 😄 ) + test("BodyRenderer accepts a map for components", () => {
+ const map = {
+ p: function View(props: Object) {
+ return <div>{props.children}</div>;
+ },
+ a: function Link(props: Object) {
+ return <a href={props.href} className="auto">{props.children}</a>;
+ }
+ };
+ expect(
+ renderJSX(
+ <BodyRenderer components={map}>
+ {{
+ t: "p",
+ p: { className: "test" },
+ c: [
+ {
+ t: "a",
+ p: { href: "http://test" },
+ c: "Link"
+ }
+ ]
+ }}
+ </BodyRenderer>
+ )
+ ).toMatchSnapshot();
+}); |
Forget the tree t/p/c thing as it's generated by markdown parser (in short: markdown is converted to a tree to avoid having to render raw html in react component). |
@MoOx what I am looking for is:
For example, this might be one page on the site: |
You can probably use markdown body for main content and use a custom section from the yaml header for other parts. |
Okay @MoOx , thanks! But what if I want to put a React component in the middle of the body somehow, like this: Water Company owns and operates regulated water utility and wastewater systems
in New Jersey, Delaware and Pennsylvania. The Company also operates water and
wastewater systems under contract on behalf of municipal and private clients in
New Jersey and Delaware. Middlesex Water has grown from a single water utility
to an enterprise with distinct business operating units meeting a full range of
residential, commercial, residential and municipal water and wastewater needs.
Through our affiliated companies we are delivering technical and management
capabilities that creatively address challenges such as aging infrastructure and
increasing regulatory pressures faced by municipalities, developers and small
system owners.
<Expandable>
<Title>See a map of our service territory</Title>
<Content>
<img src="require('./service-map.png')" />
</Content>
</Expandable>
We have two overall business segments:
* Regulated: The regulated business involves collecting, treating and
distributing water on a retail and wholesale basis to residential, commercial,
industrial and fire protection customers in parts of New Jersey and Delaware.
This segment also includes regulated wastewater systems in New Jersey,
Delaware and Pennsylvania.
* Non-Regulated: Non-regulated contract services includes the operation
and ... |
Please track #1104 |
Multiples reasons for that:
head
object (see Normalize head date (server: Date, client: string) #397)The text was updated successfully, but these errors were encountered: