1
0
mirror of synced 2025-12-23 03:44:00 -05:00

Unique headers for REST operation components (#34986)

This commit is contained in:
Hector Alfaro
2023-02-27 14:07:56 -05:00
committed by GitHub
parent 67d8cf54a1
commit d34829ed16
7 changed files with 91 additions and 29 deletions

View File

@@ -20,6 +20,7 @@ import { useVersion } from 'components/hooks/useVersion'
type Props = {
slug: string
operation: Operation
heading: string
}
const GHCLIKEY = 'ghcli'
@@ -41,7 +42,7 @@ function getLanguageHighlight(selectedLanguage: string) {
return selectedLanguage === JSKEY ? 'javascript' : 'curl'
}
export function RestCodeSamples({ operation, slug }: Props) {
export function RestCodeSamples({ operation, slug, heading }: Props) {
const { t } = useTranslation('products')
const { isEnterpriseServer } = useVersion()
@@ -228,7 +229,7 @@ export function RestCodeSamples({ operation, slug }: Props) {
return (
<>
<h3 className="mt-0 pt-0 h4" id={`${slug}--code-samples`}>
<a href={`#${slug}--code-samples`}>{`${t('rest.reference.code_samples')}`}</a>
<a href={`#${slug}--code-samples`}>{heading}</a>
</h3>
{/* Display an example selector if more than one example */}
@@ -299,11 +300,12 @@ export function RestCodeSamples({ operation, slug }: Props) {
</div>
{/* Response section */}
<h5
<div
className="mt-5 mb-2 h5"
dangerouslySetInnerHTML={{
__html: displayedExample.response.description || t('rest.reference.response'),
}}
></h5>
></div>
<div className="border rounded-1">
{displayedExample.response.schema ? (