page

package
v0.0.0-...-1ce7731 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package page contains code to render pages that can be used from backend and frontend.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportPathElementsHTML

func ImportPathElementsHTML(repoImportPath, importPath, rawQuery string) template.HTML

ImportPathElementsHTML renders the HTML of the import path with linkified elements.

Example
package main

import (
	"fmt"

	"github.com/shurcooL/gtdo/page"
)

func main() {
	inputs := []struct {
		repoImportPath string
		importPath     string
	}{
		{"github.com/shurcooL/go", "github.com/shurcooL/go/u/u10"},
		{"rsc.io/pd&f", "rsc.io/pd&f"},
		{"rsc.io/pdf", "rsc.io/pdf"},
		{"rsc.io/pdf", "rsc.io/pdf/pdfpasswd"},
		{"io", "io"},
		{"io", "io/ioutil"},
	}

	for _, i := range inputs {
		html := page.ImportPathElementsHTML(i.repoImportPath, i.importPath, "")
		fmt.Println(html)
	}

}
Output:

<a href="/github.com/shurcooL/go">github.com/shurcooL/go</a>/<a href="/github.com/shurcooL/go/u">u</a>/u10
rsc.io/pd&amp;f
rsc.io/pdf
<a href="/rsc.io/pdf">rsc.io/pdf</a>/pdfpasswd
io
<a href="/io">io</a>/ioutil

func Tabs

func Tabs(path string, rawQuery string) template.HTML

Tabs renders the html for <nav> element with tab header links.

Types

type State

type State struct {
	ImportPath   string
	RepoSpec     repoSpec
	ProcessedRev string // ProcessedRev is processed rev; its value is replaced by default branch if empty.
	CommitID     string
}

State that is passed to the frontend script from the backend handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL