Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
1.1.0 (#6)
Browse files Browse the repository at this point in the history
* Resolve #1: Multi-language support

* #2: Added MarkdownWikiController

* Added RebuildStorageCacheCommand

* Updated README.md

* Fixed meta files not supporting multiple languages

* Updated README.md

* Updated version number

* Added custom attributes to MarkdownWikiPage

* Updated README.md

* Updated version number
  • Loading branch information
Zeryther authored Nov 15, 2021
1 parent d8cb326 commit 271f2f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The file structure within your wiki directory is held simple.
* `meta.yaml` files need to contain the following keys:
`title` The page's title
`description` The page's description
Any other keys will be passed on as "custom attributes". If you need any other data for a page, save it here.

**Example:** If you want to create a page with the path `/account/creation`, you would need a folder with the path `/account/creation`. In that folder, you would create a file named `meta.yaml` and a file named `content.md`. The first contains meta data about your page, the second contains your actual page content.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gigadrive/markdown-wiki-bundle",
"version": "1.0.0",
"version": "1.1.0",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
Expand Down
7 changes: 6 additions & 1 deletion src/Model/MarkdownWikiPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function __construct(
protected array $title,
protected array $description,
protected string $path,
protected array $content
protected array $content,
protected array $customAttributes
) {
}

Expand All @@ -43,4 +44,8 @@ public function getPath(): string {
public function getContent(): array {
return $this->content;
}

public function getCustomAttributes(): array {
return $this->customAttributes;
}
}
12 changes: 11 additions & 1 deletion src/Service/MarkdownWikiImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ protected function readFilesInDirectory(string $path): ?MarkdownWikiPage {
$description = [];
$pagePath = "/" . $this->stripPathPrefix($path);
$content = [];
$customAttributes = [];

foreach ($finder as $file) {
if (str_ends_with($file->getFilename(), ".md")) {
Expand All @@ -117,6 +118,15 @@ protected function readFilesInDirectory(string $path): ?MarkdownWikiPage {

$title[$language] = $meta["title"];
$description[$language] = $meta["description"];
$customAttributes[$language] = [];

foreach ($meta as $key => $value) {
if ($key === "title" || $key === "description") {
continue;
}

$customAttributes[$language][$key] = $value;
}
}
}

Expand All @@ -125,7 +135,7 @@ protected function readFilesInDirectory(string $path): ?MarkdownWikiPage {
return null;
}

return new MarkdownWikiPage($title, $description, $pagePath, $content);
return new MarkdownWikiPage($title, $description, $pagePath, $content, $customAttributes);
}

protected function stripPathPrefix($path): string {
Expand Down

0 comments on commit 271f2f9

Please sign in to comment.