Skip to content

Commit 32cb9d6

Browse files
docs: Add a new SDKs menu to the website (#4107)
* docs: Add a new SDKs menu to the website Signed-off-by: Thomas Poignant <[email protected]> * no need for html anymore Signed-off-by: Thomas Poignant <[email protected]> * move plugin Signed-off-by: Thomas Poignant <[email protected]> * remove all AI generated code that I don't use :D Signed-off-by: Thomas Poignant <[email protected]> --------- Signed-off-by: Thomas Poignant <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 8909ed2 commit 32cb9d6

File tree

3 files changed

+86
-11
lines changed

3 files changed

+86
-11
lines changed

website/docusaurus.config.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const {sdk} = require('./data/sdk');
55
const lightCodeTheme = require('prism-react-renderer').themes.github;
66
const darkCodeTheme = require('prism-react-renderer').themes.dracula;
7+
const {generateSdksDropdownHTML} = require('./src/components/navbar/sdks');
78

89
/** @type {import("@docusaurus/types").Config} */
910
const config = {
@@ -196,17 +197,7 @@ const config = {
196197
],
197198
},
198199
],
199-
async function myPlugin(context, options) {
200-
return {
201-
name: 'docusaurus-tailwindcss',
202-
configurePostCss(postcssOptions) {
203-
// Appends TailwindCSS and AutoPrefixer.
204-
postcssOptions.plugins.push(require('tailwindcss'));
205-
postcssOptions.plugins.push(require('autoprefixer'));
206-
return postcssOptions;
207-
},
208-
};
209-
},
200+
require('./plugins/tailwind-plugin.cjs'),
210201
],
211202

212203
customFields: {
@@ -292,6 +283,18 @@ const config = {
292283
src: 'img/logo/navbar.png',
293284
},
294285
items: [
286+
{
287+
label: 'SDKs',
288+
type: 'dropdown',
289+
className: 'dyte-dropdown',
290+
items: [
291+
{
292+
type: 'html',
293+
value: generateSdksDropdownHTML(),
294+
className: 'dyte-dropdown',
295+
},
296+
],
297+
},
295298
{
296299
position: 'left',
297300
label: 'Product',
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function tailwindPlugin(context, options) {
2+
return {
3+
name: "tailwind-plugin",
4+
configurePostCss(postcssOptions) {
5+
postcssOptions.plugins = [
6+
require("postcss-import"),
7+
require("tailwindcss/nesting"),
8+
require("tailwindcss"),
9+
require("autoprefixer"),
10+
];
11+
return postcssOptions;
12+
},
13+
};
14+
}
15+
16+
module.exports = tailwindPlugin;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {sdk} from '../../../data/sdk.js';
2+
3+
// Function to generate HTML string for SDKs dropdown
4+
export function generateSdksDropdownHTML() {
5+
const clientSdks = sdk.filter(s => s.paradigm.includes('Client'));
6+
const serverSdks = sdk.filter(s => s.paradigm.includes('Server'));
7+
8+
const generateSdkSection = sectionItem => {
9+
return `
10+
<section class="flex flex-col gap-3 mb-5">
11+
<div class="text-center lg:text-left">
12+
<h3 class="text-2xl font-poppins font-[800] tracking-[-0.08rem] mb-0">
13+
${sectionItem.title}
14+
</h3>
15+
<p class="text-xs text-gray-400 font-poppins font-[400] leading-8 mb-0">
16+
${sectionItem.description}
17+
</p>
18+
</div>
19+
20+
<div class="inline-flex flex-wrap gap-2">
21+
${sectionItem.sdks.map(sdkItem => generateSdkCard(sdkItem)).join('')}
22+
</div>
23+
</section>
24+
`;
25+
};
26+
27+
const generateSdkCard = sdkItem => {
28+
return `
29+
<a
30+
href="/docs/sdk/${sdkItem.docLink}"
31+
class="no-underline hover:no-underline inline-flex items-center gap-x-1.5 py-1.5 px-3 rounded-lg text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-800/30 dark:text-blue-500"
32+
>
33+
<i class="${sdkItem.faLogo} text-xl"></i>
34+
${sdkItem.name}
35+
</a>
36+
`;
37+
};
38+
39+
return `
40+
<div class="sdks-dropdown flex max-w-4xl flex-col rounded-2xl lg:min-w-[600px]">
41+
<div class="flex flex-col bg-secondary-800lg:min-h-[300px]">
42+
${generateSdkSection({
43+
title: 'Client SDKs',
44+
description:
45+
'Use feature flags in your web or mobile applications with these SDKs.',
46+
sdks: clientSdks,
47+
})}
48+
${generateSdkSection({
49+
title: 'Server SDKs',
50+
description:
51+
'Use feature flags in your backend applications with these SDKs.',
52+
sdks: serverSdks,
53+
})}
54+
</div>
55+
`;
56+
}

0 commit comments

Comments
 (0)