mirror of https://github.com/bastienwirtz/homer
Rework Linkding integration based on feedback on the PR
parent
e1fdb0069b
commit
a63f9e2c7c
|
@ -1,8 +1,6 @@
|
|||
<template>
|
||||
<template v-for="bookmark in bookmarks" :key="bookmark.name">
|
||||
<Generic :item="bookmark">
|
||||
</Generic>
|
||||
</template>
|
||||
<Generic v-for="bookmark in bookmarks" :key="bookmark.name" :item="bookmark">
|
||||
</Generic>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -16,16 +14,16 @@ export default {
|
|||
},
|
||||
mixins: [service],
|
||||
props: {
|
||||
item: Object
|
||||
item: Object,
|
||||
},
|
||||
data: () => ({
|
||||
bookmarks: [],
|
||||
}),
|
||||
computed: {
|
||||
calculatedLimit: function () {
|
||||
let limit = this.item.limit ? this.item.limit : 5;
|
||||
return Math.min(Math.max(limit,1),15);
|
||||
}
|
||||
const limit = parseInt(this.item.limit) || 5;
|
||||
return Math.min(Math.max(limit, 1), 15);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.fetchBookmarks();
|
||||
|
@ -37,32 +35,29 @@ export default {
|
|||
Accept: "application/json",
|
||||
};
|
||||
|
||||
let limit = this.calculatedLimit;
|
||||
|
||||
let query = ''
|
||||
let query = "";
|
||||
if (this.item.query) {
|
||||
query = `&q=${encodeURIComponent(this.item.query)}`;
|
||||
}
|
||||
|
||||
let url = `/api/bookmarks/?limit=${limit}${query}`;
|
||||
let url = `/api/bookmarks/?limit=${this.calculatedLimit}${query}`;
|
||||
|
||||
this.fetch(url, {
|
||||
headers,
|
||||
})
|
||||
.then((ld_response) => {
|
||||
this.bookmarks = ld_response.results.map(bookmark => ({
|
||||
name: `${bookmark.title}`,
|
||||
subtitle: `${bookmark.description}`,
|
||||
url: bookmark.url,
|
||||
logo: `${bookmark.favicon_url}`,
|
||||
tag: `${bookmark.tag_names.join(" #")}`
|
||||
}));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
this.error = true;
|
||||
});
|
||||
.then((ld_response) => {
|
||||
this.bookmarks = ld_response.results.map((bookmark) => ({
|
||||
name: `${bookmark.title}`,
|
||||
subtitle: `${bookmark.description}`,
|
||||
url: bookmark.url,
|
||||
logo: `${bookmark.favicon_url}`,
|
||||
tag: `${bookmark.tag_names.join(" #")}`,
|
||||
}));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue