CodeSamplePanel
Domain · API DocAPI kod örneklerini koyu arka planlı panel içinde gösterir. İlk örnek açık, diğerleri details/summary ile erişilebilir.
cURL
JavaScript
curl -X GET https://api.example.com/users \
-H 'Authorization: Bearer <token>'
<%- include('modules/domain/api-doc/CodeSamplePanel', {
samples: [
{ lang: 'curl', label: 'cURL', source: "curl -X GET https://api.example.com/users \
-H 'Authorization: Bearer '" },
{ lang: 'javascript', label: 'JavaScript', source: "const res = await fetch('/users', { headers: { Authorization: 'Bearer ' } });" },
]
}) %>
<%
var _samples = locals.samples || [];
if (!_samples.length) { return; }
%>
<% _samples.forEach(function(s, i) { %>
<%= s.label || s.lang %>
<% }); %>
<% _samples.forEach(function(s, i) { %>
<% if (i === 0) { %>
<%= s.source %>
<% } else { %>
<%= s.label || s.lang %>
<%= s.source %>
<% } %>
<% }); %>