github.com/Jeffail/benthos/v3@v3.65.0/website/src/theme/ComponentsByCategory/index.js (about) 1 import React from 'react'; 2 import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 3 4 import Tabs from '@theme/Tabs'; 5 import TabItem from '@theme/TabItem'; 6 7 import ComponentCard from '@theme/ComponentCard'; 8 9 let descriptions = { 10 inputs: [ 11 { 12 name: "Services", 13 description: "Inputs that consume from storage or message streaming services.", 14 }, 15 { 16 name: "Network", 17 description: "Inputs that consume directly from low level network protocols.", 18 }, 19 { 20 name: "AWS", 21 description: "Inputs that consume from Amazon Web Services products.", 22 }, 23 { 24 name: "GCP", 25 description: "Inputs that consume from Google Cloud Platform services.", 26 }, 27 { 28 name: "Azure", 29 description: "Inputs that consume from Microsoft Azure services.", 30 }, 31 { 32 name: "Social", 33 description: "Inputs that consume from social applications and services.", 34 }, 35 { 36 name: "Local", 37 description: "Inputs that consume from the local machine/filesystem.", 38 }, 39 { 40 name: "Utility", 41 description: "Inputs that provide utility by generating data or combining/wrapping other inputs.", 42 }, 43 ], 44 buffers: [ 45 { 46 name: "Windowing", 47 description: "Buffers that provide message windowing capabilities.", 48 }, 49 { 50 name: "Utility", 51 description: "Buffers that are intended for niche but general use.", 52 }, 53 ], 54 processors: [ 55 { 56 name: "Mapping", 57 description: "Processors that specialize in restructuring messages.", 58 }, 59 { 60 name: "Integration", 61 description: "Processors that interact with external services.", 62 }, 63 { 64 name: "Parsing", 65 description: "Processors that specialize in translating messages from one format to another.", 66 }, 67 { 68 name: "Composition", 69 description: "Higher level processors that compose other processors and modify their behavior.", 70 }, 71 { 72 name: "Utility", 73 description: "Processors that provide general utility or do not fit in another category.", 74 }, 75 ], 76 outputs: [ 77 { 78 name: "Services", 79 description: "Outputs that write to storage or message streaming services.", 80 }, 81 { 82 name: "Network", 83 description: "Outputs that write directly to low level network protocols.", 84 }, 85 { 86 name: "AWS", 87 description: "Outputs that write to Amazon Web Services products.", 88 }, 89 { 90 name: "GCP", 91 description: "Outputs that write to Google Cloud Platform services.", 92 }, 93 { 94 name: "Azure", 95 description: "Outputs that write to Microsoft Azure services.", 96 }, 97 { 98 name: "Social", 99 description: "Outputs that write to social applications and services.", 100 }, 101 { 102 name: "Local", 103 description: "Outputs that write to the local machine/filesystem.", 104 }, 105 { 106 name: "Utility", 107 description: "Outputs that provide utility by combining/wrapping other outputs.", 108 }, 109 ], 110 }; 111 112 function ComponentsByCategory(props) { 113 let {type} = props; 114 const context = useDocusaurusContext(); 115 const types = context.siteConfig.customFields.components[type]; 116 117 let summaries = descriptions[type] || []; 118 119 let categories = {}; 120 let categoryList = []; 121 for (let i = 0; i < summaries.length; i++) { 122 categoryList.push(summaries[i].name); 123 categories[summaries[i].name.toLowerCase()] = { 124 summary: summaries[i].description, 125 items: [], 126 } 127 } 128 129 for (let i = 0; i < types.length; i++) { 130 let cats = types[i].categories; 131 if ( Array.isArray(cats) ) { 132 for (let j = 0; j < cats.length; j++) { 133 let catLower = cats[j].toLowerCase(); 134 if ( categories[catLower] === undefined ) { 135 categoryList.push(catLower.charAt(0).toUpperCase() + catLower.slice(1)); 136 categories[catLower] = { 137 summary: "", 138 items: [types[i]], 139 }; 140 } else { 141 categories[catLower].items.push(types[i]); 142 } 143 } 144 } 145 } 146 147 return ( 148 <Tabs defaultValue={categoryList[0].toLowerCase()} values={categoryList.map((cat) => ( 149 { label: cat, value: cat.toLowerCase() } 150 ))}> 151 {categoryList.map((cat) => ( 152 <TabItem key={cat.toLowerCase()} value={cat.toLowerCase()}> 153 <p>{categories[cat.toLowerCase()].summary}</p> 154 {categories[cat.toLowerCase()].items.map((data, idx) => ( 155 <ComponentCard key={idx} type={type} component={data} /> 156 ))} 157 </TabItem> 158 ))} 159 </Tabs> 160 ); 161 } 162 163 export default ComponentsByCategory;