facebook / facebook/docusaurus

Allow README.md to be blog index file name

Đang mở
#7,871 5 bình luận 1 reaction 0 người được giao Xem trên GitHub
feature
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).

### Description

see `packages/docusaurus-plugin-content-blog/src/blogUtils.ts:146`:

```ts
const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
const slug = `/${text}`;
return {date: undefined, text, slug};
```

It's easy to add the support of rendering `index.md`, `readme.md`, etc. to be the index page if there are only one unique file (with these possible names) under a specific folder.

As far as I know, many blog framewroks support both `index.md` and `readme.md` to be rendered as the index page.

### Has this been requested on Canny?

_No response_

### Motivation

The github use the default `readme.md` (or `README.md`, which is case-insensitive) as the default rendered file.

Hence, there are a lot of projects (including blog) with their introduction file naming with `readme.md` rather than `index.md`.

So it would be quite delightful if we docusaurus can support this design.

### API design

I feel it OK with either an extra API field for our users to manually point out what index filename is the best, or just do a litter more work in our blogUtils logic, in order to translate the md file to slug accuarately.

### Have you tried building it?

_No response_

### Self-service

- [X] I'd be willing to contribute this feature to Docusaurus myself.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.