-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: docs title tag #1942
Conversation
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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.
if (commonHeadings.includes(node.tagName)) { | |
if (commonHeadings.includes(node.tagName) && node.children && node.children.length > 0) { |
Copilot uses AI. Check for mistakes.
1155c8f
to
313d888
Compare
There was a problem hiding this 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 => { ... }) || {};
[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 |
No description provided.