Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

feat(app): send docs links to the public site

spacesdrivea4586ad957ea
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index bf9a200..15d6b51 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -8,7 +8,7 @@ import { AppProvider } from './context/AppContext';
import ProtectedRoute from './components/ProtectedRoute';
import MainLayout from './layout/index';
import Login from './pages/Login';
-import { docsChildRoutes } from './docs/routes';
+import DocsRedirect from './components/DocsRedirect';
const Overview = lazy(() => import('./features/analytics/overview/Overview'));
const ChannelAnalytics = lazy(() => import('./features/analytics/channel/ChannelAnalytics'));
@@ -24,7 +24,6 @@ const RedditPosts = lazy(() => import('./features/analytics/reddit/Reddit
const RedditPostsAll = lazy(() => import('./features/analytics/reddit/RedditPostsAll'));
const TrackedContent = lazy(() => import('./features/analytics/tracked/TrackedContent'));
const TrackedCategory = lazy(() => import('./features/analytics/tracked/TrackedCategory'));
-const DocsLayout = lazy(() => import('./docs/DocsLayout'));
const router = createBrowserRouter([
{
@@ -32,9 +31,8 @@ const router = createBrowserRouter([
element: <Login />,
},
{
- path: '/docs',
- element: <DocsLayout />,
- children: docsChildRoutes,
+ path: '/docs/*',
+ element: <DocsRedirect />,
},
{
path: '/',
diff --git a/frontend/src/components/CommandPalette.tsx b/frontend/src/components/CommandPalette.tsx
index dd48749..bf614ba 100644
--- a/frontend/src/components/CommandPalette.tsx
+++ b/frontend/src/components/CommandPalette.tsx
@@ -15,6 +15,7 @@ import { accountName, accountPath, PLATFORM_META, platformOf } from '@/lib/accou
import type { AccountFields } from '@/lib/accounts';
import type { SearchCommand } from '@/lib/commandSearch';
import { NAV_GROUPS } from '@/layout/navigation';
+import { docsUrl } from '@/lib/docs';
const PAGE_ICONS: Record<string, LucideIcon> = {
'/': LayoutDashboard, '/videos': PlaySquare, '/shorts': Scissors, '/reels': Clapperboard,
@@ -65,7 +66,7 @@ export default function CommandPalette({ open, onOpenChange, accounts, categorie
icon: Tag, run: () => navigate(`/tracked-content/category/${encodeURIComponent(category)}`),
})),
{ id: 'action:add-account', group: 'Actions', label: 'Add an account', keywords: ['connect', 'youtube', 'instagram', 'reddit'], icon: Plus, run: () => navigate('/accounts?add=1') },
- { id: 'action:docs', group: 'Actions', label: 'Open documentation', keywords: ['help', 'guide', 'docs', 'setup', 'self-host'], icon: BookOpen, run: () => navigate('/docs') },
+ { id: 'action:docs', group: 'Actions', label: 'Open documentation', keywords: ['help', 'guide', 'docs', 'setup', 'self-host'], icon: BookOpen, run: () => window.open(docsUrl(), '_blank', 'noopener') },
{ id: 'action:refresh', group: 'Actions', label: 'Refresh all accounts', keywords: ['sync', 'update'], icon: RefreshCw, run: onRefreshAll },
{ id: 'action:theme-light', group: 'Theme', label: 'Use light theme', keywords: ['appearance', 'paper'], icon: Sun, run: () => setTheme('light') },
{ id: 'action:theme-dark', group: 'Theme', label: 'Use dark theme', keywords: ['appearance', 'dusk'], icon: Moon, run: () => setTheme('dark') },
diff --git a/frontend/src/components/DocsRedirect.tsx b/frontend/src/components/DocsRedirect.tsx
new file mode 100644
index 0000000..4fac82b
--- /dev/null
+++ b/frontend/src/components/DocsRedirect.tsx
@@ -0,0 +1,12 @@
+import { useEffect } from 'react';
+import { useLocation } from 'react-router-dom';
+import { docsUrl } from '../lib/docs';
+
+// old links to the app's /docs pages land on the same page of the public docs
+export default function DocsRedirect() {
+ const { pathname, hash } = useLocation();
+ useEffect(() => {
+ window.location.replace(docsUrl(pathname.replace(/^\/docs/, '') + hash));
+ }, [pathname, hash]);
+ return null;
+}
diff --git a/frontend/src/features/settings/SchedulingSection.tsx b/frontend/src/features/settings/SchedulingSection.tsx
index 8fb48fd..56db497 100644
--- a/frontend/src/features/settings/SchedulingSection.tsx
+++ b/frontend/src/features/settings/SchedulingSection.tsx
@@ -1,11 +1,11 @@
import React from 'react';
-import { Link } from 'react-router-dom';
import { ArrowRight, Clock, Server, Users } from 'lucide-react';
import SurfaceBox from '@/components/SurfaceBox';
import { ADMIN_EMAIL, adminMailto } from '@/lib/contact';
import SettingsSection from './SettingsSection';
import SchedulingSetupGuide from './SchedulingSetupGuide';
import type { GithubRepoSettings } from './useServerSettings';
+import { docsUrl } from '@/lib/docs';
interface HowItWorksStep {
title: string;
@@ -65,9 +65,9 @@ export default function SchedulingSection({ github }: SchedulingSectionProps) {
<div className="flex flex-col gap-2 rounded-field border border-line p-4">
<p className="flex items-center gap-2 text-sm font-semibold text-ink"><Server className="size-4 stroke-[1.75] text-ink-faint" />You run your own Twiligent</p>
<p className="text-sm text-ink-muted">Deploying the backend is enough; scheduling starts with it. The GitHub backup below is optional.</p>
- <Link to="/docs/self-host" className="mt-auto inline-flex items-center gap-1 text-sm font-medium text-brand-text underline-offset-4 hover:underline">
+ <a href={docsUrl('/self-host')} target="_blank" rel="noopener noreferrer" className="mt-auto inline-flex items-center gap-1 text-sm font-medium text-brand-text underline-offset-4 hover:underline">
Self-hosting guide<ArrowRight className="size-3.5" />
- </Link>
+ </a>
</div>
</div>
</SurfaceBox>
diff --git a/frontend/src/features/settings/SchedulingSetupGuide.tsx b/frontend/src/features/settings/SchedulingSetupGuide.tsx
index 1bfe69b..b10f48b 100644
--- a/frontend/src/features/settings/SchedulingSetupGuide.tsx
+++ b/frontend/src/features/settings/SchedulingSetupGuide.tsx
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from 'react';
-import { Link } from 'react-router-dom';
import { BookOpen, ChevronDown } from 'lucide-react';
import { Button } from '@/components/ui/button';
import SurfaceBox from '@/components/SurfaceBox';
@@ -9,6 +8,7 @@ import type { SetupProgress } from './schedulingProgress';
import GithubRepoForm from './GithubRepoForm';
import SchedulingSetupSteps from './SchedulingSetupSteps';
import type { GithubRepoFormProps } from './GithubRepoForm';
+import { docsUrl } from '@/lib/docs';
export type SchedulingSetupGuideProps = Omit<GithubRepoFormProps, 'canSave'>;
@@ -55,7 +55,7 @@ export default function SchedulingSetupGuide({ owner, repo, onOwnerChange, onRep
A second copy of the publisher that runs on GitHub every 15 minutes, for free, so posts still go out if the server is ever paused. Step 2 needs the secret key of the Supabase project behind this Twiligent, which only its administrator has. If you only sign in here, skip this: the server already publishes your posts.
</p>
<div className="flex flex-wrap items-center gap-2">
- <Button variant="outline" size="sm" render={<Link to="/docs/self-host/github" />}>
+ <Button variant="outline" size="sm" render={<a href={docsUrl('/self-host/github')} target="_blank" rel="noopener noreferrer" />}>
<BookOpen data-icon="inline-start" />
Read the full guide
</Button>
diff --git a/frontend/src/features/settings/UsefulLinksSection.tsx b/frontend/src/features/settings/UsefulLinksSection.tsx
index e841d3a..5e691ec 100644
--- a/frontend/src/features/settings/UsefulLinksSection.tsx
+++ b/frontend/src/features/settings/UsefulLinksSection.tsx
@@ -1,5 +1,4 @@
import React from 'react';
-import { Link } from 'react-router-dom';
import { ArrowRight, BookOpen, ExternalLink } from 'lucide-react';
import SurfaceBox from '@/components/SurfaceBox';
import SettingsSection from './SettingsSection';
@@ -9,15 +8,17 @@ export default function UsefulLinksSection() {
return (
<SettingsSection id="links" title="Useful links">
<SurfaceBox content={false} className="divide-y divide-divider">
- {DOC_LINKS.map(({ label, to }) => (
- <Link
+ {DOC_LINKS.map(({ label, href }) => (
+ <a
key={label}
- to={to}
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
className="flex items-center justify-between gap-2 px-5 py-3 text-sm text-ink transition-colors duration-(--duration-fast) hover:bg-surface-hover"
>
<span className="flex items-center gap-2"><BookOpen className="size-4 shrink-0 stroke-[1.75] text-ink-faint" />{label}</span>
<ArrowRight className="size-4 shrink-0 text-ink-faint" />
- </Link>
+ </a>
))}
{EXTERNAL_LINKS.map(({ label, href }) => (
<a
diff --git a/frontend/src/features/settings/settingsData.ts b/frontend/src/features/settings/settingsData.ts
index ed397ee..821342f 100644
--- a/frontend/src/features/settings/settingsData.ts
+++ b/frontend/src/features/settings/settingsData.ts
@@ -1,10 +1,11 @@
import type {
GitHubSettingsRequest, GitHubSettingsResponse, HealthResponse, KeysStatusResponse,
} from '../../../../shared/types/domain.ts';
+import { docsUrl } from '../../lib/docs.ts';
export interface DocLink {
label: string;
- to: string;
+ href: string;
}
export interface ExternalLink {
@@ -31,9 +32,9 @@ export interface HealthCheckResult {
}
export const DOC_LINKS: DocLink[] = [
- { label: 'Using Twiligent', to: '/docs/use/getting-started' },
- { label: 'Run your own Twiligent', to: '/docs/self-host' },
- { label: 'Environment variables', to: '/docs/reference/environment' },
+ { label: 'Using Twiligent', href: docsUrl('/use/getting-started') },
+ { label: 'Run your own Twiligent', href: docsUrl('/self-host') },
+ { label: 'Environment variables', href: docsUrl('/reference/environment') },
];
export const EXTERNAL_LINKS: ExternalLink[] = [
diff --git a/frontend/src/layout/Sidebar.tsx b/frontend/src/layout/Sidebar.tsx
index 707c1b4..e3ab6d2 100644
--- a/frontend/src/layout/Sidebar.tsx
+++ b/frontend/src/layout/Sidebar.tsx
@@ -18,6 +18,7 @@ import { accountName, accountPath } from '@/lib/accounts';
import { NAV_GROUPS, isNavActive } from './navigation';
import { useAppContext } from '../context/AppContext';
import { useAuth } from '../context/AuthContext';
+import { docsUrl } from '@/lib/docs';
const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
@@ -164,7 +165,7 @@ function UserMenu({ onSignOut }: { onSignOut: () => void }) {
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => navigate('/settings')}><Settings />Settings</DropdownMenuItem>
- <DropdownMenuItem onClick={() => navigate('/docs')}><BookOpen />Documentation</DropdownMenuItem>
+ <DropdownMenuItem onClick={() => window.open(docsUrl(), '_blank', 'noopener')}><BookOpen />Documentation</DropdownMenuItem>
<DropdownMenuItem onClick={onSignOut}><LogOut />Sign out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/frontend/src/lib/docs.ts b/frontend/src/lib/docs.ts
new file mode 100644
index 0000000..b892314
--- /dev/null
+++ b/frontend/src/lib/docs.ts
@@ -0,0 +1,7 @@
+// the documentation lives on the public site, not in the app
+export const DOCS_URL = 'https://twiligent.ujjwal.fyi/docs';
+
+// a docs page by its path under /docs, such as '/self-host/github'
+export function docsUrl(path = ''): string {
+ return `${DOCS_URL}${path}`;
+}
diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx
index ca65150..1914465 100644
--- a/frontend/src/pages/Login.tsx
+++ b/frontend/src/pages/Login.tsx
@@ -1,6 +1,6 @@
import { useState } from 'react';
import type { FormEvent } from 'react';
-import { Link, useNavigate } from 'react-router-dom';
+import { useNavigate, useSearchParams } from 'react-router-dom';
import { toast } from 'sonner';
import { BookOpen, MailWarning } from 'lucide-react';
import { useAuth } from '../context/AuthContext';
@@ -22,6 +22,7 @@ import LoginEmailForm from './LoginEmailForm';
import PasswordInput from './PasswordInput';
import { LOGIN_COPY, PRIVACY_URL } from './loginCopy';
import type { LoginMode } from './loginCopy';
+import { docsUrl } from '@/lib/docs';
interface GoogleOptionProps {
text: GoogleButtonText;
@@ -61,7 +62,9 @@ export default function Login() {
signIn, signUp, verifySignUpCode, resendSignUpCode, sendPasswordReset, verifyPasswordResetCode, updatePassword, signInWithGoogle,
} = useAuth();
const navigate = useNavigate();
- const [mode, setMode] = useState<LoginMode>('login');
+ // the public site's Get started buttons open /login?mode=signup
+ const [params] = useSearchParams();
+ const [mode, setMode] = useState<LoginMode>(params.get('mode') === 'signup' ? 'signup' : 'login');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [code, setCode] = useState('');
@@ -199,7 +202,7 @@ export default function Login() {
<div className="flex min-h-svh flex-col px-6 py-6 sm:px-10">
<header className="flex items-center justify-between">
<Logo className="h-7" />
- <Button variant="ghost" size="sm" render={<Link to="/docs" />}>
+ <Button variant="ghost" size="sm" render={<a href={docsUrl()} />}>
<BookOpen data-icon="inline-start" />
Docs
</Button>