refactor(api-key): Inject Ghost API key at build time
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user