summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2020-02-28 23:08:02 +0000
committerDavid T. Sadler <davidtsadler@googlemail.com>2020-02-28 23:08:02 +0000
commitf849601778a9aacb42a37952cb6578cc2d9d910a (patch)
tree4b897e30e78f1c583d2b72507d076d933e4fe08d
parenta95a53491467758c1fc0ebb3840b0e51a79b42f8 (diff)
Allow category name to be independant of slug
-rw-r--r--config.php5
-rw-r--r--source/_categories/mysql.md4
-rw-r--r--source/_categories/php.md4
-rw-r--r--source/_layouts/master.blade.php2
-rw-r--r--source/_partials/postStub.blade.php2
-rw-r--r--source/_posts/customizing-your-site.md2
-rw-r--r--source/_posts/getting-started.md2
7 files changed, 16 insertions, 5 deletions
diff --git a/config.php b/config.php
index e357577..9c8274f 100644
--- a/config.php
+++ b/config.php
@@ -22,7 +22,10 @@ return [
'path' => '/categories/{filename}',
'posts' => function ($page, $allPosts) {
return $allPosts->filter(function ($post) use ($page) {
- return $post->categories ? in_array($page->getFilename(), $post->categories, true) : false;
+ $categorySlugs = array_map(function ($category) {
+ return Str::slug($category);
+ }, $post->categories);
+ return $post->categories ? in_array($page->getFilename(), $categorySlugs, true) : false;
});
},
],
diff --git a/source/_categories/mysql.md b/source/_categories/mysql.md
new file mode 100644
index 0000000..9d40511
--- /dev/null
+++ b/source/_categories/mysql.md
@@ -0,0 +1,4 @@
+---
+extends: _layouts.category
+description: All the MySql posts
+---
diff --git a/source/_categories/php.md b/source/_categories/php.md
new file mode 100644
index 0000000..7efa7fd
--- /dev/null
+++ b/source/_categories/php.md
@@ -0,0 +1,4 @@
+---
+extends: _layouts.category
+description: All the PHP posts
+---
diff --git a/source/_layouts/master.blade.php b/source/_layouts/master.blade.php
index 429c4a7..05402f8 100644
--- a/source/_layouts/master.blade.php
+++ b/source/_layouts/master.blade.php
@@ -9,7 +9,7 @@
<aside>
<ol>
@foreach ($page->allCategories($posts) as $category)
- <li><a href="/categories/{{ $category }}">{{ $category }}</a></li>
+ <li><a href="/categories/{{ \Illuminate\Support\Str::slug($category) }}">{{ $category }}</a></li>
@endforeach
</ol>
</aside>
diff --git a/source/_partials/postStub.blade.php b/source/_partials/postStub.blade.php
index ca9f08b..734d23f 100644
--- a/source/_partials/postStub.blade.php
+++ b/source/_partials/postStub.blade.php
@@ -9,7 +9,7 @@
</time>
<div class="order-1 md:order-2">
@foreach ($post->categories as $category)
- <span class="inline-block bg-green-800 rounded py-2 px-4"><a class="text-gray-200" href="/categories/{{ $category }}">{{ $category }}</a></span>
+ <span class="inline-block bg-green-800 rounded py-2 px-4"><a class="text-gray-200" href="/categories/{{ \Illuminate\Support\Str::slug($category) }}">{{ $category }}</a></span>
@endforeach
</div>
</div>
diff --git a/source/_posts/customizing-your-site.md b/source/_posts/customizing-your-site.md
index 50b53a1..aaf2850 100644
--- a/source/_posts/customizing-your-site.md
+++ b/source/_posts/customizing-your-site.md
@@ -4,7 +4,7 @@ section: content
title: Customizing Your Site
date: 2018-12-24
description: Customize your site with CSS and JS
-categories: [configuration, feature]
+categories: [PHP, MySQL]
featured: true
excerpt: This starter template comes pre-loaded with Tailwind CSS, a utility CSS framework that allows you to customize and build complex designs without touching a line of CSS.
---
diff --git a/source/_posts/getting-started.md b/source/_posts/getting-started.md
index 8f28cc6..1b378a9 100644
--- a/source/_posts/getting-started.md
+++ b/source/_posts/getting-started.md
@@ -6,7 +6,7 @@ date: 2018-12-25
description: Getting started with the Jigsaw blog starter template
cover_image: /assets/img/post-cover-image-2.png
featured: true
-categories: [configuration]
+categories: [Configuration]
---
This is a starter template for creating a beautiful, customizable blog with minimal effort. You’ll only have to change a few settings and you’re ready to go.<!-- more -->