mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-31 15:57:30 +03:00 
			
		
		
		
	fix: add id attr to headers to work before react is loaded if ssr
This commit is contained in:
		
							parent
							
								
									7eb477b9de
								
							
						
					
					
						commit
						174345399f
					
				|  | @ -59,11 +59,12 @@ export class ContentItem extends React.Component<ContentItemProps> { | |||
| export class TagItem extends React.Component<ContentItemProps> { | ||||
|   render() { | ||||
|     const { name, description } = this.props.item; | ||||
|     const hash = this.props.item.getHash(); | ||||
|     return ( | ||||
|       <Row> | ||||
|         <MiddlePanel key="middle"> | ||||
|           <H1> | ||||
|             <ShareLink href={'#' + this.props.item.getHash()} /> | ||||
|           <H1 id={hash}> | ||||
|             <ShareLink href={'#' + hash} /> | ||||
|             {name} | ||||
|           </H1> | ||||
|           {description !== undefined && <Markdown source={description} />} | ||||
|  |  | |||
|  | @ -44,12 +44,12 @@ export class Operation extends ComponentWithOptions<OperationProps> { | |||
| 
 | ||||
|     const { name: summary, description, deprecated } = operation; | ||||
|     const pathInMiddle = this.options.pathInMiddlePanel; | ||||
| 
 | ||||
|     const hash = operation.getHash(); | ||||
|     return ( | ||||
|       <OperationRow> | ||||
|         <MiddlePanel> | ||||
|           <H2> | ||||
|             <ShareLink href={'#' + operation.getHash()} /> | ||||
|           <H2 id={hash}> | ||||
|             <ShareLink href={'#' + hash} /> | ||||
|             {summary} {deprecated && <Badge type="warning"> Deprecated </Badge>} | ||||
|           </H2> | ||||
|           {pathInMiddle && <Endpoint operation={operation} inverted={true} />} | ||||
|  |  | |||
|  | @ -82,7 +82,7 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> { | |||
|       <div> | ||||
|         {this.props.securitySchemes.schemes.map(scheme => ( | ||||
|           <div data-section-id={scheme.sectionId} key={scheme.id}> | ||||
|             <H2> | ||||
|             <H2 id={scheme.sectionId}> | ||||
|               <ShareLink href={'#' + scheme.sectionId} /> | ||||
|               {scheme.id} | ||||
|             </H2> | ||||
|  |  | |||
|  | @ -90,14 +90,14 @@ export class MarkdownRenderer { | |||
|         let id = this.currentTopHeading.id; | ||||
|         return ( | ||||
|           `<a name="${id}"></a>` + | ||||
|           `<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}">` + | ||||
|           `<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` + | ||||
|           `<a class="share-link" href="#${id}"></a>` | ||||
|         ); | ||||
|       } else if (tokens[idx].hLevel === 2) { | ||||
|         let { id } = this.saveHeading(content, this.currentTopHeading.items); | ||||
|         return ( | ||||
|           `<a name="${id}"></a>` + | ||||
|           `<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}">` + | ||||
|           `<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` + | ||||
|           `<a class="share-link" href="#${id}"></a>` | ||||
|         ); | ||||
|       } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user