@mdguggenbichler/slugbase-core 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Documentation URLs at docs.slugbase.app.
3
+ * Paths differ by mode: selfhosted (/selfhosted/...) vs cloud (/cloud/...).
4
+ */
5
+ import { isCloud } from './mode';
6
+
7
+ const DOCS_BASE = 'https://docs.slugbase.app';
8
+
9
+ /** URL to the API Reference section (selfhosted or cloud). */
10
+ export function getDocsApiReferenceUrl(): string {
11
+ const path = isCloud ? 'cloud/api-reference' : 'selfhosted/api-reference';
12
+ return `${DOCS_BASE}/${path}`;
13
+ }
14
+
15
+ /** URL to docs home/overview (selfhosted intro or cloud overview). */
16
+ export function getDocsBaseUrl(): string {
17
+ const path = isCloud ? 'cloud/overview' : 'selfhosted/intro';
18
+ return `${DOCS_BASE}/${path}`;
19
+ }
@@ -1,6 +1,8 @@
1
1
  /**
2
- * SlugBase frontend runtime mode is self-hosted only.
2
+ * SlugBase frontend runtime mode: self-hosted or cloud.
3
+ * Derived from VITE_SLUGBASE_MODE at build time (cloud builds set it to 'cloud').
3
4
  */
4
- export const mode: 'selfhosted' = 'selfhosted';
5
- export const isCloud = false;
6
- export const isSelfhosted = true;
5
+ const buildMode = import.meta.env.VITE_SLUGBASE_MODE === 'cloud' ? 'cloud' : 'selfhosted';
6
+ export const mode: 'selfhosted' | 'cloud' = buildMode;
7
+ export const isCloud = buildMode === 'cloud';
8
+ export const isSelfhosted = !isCloud;
@@ -14,6 +14,7 @@ import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter }
14
14
  import { Badge } from '../components/ui/badge';
15
15
  import { Input } from '../components/ui/input';
16
16
  import api from '../api/client';
17
+ import { getDocsApiReferenceUrl } from '../config/docs';
17
18
 
18
19
  interface ApiToken {
19
20
  id: string;
@@ -58,7 +59,7 @@ function SettingsRow({
58
59
 
59
60
  export default function Profile() {
60
61
  const { t } = useTranslation();
61
- const { pathPrefixForLinks, apiBaseUrl } = useAppConfig();
62
+ const { pathPrefixForLinks } = useAppConfig();
62
63
  const prefix = (pathPrefixForLinks || '').replace(/\/+/g, '/') || '';
63
64
  const { user, updateUser, checkAuth } = useAuth();
64
65
  const { showToast } = useToast();
@@ -510,7 +511,7 @@ export default function Profile() {
510
511
  </p>
511
512
  </div>
512
513
  <a
513
- href={apiBaseUrl ? `${apiBaseUrl}/api-docs` : '/api-docs'}
514
+ href={getDocsApiReferenceUrl()}
514
515
  target="_blank"
515
516
  rel="noopener noreferrer"
516
517
  className="text-sm font-medium text-primary hover:text-primary/90 inline-block"
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
  import api from '../api/client';
5
5
  import { useAppConfig } from '../contexts/AppConfigContext';
6
6
  import Button from '../components/ui/Button';
7
+ import { getDocsBaseUrl } from '../config/docs';
7
8
 
8
9
  const MIN_PASSWORD_LENGTH = 8;
9
10
 
@@ -162,11 +163,11 @@ export default function Signup() {
162
163
  />
163
164
  <label htmlFor="signup-accept-terms" className="text-sm text-gray-700 dark:text-gray-300">
164
165
  {t('signup.acceptTermsPrefix')}
165
- <a href="https://docs.slugbase.app" target="_blank" rel="noopener noreferrer" className="text-blue-600 dark:text-blue-400 hover:underline">
166
+ <a href={getDocsBaseUrl()} target="_blank" rel="noopener noreferrer" className="text-blue-600 dark:text-blue-400 hover:underline">
166
167
  {t('signup.acceptTermsTerms')}
167
168
  </a>
168
169
  {t('signup.acceptTermsAnd')}
169
- <a href="https://docs.slugbase.app" target="_blank" rel="noopener noreferrer" className="text-blue-600 dark:text-blue-400 hover:underline">
170
+ <a href={getDocsBaseUrl()} target="_blank" rel="noopener noreferrer" className="text-blue-600 dark:text-blue-400 hover:underline">
170
171
  {t('signup.acceptTermsPrivacy')}
171
172
  </a>
172
173
  {t('signup.acceptTermsSuffix')}
@@ -1,6 +1,7 @@
1
1
  import { useTranslation } from 'react-i18next';
2
2
  import { Outlet } from 'react-router-dom';
3
3
  import { ExternalLink } from 'lucide-react';
4
+ import { getDocsApiReferenceUrl } from '../../config/docs';
4
5
 
5
6
  export default function AdminLayout() {
6
7
  const { t } = useTranslation();
@@ -25,7 +26,7 @@ export default function AdminLayout() {
25
26
  </p>
26
27
  </div>
27
28
  <a
28
- href="/api-docs"
29
+ href={getDocsApiReferenceUrl()}
29
30
  target="_blank"
30
31
  rel="noopener noreferrer"
31
32
  className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-primary hover:text-primary/90 transition-colors"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdguggenbichler/slugbase-core",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "SlugBase core: backend and frontend entrypoints for self-hosted and cloud apps",
5
5
  "type": "module",
6
6
  "exports": {