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

Read the document title from file.data.title #14

Closed
4 tasks done
Delapouite opened this issue May 11, 2023 · 2 comments
Closed
4 tasks done

Read the document title from file.data.title #14

Delapouite opened this issue May 11, 2023 · 2 comments
Labels
💪 phase/solved Post is done

Comments

@Delapouite
Copy link

Initial checklist

Problem

Hi

Currently the title of the document is assigned like this:

const title = options.title || file.stem

There are a few situations where this value, may have been extracted/computed upstream in the processor.

  • by reading the #+title: keyword if starting from an Org document
  • by looking at the unique h1 element if starting from HTML document

Therefore, it would be great if this plugin would also have a look at data aggregated on the vfile.

Solution

If this is ok with you, I can prepare a PR with the following change and the associated documentation:

const title = options.title || file.data.title || file.stem

Thanks.

Alternatives

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 11, 2023
@wooorm
Copy link
Member

wooorm commented May 11, 2023

Yeah, good idea I think.
rehype-meta supports this too: https://github.com/rehypejs/rehype-meta#title
It configures from file.data.meta: https://github.com/rehypejs/rehype-meta#title

This is also populated by https://github.com/rehypejs/rehype-infer-title-meta

So I think I'd prefer a little more privacy with file.data.meta, but otherwise good! 👍

@wooorm
Copy link
Member

wooorm commented Sep 1, 2023

@wooorm wooorm closed this as completed Sep 1, 2023
@wooorm wooorm added the 💪 phase/solved Post is done label Sep 1, 2023
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants