refactor(api-key): Inject Ghost API key at build time

This commit is contained in:
2026-02-17 19:21:42 +01:00
parent 9a3b35b428
commit 99ddd47649
3 changed files with 9 additions and 10 deletions

View File

@@ -102,16 +102,14 @@ document.addEventListener('DOMContentLoaded', () => {
let isLoading = false;
let hasMorePosts = true;
const ghostApiKeyMeta = document.querySelector('meta[name="ghost-api-key"]');
const ghostApiUrlMeta = document.querySelector('meta[name="ghost-api-url"]');
if (!ghostApiKeyMeta || !ghostApiUrlMeta) {
console.error('Ghost Content API Key or URL meta tag not found. Infinite scroll will not work.');
// Retrieve API key and URL from global GhostConfig object
if (typeof window.GhostConfig === 'undefined' || !window.GhostConfig.ghostApiKey || !window.GhostConfig.ghostApiUrl) {
console.error('Ghost Content API Key or URL not found in window.GhostConfig. Infinite scroll will not work.');
return;
}
const GHOST_API_KEY = ghostApiKeyMeta.content;
const GHOST_API_URL = ghostApiUrlMeta.content;
const GHOST_API_KEY = window.GhostConfig.ghostApiKey;
const GHOST_API_URL = window.GhostConfig.ghostApiUrl;
const fetchPosts = async () => {
if (isLoading || !hasMorePosts) return;