facebook / facebook/docusaurus

Support Level 1 title (H1) in table of contents

Đang mở
#11,041 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
feature status: needs triage
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#issues).

### Description

Currently, the setting `toc_min_heading_level` must be set to 2 or greater. In some markdown documents, it would be nice to a table of contents that includes level 1 (h1) titles. For example:

```
---
hide_title: true
---

# Part 1

## Part 1a

## Part 1b

# Part 2

## Part 2a

```

The default setting of `toc_min_heading_level=2` could be left unchanged, so this would have no effect any current setups (validation prevents trying to set `toc_min_headiner_level=1`). But it would enable the option to have a table of contents use level one headers as desired.

### Has this been requested on Canny?

_No response_

### Motivation

I often use level 1 titles on my markdown documents and it would be nice for them to be able to be included in the TOC.

### API design

_No response_

### Have you tried building it?

I took a quick pass and changed the validation to allow for setting `toc_min_heading_level=1` but it didn't change the generated table of contents. I poked around at packages/docusaurus-theme-common/src/utils/tocUtils.ts and it seemed like it should work for a min of 1 as well as higher, but that's as far as I got.

### Self-service

- [ ] 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.