Skip to content

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

Merged
merged 3 commits into from
May 11, 2018
Merged

Conversation

montogeek
Copy link
Member

No description provided.

md.js Outdated
var visit = require('unist-util-visit');

module.exports = function getAnchors(content) {
let anchors = [];
Copy link
Member Author

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.

Copy link
Collaborator

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.

@montogeek
Copy link
Member Author

Will cleanup this branch

@skipjack skipjack changed the title feat(site) Anchors on sidebar chore(rebuild): re-incorporate anchor links Apr 15, 2018
@skipjack skipjack mentioned this pull request Apr 15, 2018
16 tasks
@skipjack
Copy link
Collaborator

skipjack commented Apr 15, 2018

Also, @montogeek let's abstract any newly created remark plugins to their own repos/packages and npm link them for testing. If you want to keep playing around with it locally for the meantime that's fine, but I'd like to do the extraction before we merge.

@@ -15,6 +15,8 @@ export default class Sidebar extends Component {
let { fixed, availableHeight, maxWidth } = this.state;
let group;

console.log(pages);
Copy link
Member

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?

@@ -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
Copy link
Collaborator

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.

require('remark-autolink-headings'),
require('remark-html'),
Copy link
Collaborator

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.
@skipjack skipjack merged commit 395e5b8 into rebuild May 11, 2018
@skipjack skipjack deleted the rebuild-anchors branch May 11, 2018 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants