Hello!
I’ve got a website that is using routing in the config file to remove the parent slug for urls following this guide. But I’m also generating images for Open Graph tags using content representations (a bit like this).
How do I set the config routing to first just return the file as requested if it includes the extension ‘.png’ (or .jpg, .pdf or whatever) before then routing to remove the parent slug?
This is where I’ve got to, but I’m a little lost…
'routes' => [
[
'pattern' => '.*\.(png|pdf|jpg)$',
'action' => function ($uid) {
RETURN THE FILE AS REQUESTED?
}
],
[
'pattern' => '(:any)',
'action' => function ($slug) {
if ($page = page('parenttoremove')->find($slug)) {
return page($page);
}
$this->next();
}
],
[
'pattern' => 'parenttoremove/(:any)',
'action' => function($uid) {
go($uid);
}
]
]
];