Skip to content

Commit

Permalink
feat: make list item text configurable (#18)
Browse files Browse the repository at this point in the history
Closes #12
  • Loading branch information
gearsdigital committed Jul 4, 2020
1 parent 51445bc commit 6f2b28b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,24 @@ git submodule add https://github.com/gearsdigital/enhanced-toolbar-link-dialog.g

## Configuration

No configuration necessary 🥳
The list item text is created using the [Kirby Query Language](https://getkirby.com/docs/guide/blueprints/query-language) and therefore customizable. It is totally up to you, how the page will appear to your users. You have access to `$page`, `site` and `kirby`.

## Available translations
The default is `{{ page.title }}`.

In order to change the default add `gearsdigital.enhanced-toolbar-link-dialog.link.title` to your `site/config.php`.

### Example
```php
// site/config.php
return [
'gearsdigital.enhanced-toolbar-link-dialog.link.title' => '### {{ page.title }} ###',
];
```

This will wrap the text in `###` => (`### In the jungle of Sumatra ###`)

## Available translations
``
- German
- English

Expand Down
10 changes: 8 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Kirby\Http\Url;
use Kirby\Toolkit\Str;

Kirby::plugin('gearsdigital/enhanced-toolbar-link-dialog', [
'api' => [
Expand All @@ -13,7 +14,12 @@
return $page->id();
},
'title' => function ($page) {
return $page->title()->value();
$query = option('gearsdigital.enhanced-toolbar-link-dialog.link.title', '{{ page.title }}');
return Str::template($query, [
'page' => $page,
'site' => site(),
'kirby' => kirby(),
]);
},
'slug' => function ($page) {
return URL::makeAbsolute($page->parent().DS.$page->slug());
Expand Down Expand Up @@ -54,7 +60,7 @@
'gearsdigital.enhanced-toolbar-link-dialog.external' => 'External Link',
'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'No pages found',
'gearsdigital.enhanced-toolbar-link-dialog.target.title' => 'Link Target',
'gearsdigital.enhanced-toolbar-link-dialog.target.help' => 'Specify where to open the linked document.',
'gearsdigital.enhanced-toolbar-link-dialog.target.help' => 'Specify where to open the linked document.'
],
'de' => [
'gearsdigital.enhanced-toolbar-link-dialog.internal' => 'Interner Link',
Expand Down

0 comments on commit 6f2b28b

Please sign in to comment.