Skip to content

Commit c2935a7

Browse files
committed
feat: add back on top button
1 parent f6b9ea7 commit c2935a7

File tree

1 file changed

+9
-1
lines changed
  • scripts/expand_website_templates

1 file changed

+9
-1
lines changed

scripts/expand_website_templates/main.go

+9-1
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() {
@@ -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 string, 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 on top", "🔼"), listItemPrefix+nextNode.Content[i].Value)
482+
_, _ = fmt.Fprintln(builder)
475483
}
476484

477485
return builder.String(), nil

0 commit comments

Comments
 (0)