jekyll-readme-index icon indicating copy to clipboard operation
jekyll-readme-index copied to clipboard

Support .github/README.md and add a configuration option to override

Open TomasHubelbauer opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe the problem you're trying to solve.

As far as I could tell from the source, this plugin looks for readme.md in the repository directory.

# Regexp to match a file path against to detect if the given file is a README
def readme_regex
  @readme_regex ||= %r!/readme(#{Regexp.union(markdown_converter.extname_list)})$!i
end

The regex starts with a slash so I think the README must be relative to the repository directory root.

GitHub has a feature where you can instruct the repository page rendering to use an alternative file from readme.md: .github/readme.md (as well as root/README.md and docs/README.md).

Describe the solution you'd like

I would like to suggest that this plugin considers these overrides and resolves them in the same order as GitHub does:

https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes

If you put your README file in your repository's hidden .github, root, or docs directory, GitHub will recognize and automatically surface your README to repository visitors.

If a repository contains more than one README file, then the file shown is chosen from locations in the following order: the .github directory, then the repository's root directory, and finally the docs directory.

On top of this, I would like to suggest a new configuration option that would allow overriding the README regex altogether.

Describe alternatives you've considered

I think one solution would be to just make the regex configurable alone without encoding the GitHub-specific README logic. That way people who need an alternative name for the README file would have a way to set that.

Additional context

If the regex is made configurable, there would be no way to define the resolution order if there were multiple candidate files. Ideally, I would like for this to be possible to define as well, but it feels like a bigger piece of work than might be worth doing.

TomasHubelbauer avatar May 28 '23 13:05 TomasHubelbauer