Skip to content

Commit

Permalink
Fix icons not rendering correctly on WIndows
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jan 14, 2023
1 parent 6877df4 commit 5fe3f7a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/models/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ public function getBadgeCount(): int
public function getFontIcon(): ?string
{
// Ignore any icon with a directory separator - that's not an icon font
if (!str_contains($this->icon, DIRECTORY_SEPARATOR)) {
// Be sure to check for Windows-based paths too.
if (!str_contains($this->icon, '/') && !str_contains($this->icon, '\\')) {
return $this->icon;
}

Expand All @@ -175,7 +176,8 @@ public function getIcon(): ?string
// Get the original navs path, so we can handle multi-environment paths correctly. Path's will be stored
// in one environment, so they'll be different on another. The original nav will already have the correct path,
// so it's efficient to just swap that in. This will also handle things like Craft' GQL, being `@appicons/graphql.svg`.
if (str_contains($this->icon, DIRECTORY_SEPARATOR)) {
// Be sure to check for Windows-based paths too.
if (str_contains($this->icon, '/') || str_contains($this->icon, '\\')) {
return $this->_originalNavItem['icon'] ?? $this->icon;
}

Expand Down Expand Up @@ -209,7 +211,7 @@ public function getCustomIconPath(): bool|string|null
$volumePath = $asset->getVolume()->path ?? null;

if ($volumePath) {
$path = FileHelper::normalizePath($volumePath . DIRECTORY_SEPARATOR . $asset->folderPath . DIRECTORY_SEPARATOR . $asset->filename);
$path = FileHelper::normalizePath($volumePath . '/' . $asset->folderPath . '/' . $asset->filename);
$path = App::parseEnv($path);

if (@file_exists($path)) {
Expand Down

0 comments on commit 5fe3f7a

Please sign in to comment.