Skip to content

Commit db5ab87

Browse files
committed
feat: improve indexing
1 parent 5b12b48 commit db5ab87

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Web/Blog/BlogIndexer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Tempest\Support\Arr\ImmutableArray;
1010

1111
use function Tempest\Support\arr;
12+
use function Tempest\Support\Arr\get_by_key;
13+
use function Tempest\Support\Arr\wrap;
1214
use function Tempest\uri;
1315

1416
final readonly class BlogIndexer
@@ -29,20 +31,27 @@ public function __invoke(): ImmutableArray
2931
throw new \RuntimeException(sprintf('Blog entry [%s] is missing a frontmatter.', $path));
3032
}
3133

32-
['title' => $title, 'author' => $author, 'description' => $description] = $markdown->getFrontMatter();
34+
$frontmatter = $markdown->getFrontMatter();
35+
$title = get_by_key($frontmatter, 'title');
36+
$author = get_by_key($frontmatter, 'author');
37+
$description = get_by_key($frontmatter, 'description');
38+
$keywords = get_by_key($frontmatter, 'keywords');
39+
$tags = get_by_key($frontmatter, 'tag');
3340

3441
$main = new Command(
3542
type: Type::URI,
3643
title: $title,
3744
uri: uri([BlogController::class, 'show'], slug: $matches['slug']),
3845
hierarchy: [
3946
'Blog',
40-
$author,
47+
Author::tryFrom($author)?->getName() ?? 'Tempest',
4148
$title,
4249
],
4350
fields: [
44-
'author' => $author,
45-
'description' => $description,
51+
$author,
52+
$description,
53+
...wrap($keywords),
54+
...wrap($tags),
4655
],
4756
);
4857

src/Web/Documentation/DocumentationIndexer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use function Tempest\Support\arr;
1616
use function Tempest\Support\Arr\get_by_key;
17+
use function Tempest\Support\Arr\wrap;
1718
use function Tempest\Support\Str\to_kebab_case;
1819
use function Tempest\Support\Str\to_sentence_case;
1920
use function Tempest\uri;
@@ -45,6 +46,7 @@ public function __invoke(Version $version): ImmutableArray
4546
$category = $path->beforeLast('/')->afterLast('/')->replaceRegex('/\d+-/', '');
4647
$chapter = $path->basename('.md')->replaceRegex('/\d+-/', '');
4748
$title = get_by_key($markdown->getFrontMatter(), 'title');
49+
$keywords = get_by_key($markdown->getFrontMatter(), 'keywords');
4850

4951
$main = new Command(
5052
type: Type::URI,
@@ -55,6 +57,9 @@ public function __invoke(Version $version): ImmutableArray
5557
to_sentence_case($category),
5658
$title,
5759
],
60+
fields: [
61+
...wrap($keywords),
62+
],
5863
);
5964

6065
/** @var Heading[] */

src/Web/Documentation/content/main/5-extra-topics/01-contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Contributing
3+
keywords: "How do I"
34
---
45

56
Welcome aboard! We're excited that you are interested in contributing to the Tempest framework. We value all contributions to the project and have assembled the following resources to help you get started. Thanks for being a contributor!

0 commit comments

Comments
 (0)