Skip to content

Commit

Permalink
Allow function for url action and startUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw committed Jan 4, 2024
1 parent d542fce commit 3bc4288
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/sourcebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ class SourceBot {
}

makeUrl (url) {
if (typeof url === 'function') {
return url(this.articleInfo, this.getParams())
}
url = interpolate(url, this.articleInfo, '', encodeURIComponent)
const params = this.getParams()
url = interpolate(url, params, 'source', encodeURIComponent)
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export type MessageAction = {
message: string
}
export type UrlAction = {
url: string
url: string | ((articleInfo: ArticleInfo, sourceParams: SiteSourceParams) => string)
}
export type ScriptAction = {
script: string
Expand Down

0 comments on commit 3bc4288

Please sign in to comment.