Using common for socials definitions.

This commit is contained in:
2025-12-28 06:00:46 +01:00
parent 2b338e32eb
commit 8d6da08519
5 changed files with 5 additions and 33 deletions

View File

@@ -19,7 +19,7 @@ import { curateStash } from './stashes.js';
import escape from '../utils/escape-manticore.js';
import slugify from '../utils/slugify.js';
import { curateRevision } from './revisions.js';
import { interpolateProfiles } from '../common/actors.mjs'; // eslint-disable-line import/namespace
import { interpolateProfiles, platformsByHostname } from '../common/actors.mjs'; // eslint-disable-line import/namespace
import { resolvePlace } from '../common/geo.mjs'; // eslint-disable-line import/namespace
const logger = initLogger();
@@ -824,16 +824,6 @@ function convertWeight(weight, units) {
return Number(weight) || null;
}
const platformsByHostname = Object.fromEntries(Object.entries(config.socials.urls).map(([platform, url]) => {
const { hostname, pathname } = new URL(url);
return [hostname, {
platform,
pathname: decodeURIComponent(pathname),
url,
}];
}));
function curateSocials(socials) {
return socials.map((social) => {
if (!social.handle && !social.url) {

View File

@@ -4,6 +4,7 @@ import { renderPage } from 'vike/server'; // eslint-disable-line import/extensio
import { fetchUserStashes } from '../stashes.js';
import { fetchUserTemplates } from '../users.js';
import { fetchUnseenNotificationsCount } from '../alerts.js';
import { socials } from '../../common/actors.mjs'; // eslint-disable-line import/namespace
export default async function mainHandler(req, res, next) {
const [stashes, templates, unseenNotifications] = req.user ? await Promise.all([
@@ -43,7 +44,7 @@ export default async function mainHandler(req, res, next) {
media: config.media,
psa: config.psa,
links: config.links,
socials: config.socials,
socials,
},
meta: {
now: new Date().toISOString(),