gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

gatsby serve can't update wordpress articles #37929

Closed csic21 closed 1 year ago

csic21 commented 1 year ago

Preliminary Checks

Description

When using gatsby develop, adding an article using wordpress can be dynamically generated. But when using gatsby build + gatsby serve, adding a new article with wordpress only has the old data. Does the production environment not support the function of dynamically generating articles? Do I need to rebuild every time I write an article in wordpress?

Reproduction Link

https://github.com/gatsbyjs/gatsby/tree/master/starters/gatsby-starter-wordpress-blog

Steps to Reproduce

use wordpress official Starter

Expected Result

Use gatsby serve to automatically get wordpress articles.like use plugin gatsby-source-wordpress options nodeUpdateInterval in gatsby-config.js

Actual Result

Unable to automatically update articles using gatsby serve

Environment

System:
    OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Languages:
    Python: 2.7.18 - /usr/bin/python
  npmPackages:
    gatsby: ~5.3.2 => 5.3.3
    gatsby-plugin-image: ^3.3.2 => 3.8.0
    gatsby-plugin-manifest: ^5.3.1 => 5.8.0
    gatsby-plugin-offline: ^6.3.1 => 6.8.0
    gatsby-plugin-react-helmet: ^6.3.0 => 6.8.0
    gatsby-plugin-sharp: ^5.3.2 => 5.8.1
    gatsby-source-filesystem: ^5.3.1 => 5.8.0
    gatsby-source-wordpress: ^7.8.0 => 7.8.0
    gatsby-transformer-sharp: ^5.3.1 => 5.8.0

Config Flags

No response

TylerBarnes commented 1 year ago

Hi @csic21 this is how Gatsby works. You'll need to run a build again in order to update the static files with the latest data. During development source-wordpress runs a server that does this for you. In a production site you will typically set up webhooks from WPGatsby settings in wp-admin to trigger your CI service that builds your site. Locally you can run gatsby build again and refresh the page and you should see updated content. As long as you don't run gatsby clean the build should be relatively quick. Let me know if you have any other questions.