blob: a2d5c4cb738c401dfbfb65f6d3332fdc2eb385c7 [file] [log] [blame]
<!--
Copyright 2019 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
{{define "main_content"}}
<div class="Container">
<a class="GodocButton" href="{{.GodocURL}}">Back to godoc.org</a>
{{$header := .Header}}
{{$pageType := .PageType}}
<header class="DetailsHeader">
<div class="DetailsHeader-breadcrumb">
{{.BreadcrumbPath}}
</div>
<div class="DetailsHeader-main">
<h1 class="DetailsHeader-title">{{.Title}}</h1>
<div class="DetailsHeader-version">{{$header.DisplayVersion}}</div>
{{- $ppath := "" -}}
{{- if ne $pageType "mod" -}}
{{- $ppath = $header.Path -}}
{{- end}}
<!-- Do not reformat the data attributes of the following div: the server uses a regexp to extract them. -->
<div class="DetailsHeader-badge $$GODISCOVERY_LATESTCLASS$$"
data-version="{{$header.LinkVersion}}" data-mpath="{{$header.ModulePath}}" data-ppath="{{$ppath}}" data-pagetype="{{$pageType}}">
<span>Latest</span>
<a href="{{$header.LatestURL}}">Go to latest</a>
</div>
</div>
<div class="DetailsHeader-infoLabel">
<span class="DetailsHeader-infoLabelTitle">Published:</span>
<strong>{{$header.CommitTime}}</strong>
<span class="DetailsHeader-infoLabelDivider">|</span>
<span class="DetailsHeader-infoLabelTitle">{{pluralize (len $header.Licenses) "License"}}: </span>
<span data-test-id="DetailsHeader-infoLabelLicense">
{{range $i, $e := $header.Licenses -}}{{if $i}}, {{end}}
<a href="{{$header.URL}}?tab=licenses#{{.Anchor}}">{{$e.Type}}</a>
{{- else -}}
<span>None detected</span>
<a href="/license-policy" class="Disclaimer-link"><em>not legal advice</em></a>
{{- end}}
</span>
{{if or (eq $pageType "pkg") (eq $pageType "dir")}}
<span class="DetailsHeader-infoLabelDivider">|</span>
{{if eq $header.ModulePath "std"}}
<a data-test-id="DetailsHeader-infoLabelModule" href="{{$header.Module.URL}}">Standard library</a>
{{else}}
<span class="DetailsHeader-infoLabelTitle">Module: </span>
<span>
<a data-test-id="DetailsHeader-infoLabelModule" href="{{$header.Module.URL}}">{{$header.ModulePath}}</a>
</span>
{{end}}
{{end}}
</div>
</header>
<nav class="DetailsNav js-modulesNav">
<ul class="DetailsNav-list" role="tablist">
{{range .Tabs}}
<li class="{{if .Disabled}}DetailsNav-tabDisabled {{end}}DetailsNav-tab{{if eq .Name $.Settings.Name}} selected{{end}}" role="presentation">
{{if .Disabled}}
<a class="DetailsNav-link"
role="tab"
aria-selected="false">
{{else if eq .Name $.Settings.Name}}
<a class="DetailsNav-link"
role="tab"
aria-selected="true">
{{else}}
<a class="DetailsNav-link"
href="{{$header.URL}}?tab={{.Name}}"
role="tab"
aria-selected="false">
{{end}}
{{.DisplayName}}
</a>
</li>
{{end}}
</ul>
</nav>
<div class="DetailsContent">
{{if .CanShowDetails -}}
{{template "details_content" .Details}}
{{- else}}
<h2>“{{.Settings.DisplayName}}” not displayed due to license restrictions.</h2>
See our <a href="/license-policy">license policy</a>.
{{end}}
</div>
</div>
{{end}}
{{define "post_content"}}
<script nonce="{{.Nonce}}">
const navEl = document.querySelector('.js-modulesNav');
const selectedEl = navEl.querySelector(`[aria-selected='true']`);
if (selectedEl.offsetLeft + selectedEl.offsetWidth > navEl.offsetWidth) {
navEl.scrollLeft = selectedEl.offsetLeft;
}
const copyButton = document.querySelector('.js-detailsHeaderCopyPath');
if (copyButton) {
copyButton.addEventListener('click', e => {
e.preventDefault();
const inputEl = document.querySelector('.js-detailsHeaderPathInput');
inputEl.select();
document.execCommand('copy');
inputEl.blur(); // prevents jump to focused element in some browsers
});
}
</script>
{{block "details_post_content" .}}{{end}}
{{end}}