Skip to content

Commit

Permalink
docs: update pdocs
Browse files Browse the repository at this point in the history
docs: fixed link
  • Loading branch information
neurosnap committed Jul 12, 2024
1 parent c31c49e commit c6b345d
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 142 deletions.
48 changes: 5 additions & 43 deletions docs/cmd/ssg.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"log/slog"

"github.com/picosh/pdocs"
)

Expand All @@ -14,74 +16,34 @@ func main() {
Text: "Getting Started",
Href: "/getting-started",
Page: pager("getting-started.md"),
Tag: "Help",
Children: []*pdocs.Sitemap{
{Text: "Managed", Href: "#managed"},
{Text: "DNS", Href: "#dns"},
{Text: "Docker Compose", Href: "#docker-compose"},
{Text: "Docker", Href: "#docker"},
{Text: "Google Cloud Platform", Href: "#google-cloud-platform"},
{Text: "Authentication", Href: "#authentication"},
},
},
{
Text: "How it Works",
Href: "/how-it-works",
Page: pager("how-it-works.md"),
Tag: "Help",
Children: []*pdocs.Sitemap{
{Text: "Port Forward", Href: "#port-forward"},
{Text: "Traditional VPN", Href: "#traditional-vpn"},
{Text: "sish Public", Href: "#sish-public"},
{Text: "sish Private", Href: "#sish-private"},
},
},
{
Text: "Forwarding Types",
Href: "/forwarding-types",
Page: pager("forwarding-types.md"),
Tag: "Help",
Children: []*pdocs.Sitemap{
{Text: "HTTP", Href: "#href"},
{Text: "TCP", Href: "#tcp"},
{Text: "TCP Alias", Href: "#tcp-alias"},
{Text: "SNI", Href: "#sni"},
},
},
{
Text: "Cheatsheet",
Href: "/cheatsheet",
Page: pager("cheatsheet.md"),
Tag: "Help",
Children: []*pdocs.Sitemap{
{Text: "Remote forward SSH tunnels", Href: "#remote-forward-ssh-tunnels"},
{Text: "Local forward SSH tunnels", Href: "#local-foward-ssh-tunnels"},
{Text: "HTTPS public access", Href: "#https-public-access"},
{Text: "HTTPS private access", Href: "#https-private-access"},
{Text: "Websocket", Href: "#websocket"},
{Text: "TCP public access", Href: "#tcp-public-access"},
{Text: "TCP private access", Href: "#tcp-private-access"},
},
},
{Text: "CLI", Href: "/cli", Page: pager("cli.md"), Tag: "CLI"},
{Text: "CLI", Href: "/cli", Page: pager("cli.md")},
{
Text: "Advanced",
Href: "/advanced",
Page: pager("advanced.md"),
Children: []*pdocs.Sitemap{
{Text: "Choose your own subdomain", Href: "#choose-your-own-subdomain"},
{Text: "Websocket Support", Href: "#websocket-support"},
{Text: "Allowlist IPs", Href: "#allowlist-ips"},
{Text: "Custom Domains", Href: "#custom-domains"},
{Text: "Load Balancing", Href: "#load-balancing"},
},
Tag: "Help",
},
{Text: "FAQ", Href: "/faq", Page: pager("faq.md"), Tag: "Help"},
{Text: "FAQ", Href: "/faq", Page: pager("faq.md")},
},
}

config := &pdocs.DocConfig{
Logger: slog.Default(),

Check failure on line 46 in docs/cmd/ssg.go

View workflow job for this annotation

GitHub Actions / test

File is not `goimports`-ed (goimports)
Sitemap: sitemap,
Out: "./docs/public",
Tmpl: "./docs/tmpl",
Expand Down
2 changes: 1 addition & 1 deletion docs/posts/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ssh -p 2222 -R 80:localhost:8080 tuns.sh

# Docker

[Find our latest releases.](/releases)
[Find our latest releases.](/faq#where-can-i-find-latest-releases)

Pull the Docker image

Expand Down
40 changes: 38 additions & 2 deletions docs/static/main.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
.visited {
color: var(--visited);
}

.sitemap {
width: 150px;
width: 250px;
}

.post {
max-width: 700px;
}

.container-xs {
max-width: 20em;
width: 100%;
}

.post-container {
display: flex;
gap: 1rem;
Expand Down Expand Up @@ -99,9 +108,23 @@
min-width: 150px;
}

.sitemap-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
}

.sidebar-list {
padding: 0 0 0 1rem;
}

.sidebar-list li {
margin: 0 0 0.5rem 0;
}

@media only screen and (max-width: 800px) {
body {
padding: 0 1rem;
padding: 0 0.75rem;
}

header {
Expand All @@ -118,4 +141,17 @@
column-count: 2;
width: 100%;
}

.sitemap-grid {
grid-template-columns: repeat(1, 1fr);
}

.mk-nav {
padding: 1rem 0;
}

.sidebar-list {
padding: 0 0 0 0.6rem;
margin: 0;
}
}
23 changes: 23 additions & 0 deletions docs/tmpl/pager.partial.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{ define "pager" }}
<div class="flex justify-between gap-2 my-4">
<div class="pager max-w-half flex items-center">
{{if .Prev}}
<div class="flex flex-col items-start">
<div class="text-sm font-grey-light">&lt;&lt; PREV</div>
<a href="{{.Prev.GenHref}}" class="text-xl link-alt-adj">{{.Prev.Text}}</a>
</div>
{{end}}
</div>

<div class="pager max-w-half flex items-center justify-end">
{{if .Next}}
<div class="flex flex-col items-end">
<div class="text-sm font-grey-light">
NEXT &gt;&gt;
</div>
<a href="{{.Next.GenHref}}" class="text-xl align-right link-alt-adj">{{.Next.Text}}</a>
</div>
{{end}}
</div>
</div>
{{end}}
22 changes: 1 addition & 21 deletions docs/tmpl/post.page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,7 @@
{{.Data.Html}}
</article>

<div class="flex justify-between gap-2 my-4">
{{if .Prev}}
<div class="pager max-w-half flex items-center">
<div class="flex flex-col items-start">
<div class="text-sm font-grey-light">&lt;&lt; PREV</div>
<a href="{{.Prev.GenHref}}" class="text-xl link-alt-adj">{{.Prev.Text}}</a>
</div>
</div>
{{end}}

{{if .Next}}
<div class="pager max-w-half flex items-center justify-end">
<div class="flex flex-col items-end">
<div class="text-sm font-grey-light">
NEXT &gt;&gt;
</div>
<a href="{{.Next.GenHref}}" class="text-xl align-right link-alt-adj">{{.Next.Text}}</a>
</div>
</div>
{{end}}
</div>
{{template "pager" .}}
</main>

{{template "sitemap-footer" .}}
Expand Down
40 changes: 27 additions & 13 deletions docs/tmpl/sitemap-footer.partial.tmpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
{{define "sitemap-footer"}}
<div class="sitemap text-sm mb-4">
{{range .Sitemap.Children -}}
<div>
{{- if (and $.Prev (eq $.Prev.GenHref .GenHref)) -}}
<a href="{{.GenHref}}" class="link-alt-adj">{{.Text}}</a>
{{- else if (and $.Next (eq $.Next.GenHref .GenHref)) -}}
<a href="{{.GenHref}}" class="link-alt-adj">{{.Text}}</a>
{{- else if (eq $.Href .GenHref) -}}
<a href="{{.GenHref}}" class="link-alt-hover">{{.Text}}</a>
{{- else -}}
<a href="{{.GenHref}}" class="link-alt">{{.Text}}</a>
{{- end -}}
</div>
{{- end}}
<ul class="list-none sidebar-list">
{{range .Sitemap.Children}}
{{if .Href}}
<li class="text-md">
{{if (eq $.Href .GenHref)}}
<a href="{{.GenHref}}" class="link-alt-hover">{{.Text}}</a>
{{else}}
<a href="{{.GenHref}}" class="link-alt">{{.Text}}</a>
{{end}}
</li>
{{else}}
<li class="text-md">{{.Text}}</li>
{{end}}

{{range .Children}}
<ul class="list-none sidebar-list">
<li>
{{if (eq $.Href .GenHref)}}
<a href="{{.GenHref}}" class="link-alt-hover">{{.Text}}</a>
{{else}}
<a href="{{.GenHref}}" class="link-alt">{{.Text}}</a>
{{end}}
</li>
</ul>
{{end}}
{{end}}
</ul>
</div>
{{end}}
33 changes: 18 additions & 15 deletions docs/tmpl/toc.partial.tmpl
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{{define "toc"}}
<div>
{{range $key, $value := .SitemapByTag}}
<div class="box my">
<h2 class="text-xl">{{$key}}</h2>
<ul>
{{range $value}}
<div class="sitemap-grid">
{{range .Sitemap.Children -}}
{{if .Children}}
<div class="box my">
<h2 class="text-xl text-underline inline-block">{{.Text}}</h2>
<ul class="list-none" style="padding-left: 0;">
{{range .Children -}}
<li>
<a href="{{.GenHref}}">{{.Text}}</a>

<ul class="list-disc" style="padding-left: 2rem;">
{{range .Children}}
<li>
<a href="{{.GenHref}}">{{.Text}}</a>
{{if .Children}}
<ul>
{{range .Children}}
<li><a href="{{.ParentHref}}{{.GenHref}}">{{.Text}}</a></li>
{{end}}
</ul>
{{end}}
</li>
{{end}}
</ul>
</div>
</ul>
</li>
{{- end}}
</ul>
</div>
{{end}}
{{- end}}
</div>
{{end}}
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/jpillora/ipfilter v1.2.9
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
github.com/picosh/pdocs v0.0.0-20240303160411-1e3ac645dce0
github.com/picosh/pdocs v0.0.0-20240626184614-7aff67648d6e
github.com/pires/go-proxyproto v0.7.0
github.com/radovskyb/watcher v1.0.7
github.com/sirupsen/logrus v1.9.3
Expand All @@ -29,8 +29,6 @@ require (
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
Expand Down Expand Up @@ -73,6 +71,7 @@ require (
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect
go.abhg.dev/goldmark/anchor v0.1.1 // indirect
go.abhg.dev/goldmark/toc v0.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.7.0 // indirect
Expand Down
Loading

0 comments on commit c6b345d

Please sign in to comment.