-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
chore(rebuild): re-incorporate anchor links #2041
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
Conversation
md.js
Outdated
var visit = require('unist-util-visit'); | ||
|
||
module.exports = function getAnchors(content) { | ||
let anchors = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first attempt to write a plugin for remark, not 100% sure if it the best approach. I tried to search for examples doing something similar without luck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can give you a really simple one I wrote for replacing text within nodes as an example. Docs-wise you should start here though:
https://github.com/unifiedjs/unified#plugin
And I bet @wooorm would answer any questions you have (I'll do my best as well). I think what you have is pretty close, and you should add an option to allow selection of header levels. Then we can use this within the DirectoryTreePlugin
enhance
option to enrich each markdown node with the anchor links we need.
We'll need to synchronize this with #2043. Not sure what the best approach is off the top of my head. Might make sense to make these changes in the same PR.
Will cleanup this branch |
Also, @montogeek let's abstract any newly created |
src/components/Sidebar/Sidebar.jsx
Outdated
@@ -15,6 +15,8 @@ export default class Sidebar extends Component { | |||
let { fixed, availableHeight, maxWidth } = this.state; | |||
let group; | |||
|
|||
console.log(pages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, right?
src/components/Page/Page.jsx
Outdated
@@ -71,7 +71,7 @@ class Page extends React.Component { | |||
if ( this.props.content instanceof Promise ) { | |||
this.props.content | |||
.then(content => this.setState({ | |||
content | |||
content: content.default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be dropped as well since it was addressed on rebuild
.
webpack.common.js
Outdated
require('remark-autolink-headings'), | ||
require('remark-html'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remark-html
should be dropped as the remark-loader
already includes it at the end of the chain.
@montogeek started this work, I just rebased on the latest `rebuild` and cleaned things up slightly. I also renamed the misspelled enhancer utility.
No description provided.