Skip to content

Commit 67baa9d

Browse files
committed
title bug
1 parent 15911b6 commit 67baa9d

1 file changed

Lines changed: 64 additions & 5 deletions

File tree

app.js

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,31 @@ async function initSQLite() {
8787
async function loadBookmarks() {
8888
updateLoadingMessage('Loading bookmarks...');
8989
try {
90-
const lists = db.exec({ sql: `SELECT id, name, description, icon, parentId FROM bookmarkLists ORDER BY name`, returnValue: "resultRows", rowMode: "object" });
91-
const bookmarksInLists = db.exec({ sql: `SELECT b.id, b.title, bl.url, bl.favicon, bl.description, bil.listId FROM bookmarks b JOIN bookmarkLinks bl ON b.id = bl.id JOIN bookmarksInLists bil ON b.id = bil.bookmarkId WHERE b.type = 'link' ORDER BY b.title`, returnValue: "resultRows", rowMode: "object" });
90+
const lists = db.exec({
91+
sql: `SELECT id, name, description, icon, parentId FROM bookmarkLists ORDER BY name`,
92+
returnValue: "resultRows",
93+
rowMode: "object"
94+
});
95+
96+
// FIXED: Now selecting both b.title and bl.title
97+
const bookmarksInLists = db.exec({
98+
sql: `SELECT
99+
b.id,
100+
b.title as bookmark_title,
101+
bl.title as link_title, -- Added this line to get the crawled title
102+
bl.url,
103+
bl.favicon,
104+
bl.description,
105+
bil.listId
106+
FROM bookmarks b
107+
JOIN bookmarkLinks bl ON b.id = bl.id
108+
JOIN bookmarksInLists bil ON b.id = bil.bookmarkId
109+
WHERE b.type = 'link'
110+
ORDER BY COALESCE(b.title, bl.title)`,
111+
returnValue: "resultRows",
112+
rowMode: "object"
113+
});
114+
92115
bookmarksData = bookmarksInLists;
93116

94117
const listsById = {};
@@ -220,9 +243,45 @@ function renderList(list, level = 0) {
220243

221244
// Render a single bookmark item
222245
function renderBookmark(bookmark) {
223-
const faviconUrl = bookmark.favicon || `https://www.google.com/s2/favicons?domain=${new URL(bookmark.url).hostname}`;
224-
const target = config.bookmarkTarget === '_blank' ? 'target="_blank" rel="noopener noreferrer"' : '';
225-
return `<a href="${escapeHtml(bookmark.url)}" class="bookmark-item" title="${escapeHtml(bookmark.title || bookmark.url)}" ${target}><img src="${escapeHtml(faviconUrl)}" alt="" class="bookmark-favicon" loading="lazy"><span class="bookmark-title">${escapeHtml(bookmark.title || 'Untitled')}</span></a>`;
246+
// Now we have bookmark_title and link_title from the query
247+
// Priority: bookmark_title (user-set) > link_title (crawled) > 'Untitled'
248+
let title = bookmark.bookmark_title || bookmark.link_title || 'Untitled';
249+
250+
const url = bookmark.url || bookmark.asset?.sourceUrl || '#';
251+
252+
// Get favicon URL
253+
let faviconUrl = bookmark.favicon || '';
254+
if (!faviconUrl && bookmark.url) {
255+
try {
256+
// Fallback to Google's favicon service
257+
const domain = new URL(bookmark.url).hostname;
258+
faviconUrl = `https://www.google.com/s2/favicons?domain=${domain}&sz=32`;
259+
} catch (e) {
260+
// Invalid URL, skip favicon
261+
}
262+
}
263+
264+
// Determine target attribute
265+
const target = (config && config.bookmarkTarget) || '_self';
266+
267+
return `
268+
<a href="${url}"
269+
class="bookmark-item"
270+
title="${title}"
271+
target="${target}"
272+
rel="${target === '_blank' ? 'noopener noreferrer' : ''}"
273+
draggable="false">
274+
<div class="bookmark-content">
275+
${faviconUrl ? `
276+
<img src="${faviconUrl}"
277+
alt=""
278+
class="bookmark-favicon"
279+
onerror="this.style.display='none'">
280+
` : ''}
281+
<span class="bookmark-title">${title}</span>
282+
</div>
283+
</a>
284+
`;
226285
}
227286

228287
// MODIFIED: Initializes SortableJS on each column and groups them

0 commit comments

Comments
 (0)