-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
806 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,7 @@ | |
- title: Roadmap | ||
icon: bi-map | ||
url: /roadmap | ||
sublinks: | ||
- title: Search | ||
url: /search/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,113 +2,58 @@ | |
file: algolia.html | ||
sources: | ||
https://www.algolia.com/doc/onboarding/, | ||
https://community.algolia.com/jekyll-algolia/blog.html, | ||
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/#the-instantsearch-instance, | ||
https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/, | ||
https://www.algolia.com/doc/guides/building-search-ui/installation/js/ | ||
TODO: Uplift Algolia functionality | ||
--> | ||
|
||
<!-- https://www.algolia.com/doc/guides/building-search-ui/installation/js/ --> | ||
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/algoliasearch-lite.umd.js" integrity="sha256-1QNshz86RqXe/qsCBldsUu13eAX6n/O98uubKQs87UI=" crossorigin="anonymous"></script> --> | ||
<!-- <script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4.67.0/dist/instantsearch.production.min.js" integrity="sha256-TW7D3X/i/W+RUgEeDppEnFT2ixv5lzplKH0c58D92dY=" crossorigin="anonymous"></script> --> | ||
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.[email protected]/themes/reset-min.css" integrity="sha256-2AeJLzExpZvqLUxMfcs+4DWcMwNfpnjUeAAvEtPr0wU=" crossorigin="anonymous"> --> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/algoliasearch@4.23.3/dist/algoliasearch-lite.umd.js" integrity="sha256-1QNshz86RqXe/qsCBldsUu13eAX6n/O98uubKQs87UI=" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/instantsearch.[email protected]/dist/instantsearch.production.min.js" integrity="sha256-AEialBwCKmHcqym8j00nCLu/FDy3530TKG9n6okJobM=" crossorigin="anonymous"></script> | ||
|
||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/instantsearch.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script> | ||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/instantsearch.min.css"> | ||
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/instantsearch-theme-algolia.min.css"> --> | ||
<script> | ||
const searchClient = algoliasearch('{{ site.algolia.application_id }}', '{{ site.algolia.search_only_api_key }}'); | ||
|
||
const search = instantsearch({ | ||
appId: '{{ site.algolia.application_id }}', | ||
apiKey: '{{ site.algolia.search_only_api_key }}', | ||
indexName: '{{ site.algolia.index_name }}' | ||
}); | ||
|
||
const hitTemplate = function(hit) { | ||
let date = ''; | ||
if (hit.date) { | ||
date = moment.unix(hit.date).format('MMM D, YYYY'); | ||
} | ||
|
||
let url = `{{ site.baseurl }}${hit.url}#${hit.anchor}`; | ||
|
||
const title = hit._highlightResult.title.value; | ||
|
||
let breadcrumbs = ''; | ||
if (hit._highlightResult.headings) { | ||
breadcrumbs = hit._highlightResult.headings.map(match => { | ||
return `<span class="post-breadcrumb">${match.value}</span>` | ||
}).join(' > ') | ||
indexName: '{{ site.algolia.index_name }}', | ||
searchClient, | ||
searchFunction(helper) { | ||
const container = document.querySelector('#hits'); | ||
if (helper.state.query === '') { | ||
container.style.display = 'none'; | ||
return; | ||
} | ||
container.style.display = 'block'; | ||
helper.search(); | ||
} | ||
}); | ||
|
||
const content = hit._highlightResult.html.value; | ||
|
||
return ` | ||
<div class="post-item"> | ||
<span class="post-meta">${date}</span> | ||
<h2><a class="post-link" href="${url}">${title}</a></h2> | ||
{{#breadcrumbs}}<a href="${url}" class="post-breadcrumbs">${breadcrumbs}</a>{{/breadcrumbs}} | ||
<div class="post-snippet">${content}</div> | ||
</div> | ||
`; | ||
} | ||
|
||
|
||
search.addWidget( | ||
search.addWidgets([ | ||
instantsearch.widgets.searchBox({ | ||
container: '#search-searchbar', | ||
placeholder: 'Search...', | ||
poweredBy: true // This is required if you're on the free Community plan | ||
}) | ||
); | ||
container: '#searchbox', | ||
}), | ||
|
||
search.addWidget( | ||
instantsearch.widgets.hits({ | ||
container: '#search-hits', | ||
container: '#hits', | ||
templates: { | ||
item: hitTemplate | ||
item: function(hit) { | ||
return ` | ||
<div> | ||
<h2>${hit.title}</h2> | ||
<p>${hit.content}</p> | ||
</div> | ||
`; | ||
} | ||
} | ||
}) | ||
); | ||
|
||
]); | ||
|
||
search.start(); | ||
|
||
</script> | ||
|
||
<!-- <style> | ||
.ais-search-box { | ||
max-width: 100%; | ||
margin-bottom: 15px; | ||
} | ||
.post-item { | ||
margin-bottom: 30px; | ||
} | ||
.post-link .ais-Highlight { | ||
color: #111; | ||
font-style: normal; | ||
text-decoration: underline; | ||
} | ||
.post-breadcrumbs { | ||
color: #424242; | ||
display: block; | ||
} | ||
.post-breadcrumb { | ||
font-size: 18px; | ||
color: #424242; | ||
} | ||
.post-breadcrumb .ais-Highlight { | ||
font-weight: bold; | ||
font-style: normal; | ||
} | ||
.post-snippet .ais-Highlight { | ||
color: #2a7ae2; | ||
font-style: normal; | ||
font-weight: bold; | ||
} | ||
.post-snippet img { | ||
display: none; | ||
} | ||
</style> --> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/satellite-min.css" integrity="sha256-p/rGN4RGy6EDumyxF9t7LKxWGg6/MZfGhJM/asKkqvA=" crossorigin="anonymous"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,123 @@ | ||
<h2>Sitemap of current collection</h2> | ||
|
||
<ul> | ||
{% for item in page.collections %} | ||
<li> | ||
<a href="{{ item.url | relative_url }}">{{ item.title }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
|
||
<h1>Sitemap</h1> | ||
|
||
{% for collection in site.collections %} | ||
<h2>{{ collection.label }}</h2> | ||
<ul> | ||
{% for item in collection.docs %} | ||
<li> | ||
<a href="{{ item.url | relative_url }}">{{ item.title }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endfor %} | ||
<!-- | ||
file: sitemap.html | ||
path: _includes/sitemap.html | ||
description: This is the snippet for the sitemap page. | ||
--> | ||
|
||
<h1>Sitemap - Index</h1> | ||
|
||
<input type="text" id="searchBar" onkeyup="searchFunction()" placeholder="Search for keywords.."> | ||
|
||
<div class="table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col" data-type="string" data-order="desc">Collection <i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Page <i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Description<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Excerpt<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Path<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="date" data-order="desc">Last Modified Date <i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Categories<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Tags<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Absolute URL<i class="sort-icon"></i></th> | ||
<th scope="col" data-type="string" data-order="desc">Author <i class="sort-icon"></i></th> | ||
|
||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for collection in site.collections %} | ||
{% for item in collection.docs %} | ||
<tr> | ||
<td>{{ collection.label }}</td> | ||
<td> | ||
<a href="{{ item.url | relative_url }}">{{ item.title }}</a> | ||
</td> | ||
<td>{{ item.description }}</td> | ||
<td>{{ item.excerpt }}</td> | ||
<td>{{ item.path }}</td> | ||
<td>{{ item.lastmod | date: "%Y/%m/%d" | default: "null" }}</td> | ||
<td>{{ item.categories | join: ", " }}</td> | ||
<td>{{ item.tags | join: ", " }}</td> | ||
<td> | ||
<a href="{{ site.url }}{{ item.url }}">{{ site.url }}{{ item.url }}</a> | ||
</td> | ||
<td>{{ item.author }}</td> | ||
</tr> | ||
{% endfor %} | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<!-- Sorting feature --> | ||
|
||
<script> | ||
document.querySelectorAll('th').forEach(header => { | ||
header.addEventListener('click', () => { | ||
const tableElement = document.querySelector('table'); | ||
const headerIndex = Array.prototype.indexOf.call(header.parentNode.children, header); | ||
const currentTbody = tableElement.querySelector('tbody'); | ||
const newTbody = currentTbody.cloneNode(true); | ||
const rows = Array.from(newTbody.querySelectorAll('tr')); | ||
const type = header.getAttribute('data-type'); | ||
const order = header.getAttribute('data-order'); | ||
const sortedRows = rows.sort((a, b) => { | ||
const aValue = a.children[headerIndex].textContent; | ||
const bValue = b.children[headerIndex].textContent; | ||
if (type === 'date') { | ||
const aDate = aValue === "null" ? new Date(0) : new Date(...aValue.split('/').map((val, idx) => parseInt(val) - (idx === 1 ? 1 : 0))); // subtract 1 from month | ||
const bDate = bValue === "null" ? new Date(0) : new Date(...bValue.split('/').map((val, idx) => parseInt(val) - (idx === 1 ? 1 : 0))); // subtract 1 from month | ||
return order === 'asc' ? aDate - bDate : bDate - aDate; | ||
} | ||
return order === 'asc' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue); | ||
}); | ||
sortedRows.forEach(row => newTbody.appendChild(row)); | ||
tableElement.replaceChild(newTbody, currentTbody); | ||
header.setAttribute('data-order', order === 'asc' ? 'desc' : 'asc'); | ||
document.querySelectorAll('.sort-icon').forEach(icon => icon.className = 'sort-icon'); // clear all icons | ||
header.querySelector('.sort-icon').className = order === 'asc' ? 'sort-icon bi bi-arrow-down' : 'sort-icon bi bi-arrow-up'; // set the icon for the sorted column | ||
|
||
}); | ||
}); | ||
</script> | ||
|
||
<!-- searchbar script --> | ||
|
||
<script> | ||
function searchFunction() { | ||
var input, filter, table, tr, td, i, j, txtValue; | ||
input = document.getElementById("searchBar"); | ||
filter = input.value.toLowerCase(); | ||
table = document.getElementsByTagName("table"); | ||
tr = table[0].getElementsByTagName("tr"); | ||
|
||
for (i = 0; i < tr.length; i++) { | ||
td = tr[i].getElementsByTagName("td"); | ||
for (j = 0; j < td.length; j++) { | ||
if (td[j]) { | ||
txtValue = td[j].textContent || td[j].innerText; | ||
if (txtValue.toLowerCase().indexOf(filter) > -1) { | ||
tr[i].style.display = ""; | ||
break; | ||
} else { | ||
tr[i].style.display = "none"; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<script> | ||
// Parse the URL query parameters | ||
const urlParams = new URLSearchParams(window.location.search); | ||
// Get the 'q' parameter | ||
const searchQuery = urlParams.get('q'); | ||
// If a search query was provided, set it as the value of the search bar | ||
if (searchQuery) { | ||
document.getElementById('searchBar').value = searchQuery; | ||
// Call the search function | ||
searchFunction(); | ||
} | ||
</script> |
Oops, something went wrong.