-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsearch.html
More file actions
164 lines (153 loc) · 7.63 KB
/
Copy pathsearch.html
File metadata and controls
164 lines (153 loc) · 7.63 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search - GIT Going with GitHub</title>
<link rel="stylesheet" href="./styles/github-markdown.css">
<link rel="stylesheet" href="./styles/highlight.css">
<link rel="stylesheet" href="./styles/custom.css">
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) { .markdown-body { padding: 15px; } }
.search-results-list { list-style: none; padding: 0; margin: 0; }
.search-result-item { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--borderColor-default, #d0d7de); }
.search-result-item:last-child { border-bottom: none; }
.search-result-title { font-size: 1.2rem; font-weight: 600; margin: 0 0 0.25rem 0; padding: 0; border: none; }
.search-result-title a { color: #0969da; text-decoration: none; }
.search-result-title a:hover { text-decoration: underline; }
.search-result-url { font-size: 0.8rem; color: #57606a; margin-bottom: 0.4rem; }
.search-result-snippet { font-size: 0.9rem; color: #24292f; line-height: 1.5; }
.search-result-snippet mark { background: #fff8c5; color: inherit; padding: 0 2px; border-radius: 2px; }
#search-status { margin-bottom: 1.5rem; color: #57606a; }
@media (prefers-color-scheme: dark) {
.search-result-title a { color: #58a6ff; }
.search-result-url { color: #9ca3af; }
.search-result-snippet { color: #e6edf3; }
.search-result-snippet mark { background: #3d2b00; color: #e6edf3; }
#search-status { color: #9ca3af; }
.search-result-item { border-bottom-color: #30363d; }
}
@media (prefers-contrast: high) {
.search-result-title a { color: #6db3f2; }
.search-result-snippet mark { background: #ffff00; color: #000000; }
}
</style>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to main content</a>
<header class="site-header" role="banner">
<div class="site-header-inner">
<nav aria-label="Breadcrumb" class="breadcrumb">
<a href="./index.html">Home</a>
<span aria-hidden="true">›</span>
<span aria-current="page">Search</span>
</nav>
<div class="header-actions">
<a href="https://github.com/Community-Access/git-going-with-github/wiki" class="wiki-link" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.06l-2.573 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.457 1.457 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 1 1 1.06-1.06l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h.25a.25.25 0 0 0 .25-.25v-5.5Z"/>
</svg>
Wiki
</a>
<form role="search" class="search-form" id="search-form" action="./search.html" method="get">
<label for="site-search" class="search-label">Search docs</label>
<input
type="search"
id="site-search"
class="search-input"
name="q"
placeholder="Search docs…"
autocomplete="off"
aria-label="Search documentation"
>
<button type="submit" class="search-button" aria-label="Submit search">
<svg aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"/>
</svg>
</button>
</form>
</div>
</div>
</header>
<main id="main-content" class="markdown-body">
<h1>Search</h1>
<p id="search-status" aria-live="polite" aria-atomic="true"></p>
<ul class="search-results-list" id="search-results" role="list" aria-label="Search results"></ul>
</main>
<footer role="contentinfo" class="site-footer">
<p><strong>GIT Going with GitHub</strong> - A workshop by <a href="https://community-access.org">Community Access</a></p>
<p><a href="https://github.com/community-access/git-going-with-github">View on GitHub</a> · <a href="https://community-access.org">community-access.org</a></p>
</footer>
<script src="./scripts/lunr.min.js"></script>
<script>
(function () {
var params = new URLSearchParams(window.location.search);
var query = (params.get('q') || '').trim();
var statusEl = document.getElementById('search-status');
var resultsEl = document.getElementById('search-results');
var searchInput = document.getElementById('site-search');
if (query) searchInput.value = query;
if (!query) { statusEl.textContent = 'Enter a search term above.'; return; }
statusEl.textContent = 'Loading…';
fetch('./search-index.json')
.then(function (r) { return r.json(); })
.then(function (pages) {
var idx = lunr(function () {
this.ref('id');
this.field('title', { boost: 10 });
this.field('body');
pages.forEach(function (p) { this.add(p); }, this);
});
var results = idx.search(query);
if (results.length === 0) {
statusEl.textContent = 'No results found for "' + query + '".';
return;
}
statusEl.textContent = results.length + ' result' + (results.length === 1 ? '' : 's') + ' found for "' + query + '"';
var pageMap = {};
pages.forEach(function (p) { pageMap[p.id] = p; });
results.forEach(function (r) {
var page = pageMap[r.ref];
if (!page) return;
// Build snippet: find sentence containing a query word
var words = query.toLowerCase().split(/\s+/);
var bodyLower = page.body.toLowerCase();
var snippetStart = 0;
for (var i = 0; i < words.length; i++) {
var pos = bodyLower.indexOf(words[i]);
if (pos > -1) { snippetStart = Math.max(0, pos - 80); break; }
}
var snippet = page.body.slice(snippetStart, snippetStart + 200);
if (snippetStart > 0) snippet = '…' + snippet;
if (snippetStart + 200 < page.body.length) snippet += '…';
// Highlight matching words in snippet
words.forEach(function (w) {
if (!w) return;
var escaped = w.replace(/[^a-zA-Z0-9]/g, '');
if (!escaped) return;
var re = new RegExp('(' + escaped + ')', 'gi');
snippet = snippet.replace(re, '<mark>$1</mark>');
});
var li = document.createElement('li');
li.className = 'search-result-item';
li.innerHTML =
'<h2 class="search-result-title"><a href="./' + page.url + '">' + page.title + '</a></h2>' +
'<div class="search-result-url">' + page.url + '</div>' +
'<div class="search-result-snippet">' + snippet + '</div>';
resultsEl.appendChild(li);
});
})
.catch(function () {
statusEl.textContent = 'Search is unavailable. Please try again later.';
});
})();
</script>
</body>
</html>