chore(addLinkToShare.js): add author url in search results when adding link

This commit is contained in:
Cory Dransfeldt 2025-06-09 15:31:46 -07:00
parent c54d27dc33
commit f2bca309f5
No known key found for this signature in database
4 changed files with 15 additions and 7 deletions

View file

@ -7,3 +7,5 @@ export const sanitizeMediaString = (input) => {
return slugified.replace(/^-+|-+$/g, '');
}
export const removeUrlProtocol = (url) => url ? url.replace(/^https?:\/\//, '') : '';

View file

@ -1,6 +1,7 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, searchItems, createItem } from '../directus/client.js';
import { removeUrlProtocol } from '../sanitize.js';
export const addLinkToShare = async () => {
const config = await loadConfig();
@ -68,10 +69,15 @@ export const addLinkToShare = async () => {
type: 'list',
name: 'author',
message: 'Select an author:',
choices: authorMatches.map(a => ({
name: a.name || a.id,
value: a.id,
}))
choices: authorMatches.map(a => {
const cleanUrl = removeUrlProtocol(a.url);
const display = cleanUrl ? `${a.name} (${cleanUrl})` : a.name;
return {
name: display,
value: a.id,
};
})
});
author = response.author;

4
cli/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd",
"version": "3.2.0",
"version": "3.2.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd",
"version": "3.2.0",
"version": "3.2.1",
"dependencies": {
"@directus/sdk": "^19.1.0",
"chalk": "^5.4.1",

View file

@ -1,6 +1,6 @@
{
"name": "coryd",
"version": "3.2.0",
"version": "3.2.1",
"description": "The CLI for my site to run scripts, manage and download assets.",
"type": "module",
"bin": {