Skip to content

Commit

Permalink
Merge pull request #8 from gearsdigital/remove-domain-from-page-url-#2
Browse files Browse the repository at this point in the history
Remove domain from page url #2
  • Loading branch information
gearsdigital committed Jan 24, 2020
2 parents 807936d + 4728e95 commit 3ecc860
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 33 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
<?php

use Kirby\Http\Url;

Kirby::plugin('gearsdigital/enhanced-toolbar-link-dialog', [
'api' => [
'routes' => [
'models' => [
// a camelCased model name results in Kirby\Exception\NotFoundException
'simplepagemodel' => [
'type' => 'Kirby\Cms\Page',
'fields' => [
'id' => function ($page) {
return $page->id();
},
'title' => function ($page) {
return $page->title()->value();
},
'slug' => function ($page) {
return URL::makeAbsolute($page->slug());
},
],
],
],
'collections' => [
'simplepagecollection' => [
'model' => 'simplepagemodel',
'type' => 'Kirby\Toolkit\Collection',
],
],
'routes' => [
[
'pattern' => 'enhanced-toolbar-link-dialog/pages',
'method' => 'get',
'action' => function () {
$page = get('page');
$query = get('search', '*');
$query = get('search');

if (empty($query)) {
$query = '*';
}

return site()->search($query, 'title')->paginate([
$pagedCollection = site()->search($query, 'title')->paginate([
'page' => $page,
'limit' => 10,
]);

return $this->collection('simplepagecollection', $pagedCollection);
},
],
],
Expand All @@ -25,12 +53,12 @@
'en' => [
'gearsdigital.enhanced-toolbar-link-dialog.internal' => 'Internal Link',
'gearsdigital.enhanced-toolbar-link-dialog.external' => 'External Link',
'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'No pages found',
'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'No pages found',
],
'de' => [
'gearsdigital.enhanced-toolbar-link-dialog.internal' => 'Interner Link',
'gearsdigital.enhanced-toolbar-link-dialog.external' => 'Externer Link',
'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'Keine Seiten gefunden.',
'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'Keine Seiten gefunden.',
],
],
]);
18 changes: 9 additions & 9 deletions src/components/EnhancedToolbarLinkDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
icon="search"
/>

<k-list v-if="pages.length > 0">
<k-list v-if="hasPages">
<k-list-item
v-for="page in pages"
:key="page.id"
Expand Down Expand Up @@ -85,10 +85,6 @@

<script>
export default {
props: {
pages: Array,
text: String
},
data() {
return {
tabs: [
Expand All @@ -104,6 +100,7 @@
search: null,
currentPage: {},
currentTab: {},
pages: [],
value: {
url: null,
text: null
Expand Down Expand Up @@ -133,6 +130,9 @@
}, 200)
},
computed: {
hasPages() {
return this.pages.length
},
kirbytext() {
return this.$store.state.system.info.kirbytext;
}
Expand All @@ -157,7 +157,7 @@
},
selectPage(model) {
this.value = {
url: model.url,
url: model.slug,
text: this.value.text || model.title
};
if (this.isCurrentPage(model)) {
Expand Down Expand Up @@ -197,9 +197,9 @@
search: this.search
};
this.$api.get('enhanced-toolbar-link-dialog/pages', params).then(response => {
this.pages = response.data;
this.pagination = response.pagination;
});
this.pages = response.data;
this.pagination = response.pagination;
});
},
submit() {
this.$emit("submit", this.kirbytext ? this.createKirbytext() : this.createMarkdown());
Expand Down

0 comments on commit 3ecc860

Please sign in to comment.