Skip to content

Commit

Permalink
Use home url during crawling and post-processing for Bedrock support
Browse files Browse the repository at this point in the history
  • Loading branch information
john-shaffer committed Nov 27, 2021
1 parent 82317d1 commit 5d8f643
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public function crawlSite( string $static_site_path ) : void {
$urls = [];

foreach ( $crawlable_paths as $root_relative_path ) {
$absolute_uri = new URL( $this->site_path . $root_relative_path );
$absolute_uri = new URL(
rtrim( SiteInfo::getURL( 'home' ), '/' ) . $root_relative_path
);
$urls[] = [
'url' => $absolute_uri->get(),
'path' => $root_relative_path,
Expand Down
14 changes: 7 additions & 7 deletions src/SimpleRewriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ public static function rewriteFileContents( string $file_contents ) : string
CoreOptions::getValue( 'deploymentURL' )
);

$wordpress_site_url = apply_filters(
'wp2static_set_wordpress_site_url',
untrailingslashit( SiteInfo::getUrl( 'site' ) )
$wordpress_home_url = apply_filters(
'wp2static_set_wordpress_home_url',
untrailingslashit( SiteInfo::getUrl( 'home' ) )
);

$wordpress_site_url = untrailingslashit( $wordpress_site_url );
$wordpress_home_url = untrailingslashit( $wordpress_home_url );
$destination_url = untrailingslashit( $destination_url );
$destination_url_rel = URLHelper::getProtocolRelativeURL( $destination_url );
$destination_url_rel_c = addcslashes( $destination_url_rel, '/' );

$replacement_patterns = [
$wordpress_site_url => $destination_url,
URLHelper::getProtocolRelativeURL( $wordpress_site_url ) =>
$wordpress_home_url => $destination_url,
URLHelper::getProtocolRelativeURL( $wordpress_home_url ) =>
URLHelper::getProtocolRelativeURL( $destination_url ),
addcslashes( URLHelper::getProtocolRelativeURL( $wordpress_site_url ), '/' ) =>
addcslashes( URLHelper::getProtocolRelativeURL( $wordpress_home_url ), '/' ) =>
addcslashes( URLHelper::getProtocolRelativeURL( $destination_url ), '/' ),
];

Expand Down

0 comments on commit 5d8f643

Please sign in to comment.