summary refs log tree commit diff stats
path: root/page.templ
blob: d6c15ef47b0b4cd8a38ee0d440ea85f9526ab800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package main

templ Page(config *Config, pkg *Package) {
	<!DOCTYPE html>
	<html lang="en">
		<head>
			<meta charset="utf-8"/>
			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
			if pkg != nil {
				<meta name="go-import" content={ importString(config, *pkg) }/>
				<meta name="go-source" content={ sourceString(config, *pkg) }/>
			}
			<style>
      :root {
        --width: 800px;
        --font-main: Verdana, sans-serif;
        --font-secondary: Verdana, sans-serif;
        --font-scale: 1em;
        --background-color: #fff;
        --heading-color: #222;
        --text-color: #444;
        --link-color: #3273dc;
        --visited-color: #8b6fcb;
        --code-background-color: #f2f2f2;
        --code-color: #222;
        --blockquote-color: #222;
        --icon-external-link: url("/external-link.svg");
      }

      @media (prefers-color-scheme: dark) {
        :root {
          --background-color: #01242e;
          --heading-color: #eee;
          --text-color: #ddd;
          --link-color: #8cc2dd;
          --visited-color: #8b6fcb;
          --code-background-color: #000;
          --code-color: #ddd;
          --blockquote-color: #ccc;
        }
      }

      body {
        font-family: var(--font-secondary);
        font-size: var(--font-scale);
        margin: auto;
        padding: 20px;
        max-width: var(--width);
        text-align: left;
        background-color: var(--background-color);
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
        color: var(--text-color);
      }

      h1,
      h2,
      h3,
      h4,
      h5,
      h6 {
        font-family: var(--font-main);
        color: var(--heading-color);
        & > a {
          color: var(--heading-color);
        }
      }

      a {
        color: var(--link-color);
        cursor: pointer;
      }

      nav a {
        margin-right: 8px;
      }

      strong,
      b {
        color: var(--heading-color);
      }

      main {
        margin-top: 2ex;
        line-height: 1.6;
      }

      table {
        width: 100%;
      }
      </style>
			<title>{ config.Title }</title>
		</head>
		<body>
			<header>
				<h1>{ config.Title }</h1>
				<nav>
					for _, link := range config.Menu {
						<a href={ templ.SafeURL(link.URL) }>{ link.Name }</a>
					}
				</nav>
			</header>
			<main>
				{ children... }
			</main>
		</body>
	</html>
}

templ ListPage(config *Config) {
	@Page(config, nil) {
		<table>
			<thead>
				<tr>
					<th>Name</th>
					<th>Source</th>
					<th>Documentation</th>
				</tr>
			</thead>
			<tbody>
				for _, pkg := range config.Packages {
					<tr>
						<td>{ packageImportPath(config, pkg) }</td>
						<td><a href={ templ.SafeURL(packageForgeURL(config, pkg)) }>Source </a></td>
						<td>
							@GodocBadge(config, pkg)
						</td>
					</tr>
				}
			</tbody>
		</table>
	}
}

templ PackagePage(config *Config, pkg *Package) {
	@Page(config, pkg) {
		<p>You're probably looking for the <a href={ templ.SafeURL(godocURL(config, pkg)) }>documentation</a>.</p>
	}
}

templ GodocBadge(config *Config, pkg *Package) {
	<a href={ templ.SafeURL(godocURL(config, pkg)) }>
		Go Reference
	</a>
}