Skip to content

Commit 0831dac

Browse files
authored
docs: add "back to the top" button (#2602)
* feat: use non-breaking space * feat: add back on top button
1 parent 5ddb5e7 commit 0831dac

File tree

1 file changed

+10
-2
lines changed
  • scripts/expand_website_templates

1 file changed

+10
-2
lines changed

scripts/expand_website_templates/main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
2626
)
2727

28+
const listItemPrefix = "list-item-"
29+
2830
var stateFilePath = filepath.Join("docs", "template_data.state")
2931

3032
func main() {
@@ -257,7 +259,7 @@ func getName(lc *linter.Config) string {
257259
}
258260

259261
if hasSettings(lc.Name()) {
260-
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
262+
name = fmt.Sprintf("%s [%s](#%s)", name, spanWithID(listItemPrefix+lc.Name(), "Configuration", "⚙️"), lc.Name())
261263
}
262264

263265
if !lc.IsDeprecated() {
@@ -269,7 +271,7 @@ func getName(lc *linter.Config) string {
269271
title += fmt.Sprintf(" since %s", lc.Deprecation.Since)
270272
}
271273

272-
return name + " " + span(title, "⚠")
274+
return name + " " + span(title, "⚠")
273275
}
274276

275277
func getDesc(lc *linter.Config) string {
@@ -307,6 +309,10 @@ func span(title, icon string) string {
307309
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
308310
}
309311

312+
func spanWithID(id, title, icon string) string {
313+
return fmt.Sprintf(`<span id=%q title=%q>%s</span>`, id, title, icon)
314+
}
315+
310316
func getThanksList() string {
311317
var lines []string
312318
addedAuthors := map[string]bool{}
@@ -472,6 +478,8 @@ func getLintersSettingSnippets(node, nextNode *yaml.Node) (string, error) {
472478

473479
_, _ = fmt.Fprintln(builder, "```")
474480
_, _ = fmt.Fprintln(builder)
481+
_, _ = fmt.Fprintf(builder, "[%s](#%s)\n\n", span("Back to the top", "🔼"), listItemPrefix+nextNode.Content[i].Value)
482+
_, _ = fmt.Fprintln(builder)
475483
}
476484

477485
return builder.String(), nil

0 commit comments

Comments
 (0)