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

"Unlock the Future of Web Development: Discover the Hidden Powers of Headless WordPress!"
The default Astro blog template

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. 

Astro directory tree

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';
Astro blog global data in a code editor with a dark theme

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. 

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

You May Have Missed