Issue with theme installation

Created on 20 May 2024, 6 months ago

Steps to reproduce

After enabling this theme when we try to open the home page it throws an error

Drupal\Core\File\Exception\NotRegularDirectoryException: themes/contrib/koan/lib/stories is not a directory. in Drupal\Core\File\FileSystem->scanDirectory() (line 668 of core\lib\Drupal\Core\File\FileSystem.php).

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India aman_lnwebworks

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @aman_lnwebworks
  • First commit to issue fork.
  • Assigned to aman_lnwebworks
  • 🇮🇳India aman_lnwebworks

    Hi @sleepingmonk

    For the above issue, you need to add a

    stories

    directory inside the

    lib

    directory,

    And also need to update "koan_library_info_build()" function in .theme file

    function koan_library_info_build() {
      $extensions = ['css', 'js'];
      $directory = 'themes/contrib/koan/lib/stories';
      $libraries = [];
      try {
        // Escaping and imploding the extensions array for regex use
        $extensions = array_map('preg_quote', $extensions);
        $extensions = implode('|', $extensions);
        // Scanning the directory for files with the specified extensions
        $file_scan = \Drupal::service('file_system')->scanDirectory($directory, "/{$extensions}$/");
        
        // Processing each file found in the directory
        foreach ($file_scan as $file) {
          $parts = explode('.', $file->filename);
          $extension = end($parts);
    
          switch ($extension) {
            case 'css':
              $libraries[$file->name][$extension] = [
                'component' => [
                  '/' . $file->uri => [],
                ],
              ];
              break;
            case 'js':
              $libraries[$file->name][$extension] = [
                '/' . $file->uri => [],
              ];
              break;
          }
        }
      } catch (Exception $e) {
        // Logging the exception message to the watchdog for debugging
        \Drupal::logger('koan')->error('Error building library info: @message', ['@message' => $e->getMessage()]);
      }
      return $libraries;
    }
  • 🇮🇳India aman_lnwebworks

    Hi @sleepingmonk

    Please review the above solution once.

    Thank you !!

  • 🇮🇳India aman_lnwebworks

    Please add a preview of the theme.

    Thank you

Production build 0.71.5 2024