Added markdown anchor support
This commit is contained in:
+2
-1
@@ -1,5 +1,6 @@
|
||||
import React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import MarkdownRenderers from "../utilities/markdown_renderers.js";
|
||||
|
||||
class About extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -29,7 +30,7 @@ class About extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<ReactMarkdown source={this.state.body} />
|
||||
<ReactMarkdown source={this.state.body} renderers={MarkdownRenderers} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import MarkdownRenderers from "../utilities/markdown_renderers.js";
|
||||
|
||||
class Landing extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -29,7 +30,7 @@ class Landing extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<ReactMarkdown source={this.state.body} />
|
||||
<ReactMarkdown source={this.state.body} renderers={MarkdownRenderers} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
import React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import MarkdownRenderers from "../utilities/markdown_renderers.js";
|
||||
|
||||
class Rules extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -29,7 +30,7 @@ class Rules extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<ReactMarkdown source={this.state.body} />
|
||||
<ReactMarkdown source={this.state.body} renderers={MarkdownRenderers} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from "react";
|
||||
|
||||
//https://github.com/rexxars/react-markdown/issues/69
|
||||
function headingRenderer(props) {
|
||||
function flatten(text, child) {
|
||||
return typeof child === 'string' ? text + child : React.Children.toArray(child.props.children).reduce(flatten, text);
|
||||
}
|
||||
|
||||
let children = React.Children.toArray(props.children);
|
||||
let text = children.reduce(flatten, '');
|
||||
let slug = text.toLowerCase().replace(/\W/g, '-');
|
||||
return React.createElement('h' + props.level, {id: slug}, props.children);
|
||||
}
|
||||
|
||||
export default {
|
||||
heading: headingRenderer
|
||||
};
|
||||
Reference in New Issue
Block a user