Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion plugins/docusaurus-plugin-ionic-component-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ function formatMultiline(str) {
return str.split('\n\n').join('<br /><br />').split('\n').join(' ');
}

function formatType(attr, type) {
if (attr === 'color') {
/**
* The `color` attribute has an additional type that we don't want to display.
* The union type is used to allow intellisense to recommend the color names,
* while still accepting any string value.
*/
type = type.replace('string & Record<never, never>', 'string');
}
return type.replace(/\|/g, '\uff5c');
}

function renderProperties({ props: properties }) {
if (properties.length === 0) {
return 'No properties available for this component.';
Expand All @@ -141,7 +153,7 @@ ${properties
| --- | --- |
| **Description** | ${formatMultiline(docs)} |
| **Attribute** | \`${prop.attr}\` |
| **Type** | \`${prop.type.replace(/\|/g, '\uff5c')}\` |
| **Type** | \`${formatType(prop.attr, prop.type)}\` |
| **Default** | \`${prop.default}\` |

`;
Expand Down