diff --git a/docs/configuration.md b/docs/configuration.md index 174de834d..8fc0d9b1f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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 ``` @@ -2810,17 +2810,17 @@ 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 @@ -2828,6 +2828,7 @@ symbol-link-template: https://www.google.com/search?tbm=nws&q={SYMBOL} | ---- | ---- | -------- | | symbol | string | yes | | name | string | no | +| market | string | no | | symbol-link | string | no | | chart-link | string | no | @@ -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. diff --git a/internal/glance/widget-markets.go b/internal/glance/widget-markets.go index b53b10a11..f78b21c46 100644 --- a/internal/glance/widget-markets.go +++ b/internal/glance/widget-markets.go @@ -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) } } @@ -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"` }