Skip to content
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

Add ability to set title options #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const title = require('title')
const visit = require('unist-util-visit')

module.exports = () => (tree, file) => {
module.exports = (options) => () => (tree, file) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it should be

module.exports = (options) => (tree, file) => {

no extra function needed

even though no one seems to notice this PR 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I patched node_modules locally and it appears Max's original solution works as intended! 🎉

Copy link
Member

@leerob leerob Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone in the future stumbling onto this, you can use patch-package to get this working.

visit(tree, 'heading', node => {
visit(node, 'text', textNode => {
const text = textNode.value ? textNode.value.trim() : ''
textNode.value = title(text)
textNode.value = title(text, options)
})
})
}