Browse Source

Guess content directory

As pointed out by @Lomanic (see https://github.com/picocms/Pico/pull/260#issuecomment-153091890; thank you btw\!) we actually have to explain users how to change the content directory. This runs contrary to our "stupidly simple" claim. So Pico now simply uses the `content` directory when it exists...
Daniel Rudolf 9 năm trước cách đây
mục cha
commit
ebe007b
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      lib/Pico.php

+ 9 - 2
lib/Pico.php

@@ -437,7 +437,7 @@ class Pico
             'twig_config' => array('cache' => false, 'autoescape' => false, 'debug' => false),
             'pages_order_by' => 'alpha',
             'pages_order' => 'asc',
-            'content_dir' => $this->getRootDir() . 'content-sample/',
+            'content_dir' => null,
             'content_ext' => '.md',
             'timezone' => ''
         );
@@ -453,7 +453,14 @@ class Pico
         if (empty($this->config['base_url'])) {
             $this->config['base_url'] = $this->getBaseUrl();
         }
-        if (!empty($this->config['content_dir'])) {
+        if (empty($this->config['content_dir'])) {
+            // try to guess the content directory
+            if (is_dir($this->getRootDir() . 'content')) {
+                $this->config['content_dir'] = $this->getRootDir() . 'content/';
+            } else {
+                $this->config['content_dir'] = $this->getRootDir() . 'content-sample/';
+            }
+        } else {
             $this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
         }
         if (!empty($this->config['timezone'])) {