Skip to content

Commit

Permalink
feat: merge info and link in one (#182)
Browse files Browse the repository at this point in the history
* feat: merge info and link in one

* fix: link should be on title

* fix several conditions

* fix condition
  • Loading branch information
MaikoTan authored Mar 21, 2024
1 parent 08dbfac commit 5266a54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/core/src/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,25 @@ export function apply(ctx: Context, config: Config) {
</message>,
)
case OutputType.ImageAndLink:
if (image.pageUrl || image.authorUrl)
case OutputType.ImageAndInfo:
if (image.title || image.author || image.desc)
output.unshift(
<message>
<p>
<i18n path='.output.link'>{[image.pageUrl]}</i18n>
</p>
<p>
<i18n path='.output.homepage'>{[image.authorUrl]}</i18n>
{config.output >= OutputType.ImageAndLink && image.pageUrl ? (
<a href={image.pageUrl}>{image.title}</a>
) : (
image.title
)}
</p>
</message>,
)
case OutputType.ImageAndInfo:
if (image.title && image.author && image.desc)
output.unshift(
<message>
<p>{image.title}</p>
<p>
<i18n path='.output.author'>{[image.author]}</i18n>
{config.output >= OutputType.ImageAndLink && image.authorUrl ? (
<a href={image.authorUrl}>
<i18n path='.output.author'>{[image.author]}</i18n>
</a>
) : (
<i18n path='.output.author'>{[image.author]}</i18n>
)}
</p>
<p>
<i18n path='.output.desc'>{[image.desc]}</i18n>
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ commands:
no-result: 没有找到符合条件的图片
no-image: 获取图片失败
output:
desc: '{0}'
author: '作者: {0}'
homepage: '作者主页: {0}'
link: '页面地址: {0}'
Expand Down

0 comments on commit 5266a54

Please sign in to comment.