feat: configure default article via environment variable

- Add VITE_DEFAULT_ARTICLE_NADDR env variable support
- Create .env with default article naddr
- Create .env.example for documentation
- Add vite-env.d.ts for TypeScript type support
- Fallback to hardcoded value if env var not set
- Using Vite's built-in env variable support (no dotenv needed)
This commit is contained in:
Gigi
2025-10-05 09:08:10 +01:00
parent 1f5e3f82b0
commit 82ab07e606
3 changed files with 15 additions and 1 deletions

3
.env.example Normal file
View File

@@ -0,0 +1,3 @@
# Default article to display on app load
# This should be a valid naddr1... string (NIP-19 encoded address pointer to a kind:30023 long-form article)
VITE_DEFAULT_ARTICLE_NADDR=naddr1qvzqqqr4gupzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqqxnzd3cxqmrzv3exgmr2wfesgsmew

View File

@@ -8,7 +8,9 @@ import { createAddressLoader } from 'applesauce-loaders/loaders'
import Login from './components/Login' import Login from './components/Login'
import Bookmarks from './components/Bookmarks' import Bookmarks from './components/Bookmarks'
const DEFAULT_ARTICLE = 'naddr1qvzqqqr4gupzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqqxnzd3cxqmrzv3exgmr2wfesgsmew' // Load default article from environment variable with fallback
const DEFAULT_ARTICLE = import.meta.env.VITE_DEFAULT_ARTICLE_NADDR ||
'naddr1qvzqqqr4gupzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqqxnzd3cxqmrzv3exgmr2wfesgsmew'
function App() { function App() {
const [eventStore, setEventStore] = useState<EventStore | null>(null) const [eventStore, setEventStore] = useState<EventStore | null>(null)

9
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_DEFAULT_ARTICLE_NADDR: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}