Skip to content

Commit 55a2a34

Browse files
committed
Fix assets in all directories no matter the deep.
1 parent 8f2e5a6 commit 55a2a34

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

_build/build.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747

4848
if ($result->isSuccessful()) {
4949
// fix assets URLs to make them absolute (otherwise, they don't work in subdirectories)
50-
foreach (glob($outputDir.'/**/*.html') as $htmlFilePath) {
50+
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($outputDir)), '/^.+\.html$/i', RegexIterator::GET_MATCH) as $match) {
51+
$htmlFilePath = array_shift($match);
5152
$htmlContents = file_get_contents($htmlFilePath);
5253
file_put_contents($htmlFilePath, str_replace('href="assets/', 'href="/assets/', $htmlContents));
5354
}

0 commit comments

Comments
 (0)