Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ pages:
columns:
- size: full
widgets:
$include: rss.yml
- $include: rss.yml
- name: News
columns:
- size: full
widgets:
- type: group
widgets:
$include: rss.yml
- $include: rss.yml
- type: reddit
subreddit: news
```
Expand Down Expand Up @@ -2810,24 +2810,25 @@ An array of markets for which to display information about.
By default the markets are displayed in the order they were defined. You can customize their ordering by setting the `sort-by` property to `change` for descending order based on the stock's percentage change (e.g. 1% would be sorted higher than -1%) or `absolute-change` for descending order based on the stock's absolute price change (e.g. -1% would be sorted higher than +0.5%).

##### `chart-link-template`
A template for the link to go to when clicking on the chart that will be applied to all markets. The value `{SYMBOL}` will be replaced with the symbol of the market. You can override this on a per-market basis by specifying a `chart-link` property. Example:
A template for the link to go to when clicking on the chart that will be applied to all markets. The value `{SYMBOL}` will be replaced with the symbol of the market, and `{MARKET}` will be replaced with the market parameter. You can override this on a per-market basis by specifying a `chart-link` property. Example:

```yaml
chart-link-template: https://www.tradingview.com/chart/?symbol={SYMBOL}
chart-link-template: https://www.tradingview.com/chart/?symbol={SYMBOL}?market={MARKET}
```

##### `symbol-link-template`
A template for the link to go to when clicking on the symbol that will be applied to all markets. The value `{SYMBOL}` will be replaced with the symbol of the market. You can override this on a per-market basis by specifying a `symbol-link` property. Example:
A template for the link to go to when clicking on the symbol that will be applied to all markets. The value `{SYMBOL}` will be replaced with the symbol of the market, and `{MARKET}` will be replaced with the market parameter. You can override this on a per-market basis by specifying a `symbol-link` property. Example:

```yaml
symbol-link-template: https://www.google.com/search?tbm=nws&q={SYMBOL}
symbol-link-template: https://www.google.com/finance/beta/quote/{SYMBOL}:{MARKET}
```

###### Properties for each market
| Name | Type | Required |
| ---- | ---- | -------- |
| symbol | string | yes |
| name | string | no |
| market | string | no |
| symbol-link | string | no |
| chart-link | string | no |

Expand All @@ -2839,6 +2840,10 @@ The symbol, as seen in Yahoo Finance.

The name that will be displayed under the symbol.

`market`

The market the symbol belongs to, which can be used in `{MARKET}` replacements.

`symbol-link`

The link to go to when clicking on the symbol.
Expand Down
7 changes: 5 additions & 2 deletions internal/glance/widget-markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ func (widget *marketsWidget) initialize() error {
m := &widget.MarketRequests[i]

if widget.ChartLinkTemplate != "" && m.ChartLink == "" {
m.ChartLink = strings.ReplaceAll(widget.ChartLinkTemplate, "{SYMBOL}", m.Symbol)
link := strings.ReplaceAll(widget.ChartLinkTemplate, "{SYMBOL}", m.Symbol)
m.ChartLink = strings.ReplaceAll(link, "{MARKET}", m.Market)
}

if widget.SymbolLinkTemplate != "" && m.SymbolLink == "" {
m.SymbolLink = strings.ReplaceAll(widget.SymbolLinkTemplate, "{SYMBOL}", m.Symbol)
link := strings.ReplaceAll(widget.SymbolLinkTemplate, "{SYMBOL}", m.Symbol)
m.SymbolLink = strings.ReplaceAll(link, "{MARKET}", m.Market)
}
}

Expand Down Expand Up @@ -70,6 +72,7 @@ func (widget *marketsWidget) Render() template.HTML {
type marketRequest struct {
CustomName string `yaml:"name"`
Symbol string `yaml:"symbol"`
Market string `yaml:"market"`
ChartLink string `yaml:"chart-link"`
SymbolLink string `yaml:"symbol-link"`
}
Expand Down