stack/docs/lib/platform-config.ts
Madison d0173af691
[Docs][Content] Github install, UI changes, platform selection (#1098)
## Summary

This PR improves the documentation for GitHub authentication setup and
self-hosting.

## Changes

### GitHub OAuth/App Setup Guide
- Updated
[github.mdx](cci:7://file:///Users/madison/source/stack-auth/docs/content/docs/%28guides%29/concepts/auth-providers/github.mdx:0:0-0:0)
with clearer instructions differentiating between **GitHub OAuth App**
and **GitHub App** setup
- Added better explanations for when to use each option

### Self-Hosting Documentation
- Added prominent danger warning about self-hosting responsibilities
- Migrated inline shell commands to structured code examples using
[PlatformCodeblock](cci:1://file:///Users/madison/source/stack-auth/docs/src/components/mdx/platform-codeblock.tsx:242:0-673:1)
component
- Created
[docs/code-examples/self-host.ts](cci:7://file:///Users/madison/source/stack-auth/docs/code-examples/self-host.ts:0:0-0:0)
with all self-hosting commands

### Info Component
- Added new `danger` type for critical warnings with red accent styling
- Updated component styling with modern left accent bar and gradient
backgrounds

### PlatformCodeblock Component
- Added `hidePlatformSelector` prop to hide platform dropdown for
single-platform code examples
- Added Shell platform support for terminal commands (Docker, Git, pnpm)
- Filtered Shell platform from user-selectable options in both the
codeblock and header selectors

### Platform Config
- Added Shell platform with Docker, Git, and pnpm frameworks

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added comprehensive self-hosting and authentication customization
example collections for copy-paste use.
  * New "danger" info style with visual accent for important warnings.

* **Documentation**
* GitHub integration guide now centers on GitHub App with an alternate
OAuth path retained.
* Replaced many inline snippets with platform-driven code blocks and
improved platform/framework selector behavior (single-platform
optimization; option to hide selector).
  * Pages now surface "Last updated" above descriptions.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-20 11:49:08 -06:00

84 lines
2.2 KiB
TypeScript

/**
* Global Platform Configuration
*
* This file defines all supported platforms and frameworks across the documentation.
* This ensures consistency between code examples, platform selectors, and the header indicator.
*/
export type PlatformName = 'JavaScript' | 'Python' | 'Shell';
export type FrameworkName = string;
export type PlatformConfig = {
name: PlatformName,
frameworks: FrameworkName[],
defaultFramework: FrameworkName,
}
/**
* All supported platforms and their frameworks
* Order matters - first platform/framework will be the default
*/
export const PLATFORMS: PlatformConfig[] = [
{
name: 'JavaScript',
frameworks: ['Next.js', 'React', 'Express', 'Node.js', 'Vanilla JavaScript'],
defaultFramework: 'Next.js',
},
{
name: 'Python',
frameworks: ['Django', 'FastAPI', 'Flask'],
defaultFramework: 'Django',
},
{
name: 'Shell',
frameworks: ['Docker', 'Git', 'pnpm'],
defaultFramework: 'Docker',
},
];
/**
* Default platform to select when no selection exists
*/
export const DEFAULT_PLATFORM: PlatformName = 'JavaScript';
export const DEFAULT_FRAMEWORK = 'Next.js';
/**
* Get all platform names
*/
export function getAllPlatformNames(): PlatformName[] {
return PLATFORMS.map(p => p.name);
}
/**
* Get frameworks for a specific platform
*/
export function getFrameworksForPlatform(platform: PlatformName): FrameworkName[] {
const config = PLATFORMS.find(p => p.name === platform);
return config?.frameworks ?? [];
}
/**
* Get default framework for a platform
*/
export function getDefaultFrameworkForPlatform(platform: PlatformName): FrameworkName {
const config = PLATFORMS.find(p => p.name === platform);
return config?.defaultFramework ?? '';
}
/**
* Check if a platform/framework combination is valid
*/
export function isValidPlatformFramework(platform: string, framework: string): boolean {
const config = PLATFORMS.find(p => p.name === platform);
if (!config) return false;
return config.frameworks.includes(framework);
}
/**
* Get platform config by name
*/
export function getPlatformConfig(platform: PlatformName): PlatformConfig | undefined {
return PLATFORMS.find(p => p.name === platform);
}