Ejemplo n.º 1
0
 /**
  * [page description]
  * @param  [type] $path [description]
  * @return [type]       [description]
  */
 public static function page($path)
 {
     if (strpos($path, ':') === false && !self::$app->isAbsolutePath($path)) {
         $path = "content:{$path}";
     }
     if ($page = self::$app->path($path)) {
         $page = \Copilot\Page::fromCache($page);
         return $page;
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * [fromFolder description]
  * @param  [type] $path [description]
  * @return [type]       [description]
  */
 public static function fromFolder($path)
 {
     $pages = [];
     foreach (copi::helper('fs')->ls($path) as $file) {
         if ($file->isDir()) {
             $page = null;
             $indexfile = $file->getRealPath() . '/index';
             if (file_exists("{$indexfile}.html")) {
                 $page = "{$indexfile}.html";
             } elseif (file_exists("{$indexfile}.md")) {
                 $page = "{$indexfile}.md";
             }
             if ($page) {
                 $pages[] = Page::fromCache($page);
             }
         } elseif (in_array($file->getExtension(), ['html', 'md']) && $file->getBasename('.' . $file->getExtension()) != 'index') {
             $pages[] = Page::fromCache($file->getRealPath());
         }
     }
     $collection = new self($pages);
     return $collection;
 }