Skip to content

Commit

Permalink
Docusaurus: fix sidebars (#5689)
Browse files Browse the repository at this point in the history
* formatting

* create new re-usable platform category

* Docusaurus: Kapa.ai and OneTrust scripts (#5690)

* add actual sidebarconfigitem type

* linting
  • Loading branch information
jharrell committed Apr 10, 2024
1 parent 99bda3f commit 455c068
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 120 deletions.
29 changes: 28 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,34 @@ const config: Config = {
defaultLocale: 'en',
locales: ['en'],
},

scripts: [
// kapa.ai script
{
src: 'https://widget.kapa.ai/kapa-widget.bundle.js',
defer: true,
'data-website-id': '1b51bb03-43cc-4ef4-95f1-93288a91b560',
'data-project-name': 'Prisma',
'data-project-color': '#2D3748',
'data-project-logo': 'https://www.prisma.io/docs/ai_logo.png',
'data-button-text': 'Ask AI',
'data-modal-example-questions':
"How can I setup relations in my schema file?,What is the difference between the 'migrate dev' and 'db push' commands?,Which cache strategy should I use for my query with Prisma Accelerate?,How can I subscribe to database events with Prisma Pulse?",
'data-button-image': 'https://www.prisma.io/docs/ai_button.svg',
'data-button-text-color': '#71E8DF',
'data-button-bg-color': '#2D3748',
'data-button-border': '2px',
'data-button-border-color': '#71e8df',
'data-button-border-style': 'solid',
'data-button-box-shadow':
'drop-shadow(0px 0.724px 1.251px rgba(14, 18, 28, 0.02)) drop-shadow(0px 1.608px 2.909px rgba(14, 18, 28, 0.04)) drop-shadow(0px 2.793px 5.225px rgba(14, 18, 28, 0.06)) drop-shadow(0px 4.55px 8.671px rgba(14, 18, 28, 0.07)) drop-shadow(0px 7.485px 14.285px rgba(14, 18, 28, 0.08)) drop-shadow(0px 13.358px 24.966px rgba(14, 18, 28, 0.09)) drop-shadow(0px 33px 54px rgba(14, 18, 28, 0.07))',
},
// OneTrust Cookies Consent Notice start for prisma.io
{
src: 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js',
'data-document-language': 'true',
'data-domain-script': '22c2e2c0-3df0-4958-8672-1194370ee230',
},
],
presets: [
[
'classic',
Expand Down
234 changes: 115 additions & 119 deletions sidebars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';

// workaround suggested by Docusaurus team: https://github.com/facebook/docusaurus/issues/9902#issuecomment-1972125804
type SidebarConfig = SidebarsConfig[string];
type OnlyArray<Type> = Type extends unknown[] ? Type : never;
type SidebarItemConfigArray = OnlyArray<SidebarConfig>;
type SidebarItemConfig = SidebarItemConfigArray[number];

const platformCategory: SidebarItemConfig = {
type: 'category',
label: 'Platform',
collapsed: false,
collapsible: false,
items: [
'platform/index',
'platform/about',
{
type: 'category',
label: 'Concepts',
collapsed: false,
items: [{ type: 'autogenerated', dirName: '500-platform/20-concepts' }]
},
'platform/maturity-levels',
'platform/limits',
'platform/support',
{
type: 'category',
label: 'Platform CLI',
items: [{ type: 'autogenerated', dirName: '500-platform/60-platform-cli' }],
},
],
};

/**
* Creating a sidebar enables you to:
- create an ordered group of docs
Expand All @@ -14,17 +45,17 @@ const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
index: ['index'],
gettingStarted: [
{
type: "category",
{
type: 'category',
collapsed: false,
collapsible: false,
label: "Get Started",
label: 'Get Started',
items: [
"getting-started/index",
"getting-started/quickstart",
'getting-started/index',
'getting-started/quickstart',
{
type: "category",
label: "Set up Prisma ORM",
type: 'category',
label: 'Set up Prisma ORM',
collapsed: false,
items: [{
type: 'autogenerated',
Expand All @@ -35,131 +66,96 @@ const sidebars: SidebarsConfig = {
}
],
ormSidebar: [{
type: "category",
label: "ORM",
type: 'category',
label: 'ORM',
collapsed: false,
collapsible: false,
items: [
'orm/orm-index',
{
type: "category",
label: "Overview",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/050-overview',
}]
},
{
type: "category",
label: "Prisma Schema",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/100-prisma-schema'
}]
},
{
type: "category",
label: "Prisma Client",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/200-prisma-client'
}]
},
{
type: "category",
label: "Prisma Migrate",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/300-prisma-migrate'
}]
},
{
type: "category",
label: "Tools",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/400-tools'
}]
},
{
type: "category",
label: "Reference",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/500-reference'
}]
},
{
type: "category",
label: "More",
collapsed: false,
items : [{
type: 'autogenerated',
dirName: '200-orm/800-more'
}]
}
]}],
'orm/orm-index',
{
type: 'category',
label: 'Overview',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/050-overview',
}]
},
{
type: 'category',
label: 'Prisma Schema',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/100-prisma-schema'
}]
},
{
type: 'category',
label: 'Prisma Client',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/200-prisma-client'
}]
},
{
type: 'category',
label: 'Prisma Migrate',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/300-prisma-migrate'
}]
},
{
type: 'category',
label: 'Tools',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/400-tools'
}]
},
{
type: 'category',
label: 'Reference',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/500-reference'
}]
},
{
type: 'category',
label: 'More',
collapsed: false,
items: [{
type: 'autogenerated',
dirName: '200-orm/800-more'
}]
}
]
}],
accelerateSidebar: [
{
type: "category",
label: "Accelerate",
type: 'category',
label: 'Accelerate',
collapsed: false,
collapsible: false,
items: [{ type: 'autogenerated', dirName: '300-accelerate'}]
items: [{ type: 'autogenerated', dirName: '300-accelerate' }]
},
{
type: "category",
label: "Platform",
collapsed: false,
collapsible: false,
items: [
'platform/about',
'platform/maturity-levels',
'platform/limits',
'platform/support',
'platform/index',
{
type: "category",
collapsed: false,
label: "Concepts",
items: [{ type: 'autogenerated', dirName: '500-platform/20-concepts'}]
}
]
}
platformCategory,
],
pulseSidebar: [
pulseSidebar: [
{
type: "category",
label: "Pulse",
type: 'category',
label: 'Pulse',
collapsible: false,
collapsed: false,
items: [{ type: 'autogenerated', dirName: '400-pulse'}]
items: [{ type: 'autogenerated', dirName: '400-pulse' }]
},
{
type: "category",
label: "Platform",
collapsible: false,
collapsed: false,
items: [
'platform/about',
'platform/maturity-levels',
'platform/limits',
'platform/support',
'platform/index',
{
type: "category",
collapsed: false,
label: "Concepts",
items: [{ type: 'autogenerated', dirName: '500-platform/20-concepts'}]
}
]
}
platformCategory,
],
aboutSidebar: [{
type: 'autogenerated',
Expand Down

0 comments on commit 455c068

Please sign in to comment.