Commit fdf6456c authored by Trevor Slocum's avatar Trevor Slocum

Rewrite links to subpackage import paths

parent 6387f686
Pipeline #116044254 passed with stages
in 2 minutes and 20 seconds
0.1.4:
- Rewrite links to subpackage import paths
0.1.3:
- Add --exclude flag
- Fix compilation on Windows
......
......@@ -60,7 +60,34 @@ func updatePage(doc *goquery.Document, basePath string, siteName string) {
importPathDisplayText := importPathDisplay.Text()
if strings.ContainsRune(importPathDisplayText, '.') && strings.HasPrefix(importPathDisplayText, `import "`) && strings.HasSuffix(importPathDisplayText, `"`) {
importPath := importPathDisplayText[8 : len(importPathDisplayText)-1]
importPathDisplay.SetHtml(fmt.Sprintf(`import "<a href="https://` + importPath + `" target="_blank">` + importPath + `</a>"`))
browseImportPath := importPath
var browseInsert string
if strings.HasPrefix(importPath, "gitlab.com/") {
browseInsert = "/-/tree/master"
} else if strings.HasPrefix(importPath, "github.com/") || strings.HasPrefix(importPath, "git.sr.ht/") {
browseInsert = "/tree/master"
} else if strings.HasPrefix(importPath, "bitbucket.org/") {
browseInsert = "/src/master"
}
if browseInsert != "" {
var insertPos int
var found int
for i, c := range importPath {
if c == '/' {
found++
if found == 3 {
insertPos = i
break
}
}
}
if insertPos > 0 {
browseImportPath = importPath[0:insertPos] + browseInsert + importPath[insertPos:]
}
}
importPathDisplay.SetHtml(fmt.Sprintf(`import "<a href="https://` + browseImportPath + `" target="_blank">` + importPath + `</a>"`))
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment