{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository wiki">
	{{template "repo/header" .}}
	<div class="ui container">
		<div class="repo-button-row">
			<div class="tw-flex tw-items-center tw-gap-2">
				<a class="ui small button" href="{{.RepoLink}}/wiki/">
					{{svg "octicon-arrow-left" 14}} Back to wiki
				</a>
			</div>
		</div>

		<h2>{{svg "octicon-search" 20}} Wiki search</h2>

		<form class="ui form tw-mb-4" action="{{.RepoLink}}/wiki/" method="get">
			<input type="hidden" name="action" value="_search">
			<div class="ui action input tw-w-full">
				<input type="text" name="q" value="{{.Query}}" placeholder="Search wiki pages..." autofocus>
				<button class="ui primary button" type="submit">{{svg "octicon-search" 14}} Search</button>
			</div>
		</form>

		{{if .Query}}
		{{if .Results}}
		<div class="ui relaxed divided list">
			{{range .Results}}
			<div class="item">
				<div class="content">
					<a class="header" href="{{$.RepoLink}}/wiki/{{.PageURL}}">{{.PageName}}</a>
					{{if .Context}}
					<div class="description">
						<code class="tw-text-sm">{{.Context}}</code>
					</div>
					{{end}}
				</div>
			</div>
			{{end}}
		</div>
		<p class="tw-mt-4 text grey">{{.ResultCount}} {{if eq .ResultCount 1}}result{{else}}results{{end}} for "{{.Query}}"</p>
		{{else}}
		<div class="ui placeholder segment">
			<div class="ui icon header">
				{{svg "octicon-search" 48}}
				<br>
				No results for "{{.Query}}"
			</div>
		</div>
		{{end}}
		{{end}}
	</div>
</div>
{{template "base/footer" .}}
