diff --git a/docs/widgets/services/linkwarden.md b/docs/widgets/services/linkwarden.md index 3e731f25..d5a9fb27 100644 --- a/docs/widgets/services/linkwarden.md +++ b/docs/widgets/services/linkwarden.md @@ -14,17 +14,14 @@ widget: key: myApiKeyHere # On your Linkwarden install, go to Settings > Access Tokens. Generate a token. ``` -Use `mode` to show the stats found in the fields and/or the recent bookmarks. - -Examples: -`mode: ["stats", "recent"]` or `mode: ["stats"]` or `mode: ["recent"]` +Use `mode` to show a list of recent bookmarks. ```yaml widget: type: linkwarden url: http://linkwarden.host.or.ip key: myApiKeyHere - mode: ["stats", "recent"] + mode: ["recent"] ``` Use `params` to set which collections and/or tags to display links from. diff --git a/src/widgets/linkwarden/component.jsx b/src/widgets/linkwarden/component.jsx index 5c3f9a89..b11e9b14 100644 --- a/src/widgets/linkwarden/component.jsx +++ b/src/widgets/linkwarden/component.jsx @@ -10,7 +10,7 @@ export default function Component({ service }) { // Assign icons. Assign recent/collections/tags to query by id(s) const bookmarkTypes = useMemo( () => ({ - recent: { ids: widget.mode.includes("recent") ? ["0"] : [] }, // "0" Is a made-up number used to allow looping in processBookmarks() + recent: { ids: widget.mode?.includes("recent") ? ["0"] : [] }, // "0" Is a made-up number used to allow looping in processBookmarks() collection: { ids: widget.params?.collectionIds ? widget.params.collectionIds : [], }, @@ -195,64 +195,66 @@ export default function Component({ service }) { // Render when data is available return ( <> - {widget.mode.includes("stats") && ( - - - - - - )} + + + + + - {Object.keys(bookmarks).map((type) => ( -
- {Object.values(bookmarks[type].data).map((bookmarkList) => ( -
-
- - {`${bookmarks[type].icon} ${bookmarkList.title}`} - - {`(${bookmarkList.total})`} + {Object.keys(bookmarks).map((type) => { + const dataAvailable = Object.keys(bookmarks[type].data).length > 0; + + return dataAvailable ? ( +
+ {Object.values(bookmarks[type].data).map((bookmarkList) => ( +
+ +
- -
- ))} -
- ))} + ))} +
+ ) : null; // Render nothing if there's no data + })} ); }