“Unlock the Future of Web Development: Discover the Hidden Powers of Headless WordPress!”

Our current Astro site renders content from files in the src/pages
directory, where the [...slug].astro
is dynamic and responsible for parsing and rendering the markdown files inside the src/content/blog
directory.

Since we’ll get our content from WordPress, we can remove the src/content
directory and the content.config.ts
file.
In src/consts.ts
, define a new constant for your site’s WPGraphQL endpoint. Reminder: This can be a live site or a local Studio site.
// Place any global data in this file.
// You can import this data from anywhere in your site by using the `import` keyword.
export const SITE_TITLE = 'Astro Blog';
export const SITE_DESCRIPTION = 'Welcome to my website!';
export const WORDPRESS_API_URL = 'https://astroheadlessbuild.wpcomstaging.com/graphql';

We already know we need to get all posts, the slugs, and a single post given a slug. As we progress, more queries will likely be required. Category, tag, and author pages already come to mind.
Post Comment