diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 58f387d..8bf7f0a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -16,9 +16,11 @@ jobs: uses: actions/setup-node@v4 with: node-version: '20' - cache: 'pnpm' - name: Install dependencies run: pnpm install + - name: Create Ghost Config + run: | + echo "window.GhostConfig = { ghostApiKey: '${{ secrets.GHOST_CONTENT_API_KEY }}', ghostApiUrl: '${{ secrets.GHOST_ADMIN_API_URL }}' };" > assets/js/ghost-config.js - name: Build theme run: pnpm build - name: Deploy Ghost Theme diff --git a/assets/js/main.js b/assets/js/main.js index 52dcdea..49a50a1 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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; diff --git a/default.hbs b/default.hbs index 40f1041..c97d20d 100644 --- a/default.hbs +++ b/default.hbs @@ -6,8 +6,6 @@