Skip to content

feat: docs title tag #1942

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged

feat: docs title tag #1942

merged 1 commit into from
Apr 1, 2025

Conversation

zhanshuyou
Copy link
Contributor

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for a documentation title tag through beta tag functionality by parsing front matter in markdown files and updating markdown processing.

  • Uses gray-matter to extract front matter data from files.
  • Introduces a new MDX rehype plugin (getRehypeHeadingTagPlugin) to inject beta tag elements into heading tags.
  • Propagates the beta tag info through API reference and page components.

Reviewed Changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/restful.ts Updates file parsing to extract front matter data using gray-matter.
src/utils/mdx.ts Adds plugin to inject beta tag elements to markdown headings.
src/utils/apiReference.ts Integrates front matter parsing for API reference content.
src/types/docs.ts Extends the doc front matter type with a beta property.
src/pages/api-reference/restful/[version]/[...slug].tsx Uses the beta tag from front matter with the new MDX plugin.
src/pages/api-reference/[language]/[version]/[...slug].tsx Passes along beta tag info during markdown conversion.
Files not reviewed (3)
  • package.json: Language not supported
  • pnpm-lock.yaml: Language not supported
  • src/styles/docsStyle.less: Language not supported

src/utils/mdx.ts Outdated

return function (tree) {
visit(tree, 'element', (node, index, parent) => {
if (commonHeadings.includes(node.tagName)) {
Copy link
Preview

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

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

Accessing node.children[0] without verifying that node.children exists and is not empty can lead to runtime errors when processing headings with no children. Consider adding a check to ensure node.children[0] is defined before accessing its value.

Suggested change
if (commonHeadings.includes(node.tagName)) {
if (commonHeadings.includes(node.tagName) && node.children && node.children.length > 0) {

Copilot uses AI. Check for mistakes.

@zhanshuyou zhanshuyou force-pushed the feat/docs-title-tag branch from 1155c8f to 313d888 Compare April 1, 2025 09:53
@zhanshuyou zhanshuyou requested a review from Copilot April 1, 2025 09:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for a documentation title tag and beta tagging functionality.

  • Updates file processing functions in restful.ts and apiReference.ts to parse front matter using gray-matter.
  • Introduces a new MDX rehype plugin (getRehypeHeadingTagPlugin) to inject beta tags into headings.
  • Extends the DocFrontMatterType type with an optional beta property and adjusts static props in page components to pass the beta tag.

Reviewed Changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/utils/restful.ts Switches to using gray-matter for file content parsing and spreads front matter data into the API data list.
src/utils/mdx.ts Adds a new rehype plugin to modify heading tags by appending beta tag elements.
src/utils/apiReference.ts Mirrors the changes in restful.ts to process file content with gray-matter and spread front matter.
src/types/docs.ts Extends the DocFrontMatterType with an optional beta property.
src/pages/api-reference/restful/[version]/[...slug].tsx Removes redundant gray-matter processing and integrates the new rehype plugin using frontMatter.beta.
src/pages/api-reference/[language]/[version]/[...slug].tsx Passes betaTag to markdownToHtml to support beta tagging in the generated HTML.
Files not reviewed (3)
  • package.json: Language not supported
  • pnpm-lock.yaml: Language not supported
  • src/styles/docsStyle.less: Language not supported
Comments suppressed due to low confidence (1)

src/pages/api-reference/restful/[version]/[...slug].tsx:197

  • Ensure that the removal of gray-matter processing in this file does not bypass required extraction of front matter metadata that downstream code may depend on. Consider validating that the content provided in 'contentData' already contains the necessary front matter structure.
const { frontMatter, content } = contentData.find(v => { ... }) || {};

@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ThyeeZz, zhanshuyou

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhanshuyou zhanshuyou merged commit 2733e2a into preview Apr 1, 2025
1 check passed
@zhanshuyou zhanshuyou deleted the feat/docs-title-tag branch April 1, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants