Skip to content

Commit

Permalink
feat: return field for further chaining for resolvePermalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Oct 10, 2023
1 parent 031b185 commit 4066f1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/extensions/fieldMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@
$kirby = $field->parent()->kirby();
$pathParser = $kirby->option('permalinksResolver.pathParser', fn (string $path) => $path);

return preg_replace_callback(
if (!is_string($field->value)) {
return $field;
}

$field->value = preg_replace_callback(
'!href="\/@\/(page|file)\/([^"]+)"!',
function ($matches) use ($kirby, $pathParser) {
$type = $matches[1]; // Either `page` or `file`
Expand All @@ -163,6 +167,8 @@ function ($matches) use ($kirby, $pathParser) {
},
$field->value
);

return $field;
},

/**
Expand Down

0 comments on commit 4066f1e

Please sign in to comment.