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

feat: display title in frontmatter as heading fallback #1556

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Nov 5, 2024

Summary

Related Issue

close #1440

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Nov 5, 2024

Deploy Preview for aquamarine-blini-95325f ready!

Name Link
🔨 Latest commit 32abcfe
🔍 Latest deploy log https://app.netlify.com/sites/aquamarine-blini-95325f/deploys/6760e33faa3f9500089fdbdc
😎 Deploy Preview https://deploy-preview-1556--aquamarine-blini-95325f.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 91 (🟢 up 9 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@Timeless0911
Copy link
Contributor

Thanks, I think this should be an opt-in feature with documented.

@chenjiahan
Copy link
Member

@Timeless0911 This feature should be the default behavior as it does not introduce breaking changes. Do you have any concerns?

@Timeless0911
Copy link
Contributor

Timeless0911 commented Nov 14, 2024

@Timeless0911 This feature should be the default behavior as it does not introduce breaking changes. Do you have any concerns?

The behavior of automatically adding titles should be made optional with exclude options. Users may insert relevant titles by themselves through other slots or scripts, and we also need some ways to disable this behavior on some pages such as overview page.

@chenjiahan
Copy link
Member

Users may insert relevant titles by themselves through other slots or scripts,

This doesn't seem to be common. It's relatively rare for the page title to be different from the h1 heading. I prefer providing an option to opt-out rather than opt-in.

@Timeless0911
Copy link
Contributor

This doesn't seem to be common. It's relatively rare for the page title to be different from the h1 heading. I prefer providing an option to opt-out rather than opt-in.

Agreed. Providing an options is needed, and the default value can be true though.📌

@JounQin
Copy link
Contributor Author

JounQin commented Dec 16, 2024

I added an fallbackHeadingTitle themeConfig option.

Copy link
Contributor

@Timeless0911 Timeless0911 left a comment

Choose a reason for hiding this comment

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

LGTM

@Timeless0911 Timeless0911 enabled auto-merge (squash) December 16, 2024 15:42
@Timeless0911
Copy link
Contributor

I remember that in overview component, we deal title in a specific way, can you compatible with this case?

const overviewTitle = title || 'Overview';
return (
<div className="overview-index mx-auto px-8">
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between mb-10">
<h1 className="text-3xl leading-10 tracking-tight">{overviewTitle}</h1>
{/* Added search input */}
<SearchInput
query={query}
setQuery={setQuery}
searchRef={searchRef}
filterNameText={filterNameText}
filterPlaceholderText={filterPlaceholderText}
/>
</div>
{content}

@JounQin
Copy link
Contributor Author

JounQin commented Dec 17, 2024

I remember that in overview component, we deal title in a specific way, can you compatible with this case?

The title already reads frontmatter.title. I'm not sure what you expect to render.

Current:

---
overview: true
title: API Overview
---

# xxxx
image
---
overview: true
---

# xxxx
image

@Timeless0911
Copy link
Contributor

Timeless0911 commented Dec 17, 2024

In this case, I think we should avoid to render two H1 in content?

image

And what will be rendered if we write like below that without H1 xxxx

---
overview: true
title: API Overview
---

@JounQin
Copy link
Contributor Author

JounQin commented Dec 17, 2024

In this case, I think we should avoid to render two H1 in content?

I believe this is out of scope of this PR, the behavior doesn't change between it, so maybe a new PR for it is more suitable.

And what will be rendered if we write like below that without H1 xxxx

It doesn't change:

image

@Timeless0911
Copy link
Contributor

Oh I forget that Overview do not use docContent to render.

I think this PR is good enough to merge, thank you!

@Timeless0911 Timeless0911 merged commit 5309967 into web-infra-dev:main Dec 17, 2024
7 checks passed
@JounQin JounQin deleted the feat/heading_title branch December 17, 2024 04:32
@Timeless0911 Timeless0911 mentioned this pull request Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Use font awesome title: <title> as H1 heading if no H1 heading is added
3 participants