Skip to content

Commit fa87721

Browse files
committed
fix self-named components
1 parent 96fdd5c commit fa87721

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/BladeService.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,20 @@ public function componentNameToPath($name): string
174174

175175
// Try direct component file first (e.g., form.input -> form/input.blade.php)...
176176
$fullPath = $basePath . '/' . $componentPath . '.blade.php';
177-
if (file_exists($fullPath)) {
177+
if (file_exists($fullPath) && ! is_dir($fullPath)) {
178178
return $fullPath;
179179
}
180180

181181
// For root components, try index.blade.php (e.g., form -> form/index.blade.php)...
182-
if (!str_contains($componentPath, '/')) {
183-
$indexPath = $basePath . '/' . $componentPath . '/index.blade.php';
184-
if (file_exists($indexPath)) {
185-
return $indexPath;
186-
}
182+
$indexPath = $basePath . '/' . $componentPath . '/index.blade.php';
183+
if (file_exists($indexPath) && ! is_dir($indexPath)) {
184+
return $indexPath;
185+
}
187186

188-
// Try same-name file (e.g., card -> card/card.blade.php)...
189-
$sameNamePath = $basePath . '/' . $componentPath . '/' . $componentPath . '.blade.php';
190-
if (file_exists($sameNamePath)) {
191-
return $sameNamePath;
192-
}
187+
// Try same-name file (e.g., card -> card/card.blade.php)...
188+
$sameNamePath = $basePath . '/' . $componentPath . '/' . $componentPath . '.blade.php';
189+
if (file_exists($sameNamePath) && ! is_dir($sameNamePath)) {
190+
return $sameNamePath;
193191
}
194192
}
195193
}

0 commit comments

Comments
 (0)