diff --git a/server.js b/server.js
index f8f256f..31df5ca 100644
--- a/server.js
+++ b/server.js
@@ -3,7 +3,7 @@ import express from 'express';
import cors from 'cors';
import { create } from 'express-handlebars';
-import { domain, account, simpleLogger, actorInfo } from './src/util.js';
+import { domain, account, simpleLogger, actorInfo, replaceEmptyText } from './src/util.js';
import session, { isAuthenticated } from './src/session-auth.js';
import * as bookmarksDb from './src/bookmarks-db.js';
import * as apDb from './src/activity-pub-db.js';
@@ -97,6 +97,9 @@ const hbs = create({
eq(a, b, options) {
return a === b ? options.fn(this) : options.inverse(this);
},
+ setTitle(item) {
+ return replaceEmptyText(item.title, item.url);
+ },
},
partialsDir: './src/pages/partials',
extname: '.hbs',
diff --git a/src/activitypub.js b/src/activitypub.js
index 1f81fac..c709936 100644
--- a/src/activitypub.js
+++ b/src/activitypub.js
@@ -2,7 +2,7 @@ import fetch from 'node-fetch';
import crypto from 'crypto';
import { signedGetJSON, signedPostJSON } from './signature.js';
-import { actorInfo, actorMatchesUsername } from './util.js';
+import { actorInfo, actorMatchesUsername, replaceEmptyText } from './util.js';
function getGuidFromPermalink(urlString) {
return urlString.match(/(?:\/m\/)([a-zA-Z0-9+/]+)/)[1];
@@ -34,9 +34,10 @@ export function createNoteObject(bookmark, account, domain) {
type: 'Note',
published: d.toISOString(),
attributedTo: `https://${domain}/u/${account}`,
- content: `
- ${bookmark.title}
- ${bookmark.description?.replace('\n', '
') || ''}`,
+ content: `${replaceEmptyText(
+ bookmark.title,
+ bookmark.url,
+ )}
${bookmark.description?.trim().replace('\n', '
') || ''}`,
to: [`https://${domain}/u/${account}/followers/`, 'https://www.w3.org/ns/activitystreams#Public'],
tag: [],
};
diff --git a/src/pages/bookmark.hbs b/src/pages/bookmark.hbs
index d77d1f2..b4bf040 100644
--- a/src/pages/bookmark.hbs
+++ b/src/pages/bookmark.hbs
@@ -1,7 +1,7 @@