Supports rendering the documentation site as a set of static HTML, JS, CSS, etc files.
How does it work?
The JavaScript crawler requests /logout/ to, well, log out.
The /sitemap/ endpoint returns a list of all Posts with post_type=page and their URLs
A JavaScript crawler requests each of those pages and writes the rendered HTML to the out directory
All full-qualified site URLs are replaced with an absolute path
The JavaScript crawler sends a request to /zip-wp-files/ to create wp.zip with wp-includes and wp-content inside (without PHP files)
The JavaScript crawler unzips wp.zip in the out directory, shipping the missing static assets
Yeah, it's weird process – that's because of wp-now's limitations.
wp-now workarounds
I had to use a few workarounds that would be better addressed in wp-now:
[ ] wp-now only runs a single PHP process which means PHP cannot issue a HTTP request to itself.
[ ] wp-nowenforces a mode it deems the most appropriate and doesn't allow me to explicitly say --mode=server. However, I would just like to use it as a plain PHP server here.
[ ] wp-now does not support explicitly mounting specific directories. I needed to copy wp-content and wp-includes to ../out and couldn't do it because ../out isn't available in VFS. I ended up generating a zip file and unzip it with JavaScript. wp-now could either mount the entire host filesystem and expose all the directories or support a --mount=/host/path:/vfs/path flag.
[ ] wp-now in wp-content mode expects a theme to be in place and won't apply the default WordPress theme. I had to use the installTheme step to install twentytwentyfour. The assumption seems to be that my wp-content directory is complete and contains all it needs, but I'm shipping just a subset of the files in this repo. Instead of mounting wp-content, wp-now could perhaps mount specific plugins and directories found inside wp-content.
[ ] wp-now forcefully logs the user in so I had to add a /logout/ endpoint and request it before starting the static site generation process.
[ ] wp-nowdoesn't kill its child processes so I had to include ps aux | grep wp-now | awk '{print $2}' | xargs kill -9 in the start-site.sh bash script.
[ ] wp-now creates some new files (e.g. Blueprint-installed theme) in my filessytem so I have to run git stash -u every time a site is launched. I'd either create ALL the files in the filesystem, including sqlite-database-integration, OR no files at all and keep all the changes in VFS.
[ ] wp-now does not activate plugins or themes via activatePlugin and activateTheme step.
[ ] Occasionally wp-now stops responding to requests and just hangs. There are no CLI errors visible.
Supports rendering the documentation site as a set of static HTML, JS, CSS, etc files.
How does it work?
/logout/
to, well, log out./sitemap/
endpoint returns a list of all Posts withpost_type=page
and their URLsout
directory/zip-wp-files/
to createwp.zip
withwp-includes
andwp-content
inside (without PHP files)wp.zip
in theout
directory, shipping the missing static assetsYeah, it's weird process – that's because of
wp-now
's limitations.wp-now workarounds
I had to use a few workarounds that would be better addressed in wp-now:
wp-now
only runs a single PHP process which means PHP cannot issue a HTTP request to itself.wp-now
enforces a mode it deems the most appropriate and doesn't allow me to explicitly say--mode=server
. However, I would just like to use it as a plain PHP server here.wp-now
does not support explicitly mounting specific directories. I needed to copywp-content
andwp-includes
to../out
and couldn't do it because../out
isn't available in VFS. I ended up generating a zip file and unzip it with JavaScript.wp-now
could either mount the entire host filesystem and expose all the directories or support a--mount=/host/path:/vfs/path
flag.wp-now
doesn't support custommu-plugins
so I had to add awriteFile
step to my Blueprint.wp-now
inwp-content
mode expects a theme to be in place and won't apply the default WordPress theme. I had to use theinstallTheme
step to installtwentytwentyfour
. The assumption seems to be that mywp-content
directory is complete and contains all it needs, but I'm shipping just a subset of the files in this repo. Instead of mountingwp-content
, wp-now could perhaps mount specific plugins and directories found insidewp-content
.wp-now
forcefully logs the user in so I had to add a/logout/
endpoint and request it before starting the static site generation process.wp-now
doesn't kill its child processes so I had to includeps aux | grep wp-now | awk '{print $2}' | xargs kill -9
in thestart-site.sh
bash script.wp-now
creates some new files (e.g. Blueprint-installed theme) in my filessytem so I have to rungit stash -u
every time a site is launched. I'd either create ALL the files in the filesystem, includingsqlite-database-integration
, OR no files at all and keep all the changes in VFS.wp-now
does not activate plugins or themes viaactivatePlugin
andactivateTheme
step.wp-now
stops responding to requests and just hangs. There are no CLI errors visible.These would all make good issues
cc @sejas @wojtekn