-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use @wp-playground.cli and the Simply Static plugin for static site g…
…eneration (#59) This PR ships a Blueprint that generates the static site using the Simply Static plugin and the `run-blueprint` feature WordPress/wordpress-playground#1289. Usage: ```shell bash build-static-site.sh # the site is now rendered in the output directory ```
- Loading branch information
Showing
6 changed files
with
71 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p output | ||
bunx @wp-playground/cli@latest \ | ||
run-blueprint \ | ||
--mount=./wp-content/plugins/wp-docs-plugin:/wordpress/wp-content/plugins/wp-docs-plugin \ | ||
--mount=./wp-content/plugins/export-static-site:/wordpress/wp-content/plugins/export-static-site \ | ||
--mount=./wp-content/html-pages:/wordpress/wp-content/html-pages \ | ||
--mount=./wp-content/uploads:/wordpress/wp-content/uploads \ | ||
--mount=./wp-content/themes/playground-docs:/wordpress/wp-content/themes/playground-docs \ | ||
--mount=./output:/output \ | ||
--blueprint=./wp-content/blueprint-static-site.json \ | ||
--wp=6.5 \ | ||
--php=8.0 | ||
|
||
cd output | ||
unzip export.zip | ||
rm export.zip |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
wp-content/plugins/export-static-site/export-static-site.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
Plugin Name: Export Static Site | ||
Plugin URI: https://w.org/playground | ||
Description: Exposes a export_static_site PHP function that exports the static site using the Simply Static | ||
Version: 0.1 | ||
Author: WordPress Contributors | ||
License: GPL2 | ||
*/ | ||
|
||
function export_static_site($output_file) | ||
{ | ||
$simply_static = Simply_Static\Plugin::instance(); | ||
$simply_static->run_static_export(); | ||
|
||
// Wait at most 2 minutes for the export to finish | ||
$i = 0; | ||
do { | ||
$exports = glob(WP_CONTENT_DIR . '/uploads/simply-static/temp-files/*.zip'); | ||
sleep(1); | ||
} while (empty($exports) && ++$i < 120); | ||
|
||
if (empty($exports)) { | ||
throw new Exception("The export wasn't finished in two minutes, aborting."); | ||
} | ||
|
||
$export = end($exports); | ||
rename($export, $output_file); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters