Skip to content

Commit

Permalink
feat: add back on top button
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 18, 2022
1 parent f6b9ea7 commit ab27ca5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
)

const listItemPrefix = "list-item-"

var stateFilePath = filepath.Join("docs", "template_data.state")

func main() {
Expand Down Expand Up @@ -257,7 +259,7 @@ func getName(lc *linter.Config) string {
}

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

if !lc.IsDeprecated() {
Expand Down Expand Up @@ -307,6 +309,10 @@ func span(title, icon string) string {
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}

func spanWithID(id, title, icon string) string {
return fmt.Sprintf(`<span id=%q title=%q>%s</span>`, id, title, icon)
}

func getThanksList() string {
var lines []string
addedAuthors := map[string]bool{}
Expand Down Expand Up @@ -472,6 +478,8 @@ func getLintersSettingSnippets(node, nextNode *yaml.Node) (string, error) {

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

return builder.String(), nil
Expand Down

0 comments on commit ab27ca5

Please sign in to comment.