chore(addLinkToShare.js): add author url in search results when adding link
This commit is contained in:
parent
c54d27dc33
commit
f2bca309f5
4 changed files with 15 additions and 7 deletions
|
@ -7,3 +7,5 @@ export const sanitizeMediaString = (input) => {
|
||||||
|
|
||||||
return slugified.replace(/^-+|-+$/g, '');
|
return slugified.replace(/^-+|-+$/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const removeUrlProtocol = (url) => url ? url.replace(/^https?:\/\//, '') : '';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import { loadConfig } from '../config.js';
|
import { loadConfig } from '../config.js';
|
||||||
import { initDirectusClient, searchItems, createItem } from '../directus/client.js';
|
import { initDirectusClient, searchItems, createItem } from '../directus/client.js';
|
||||||
|
import { removeUrlProtocol } from '../sanitize.js';
|
||||||
|
|
||||||
export const addLinkToShare = async () => {
|
export const addLinkToShare = async () => {
|
||||||
const config = await loadConfig();
|
const config = await loadConfig();
|
||||||
|
@ -68,10 +69,15 @@ export const addLinkToShare = async () => {
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'author',
|
name: 'author',
|
||||||
message: 'Select an author:',
|
message: 'Select an author:',
|
||||||
choices: authorMatches.map(a => ({
|
choices: authorMatches.map(a => {
|
||||||
name: a.name || a.id,
|
const cleanUrl = removeUrlProtocol(a.url);
|
||||||
|
const display = cleanUrl ? `${a.name} (${cleanUrl})` : a.name;
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: display,
|
||||||
value: a.id,
|
value: a.id,
|
||||||
}))
|
};
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
author = response.author;
|
author = response.author;
|
||||||
|
|
4
cli/package-lock.json
generated
4
cli/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd",
|
"name": "coryd",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd",
|
"name": "coryd",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@directus/sdk": "^19.1.0",
|
"@directus/sdk": "^19.1.0",
|
||||||
"chalk": "^5.4.1",
|
"chalk": "^5.4.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd",
|
"name": "coryd",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"description": "The CLI for my site to run scripts, manage and download assets.",
|
"description": "The CLI for my site to run scripts, manage and download assets.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue