mirror of
https://github.com/andwati/pwnforfunandprofit.xyz.git
synced 2026-10-18 02:12:52 +00:00
feat: remove search functionality and related assets
This commit is contained in:
Vendored
-10
File diff suppressed because one or more lines are too long
@@ -1,102 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
if (typeof elasticlunr === 'undefined') return;
|
||||
|
||||
const searchOverlay = document.getElementById('search-overlay');
|
||||
const searchInput = document.getElementById('search-input');
|
||||
const searchResults = document.getElementById('search-results');
|
||||
const searchToggle = document.querySelector('.search-toggle');
|
||||
const searchClose = document.getElementById('search-close');
|
||||
|
||||
let searchIndex = null;
|
||||
|
||||
// Load search index
|
||||
fetch('/search_index.en.js')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
searchIndex = elasticlunr.Index.load(data);
|
||||
})
|
||||
.catch(err => console.error('Failed to load search index:', err));
|
||||
|
||||
// Open search
|
||||
const openSearch = () => {
|
||||
if (!searchOverlay) return;
|
||||
searchOverlay.classList.add('is-active');
|
||||
setTimeout(() => searchInput?.focus(), 100);
|
||||
};
|
||||
|
||||
// Close search
|
||||
const closeSearch = () => {
|
||||
if (!searchOverlay) return;
|
||||
searchOverlay.classList.remove('is-active');
|
||||
searchInput.value = '';
|
||||
searchResults.innerHTML = '';
|
||||
};
|
||||
|
||||
// Perform search
|
||||
const performSearch = (query) => {
|
||||
if (!searchIndex || !query) {
|
||||
searchResults.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const results = searchIndex.search(query, {
|
||||
fields: {
|
||||
title: { boost: 2 },
|
||||
body: { boost: 1 }
|
||||
},
|
||||
expand: true
|
||||
});
|
||||
|
||||
if (results.length === 0) {
|
||||
searchResults.innerHTML = '<div class="search-no-results">No results found</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const html = results.slice(0, 10).map(result => {
|
||||
const doc = searchIndex.documentStore.getDoc(result.ref);
|
||||
const snippet = doc.body.substring(0, 150);
|
||||
return `
|
||||
<a href="${doc.url}" class="search-result-item">
|
||||
<h3 class="search-result-title">${doc.title}</h3>
|
||||
<p class="search-result-snippet">${snippet}...</p>
|
||||
</a>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
searchResults.innerHTML = html;
|
||||
};
|
||||
|
||||
// Event listeners
|
||||
if (searchToggle) {
|
||||
searchToggle.addEventListener('click', openSearch);
|
||||
}
|
||||
|
||||
if (searchClose) {
|
||||
searchClose.addEventListener('click', closeSearch);
|
||||
}
|
||||
|
||||
if (searchOverlay) {
|
||||
searchOverlay.addEventListener('click', (e) => {
|
||||
if (e.target === searchOverlay) closeSearch();
|
||||
});
|
||||
}
|
||||
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
performSearch(e.target.value.trim());
|
||||
});
|
||||
}
|
||||
|
||||
// Keyboard shortcuts
|
||||
document.addEventListener('keydown', (e) => {
|
||||
// Escape to close
|
||||
if (e.key === 'Escape' && searchOverlay?.classList.contains('is-active')) {
|
||||
closeSearch();
|
||||
}
|
||||
// Ctrl/Cmd + K to open
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
||||
e.preventDefault();
|
||||
openSearch();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -14,10 +14,7 @@
|
||||
{% include "partials/footer.html" %}
|
||||
</div>
|
||||
|
||||
{% include "partials/search.html" %}
|
||||
|
||||
<script src="{{ get_url(path="js/elasticlunr.min.js") }}"></script>
|
||||
<script src="{{ get_url(path="js/search.js") }}"></script>
|
||||
<script src="{{ get_url(path="js/theme.js") }}"></script>
|
||||
{% block scripts %}{% endblock scripts %}
|
||||
</body>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<div id="search-overlay" class="search-overlay">
|
||||
<div class="search-modal">
|
||||
<div class="search-header">
|
||||
<input type="search" id="search-input" class="search-input" placeholder="Search posts..." autocomplete="off" />
|
||||
<button id="search-close" class="search-close" aria-label="Close search">
|
||||
<svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div id="search-results" class="search-results"></div>
|
||||
<div class="search-footer">
|
||||
<kbd>ESC</kbd> to close
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,7 +2,7 @@ base_url = "https://pwnforfunandprofit.xyz"
|
||||
title = "Pwn For Fun And Profit"
|
||||
description = "Hacking the Narrative, One Byte at a Time."
|
||||
compile_sass = true
|
||||
build_search_index = true
|
||||
build_search_index = false
|
||||
taxonomies = [ {name = "tags"} ]
|
||||
generate_feeds = true
|
||||
feed_filenames = ["rss.xml"]
|
||||
@@ -49,6 +49,6 @@ name = "Archive"
|
||||
url = "@/archive/_index.md"
|
||||
|
||||
# Features
|
||||
enable_search = true
|
||||
enable_search = false
|
||||
enable_theme_toggle = true
|
||||
show_rss_link = true
|
||||
|
||||
Reference in New Issue
Block a user