feat: single-community mode (PUBLIC_SINGLE_COMMUNITY)

For instances that are one community (thebitcoin.win): "/" reroutes to the
community page, community browsing and explore lead back to it, community
names/handles are hidden on posts and in the header, and create-post
preselects the community. Unset, behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011c5BZVwWdVLrdQi9htmuth
This commit is contained in:
larsiandClaude Opus 5.5 committed 2026-11-14 01:06:07 +01:00
1 parent 6609371a28
commit a9bf3497fe
11 files changed
+105 -27

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
import type { Reroute } from '@sveltejs/kit'
import { SINGLE_COMMUNITY } from '$lib/app/single'
/**
* Single-community mode: serve the community page for "/" and for every route that would
* otherwise list or browse communities. The address bar keeps the original path, so the home
* page stays "/". The community's own sub-pages (e.g. /c/<name>/settings) are left alone.
*/
export const reroute: Reroute = ({ url }) => {
if (!SINGLE_COMMUNITY) return
const path = url.pathname
const home = `/c/${SINGLE_COMMUNITY}`
if (path === '/' || path === '/communities' || path.startsWith('/explore')) return home
const other = path.match(/^\/c\/([^/]+)\/?$/)
if (other && other[1] !== SINGLE_COMMUNITY) return home
}