-
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 the Simply Static plugin for static site generation
Playground now supports a loopback request and libcurl, which means we can use Simply Static to generate a static site.
- Loading branch information
Showing
5 changed files
with
63 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
bun \ | ||
--config=/Users/cloudnik/.bunfig.toml \ | ||
../playground/packages/playground/cli/src/cli.ts \ | ||
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 \ |
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