[READ-ONLY] Mirror of https://github.com/flo-bit/tiny-docs. quick setup, simple, minimalistic docs for your github project flo-bit.dev/tiny-docs/
0

Configure Feed

Select the types of activity you want to include in your feed.

tiny-docs / config.server.ts
1.7 kB 56 lines
1// config.server.ts 2import { existsSync, readFileSync } from "node:fs"; 3import { resolve } from "node:path"; 4import type { Config } from "./config.type"; 5 6const defaultConfig: Config = { 7 SITE: undefined, 8 BASE: "", 9 SITE_NAME: "", 10 SITE_DESCRIPTION: "", 11 SITE_FAVICON: "", 12 SHOW_THEME_TOGGLE: true, 13 SEARCH_ENABLED: false, 14 BASE_COLOR: "zinc", 15 ACCENT_COLOR: "emerald", 16 17 FACEBOOK_URL: "", 18 TWITTER_URL: "", 19 GITHUB_URL: "", 20 LINKEDIN_URL: "", 21 YOUTUBE_URL: "", 22 BLUESKY_URL: "", 23 DISCORD_URL: "", 24 EMAIL: "", 25 26 EXCLUDE_README: false, 27 REPLACE_README_WITH_TITLE: "", 28}; 29 30// Resolve via process.cwd() — Astro runs from project root. import.meta.url 31// would lie when this module is bundled into dist/chunks during build. 32const projectRoot = process.cwd(); 33const parentDir = resolve(projectRoot, ".."); 34 35// Parent-layout (CI): tiny-docs sits at <repo>/docs-builder/ with content at <repo>/docs/. 36// Self-layout (local dev): content lives inside this repo at ./docs/. 37export const contentRoot = existsSync(resolve(parentDir, "docs")) 38 ? parentDir 39 : projectRoot; 40 41const configPath = resolve(contentRoot, "tdocs.config.json"); 42 43export function loadConfig(): Config { 44 if (!existsSync(configPath)) return defaultConfig; 45 try { 46 const parsed = JSON.parse(readFileSync(configPath, "utf-8")); 47 return { ...defaultConfig, ...parsed }; 48 } catch { 49 console.warn("⚠️ Invalid tdocs.config.json — using defaults."); 50 return defaultConfig; 51 } 52} 53 54export const config = loadConfig(); 55export const accentColor = (config.ACCENT_COLOR ?? "emerald").toLowerCase(); 56export const baseColor = (config.BASE_COLOR ?? "zinc").toLowerCase();