Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usability issue with search on main page #412 #429

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions theme/apache/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,38 @@
<link href="/css/styles.css" rel="stylesheet">
<link href="/css/new-ui.css" rel="stylesheet">
<script src="https://www.apachecon.com/event-images/snippet.js"></script>
<style>

{% include "styles.css" %}
</style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the style marker makes the styles display as text.



<!-- pagefind search -->
<link href="/_pagefind/pagefind-ui.css" rel="stylesheet">
<link href="/_pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/_pagefind/pagefind-ui.js" type="text/javascript"></script>

<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#pagefind-search" });
});
var pageTitle = '{{ page.title }}';
if(pageTitle === '404'){
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#page-404-search" });
// Initialize the Pagefind UI for the main search
new PagefindUI({ element: "#pagefind-search" });

// Get the search button and input field
const searchButton = document.querySelector('.dropdown-toggle'); // class of the button
const searchInput = document.querySelector('#pagefind-search input'); // The input field for Pagefind search

// Add click event to focus on the input when the button is clicked
searchButton.addEventListener('click', () => {
searchInput.focus(); // Focus on the input field when the button is clicked
});
}

// Check if the page is a 404 and initialize the search UI for the 404 page
const pageTitle = '{{ page.title }}'; // Assuming this is a template engine placeholder
if (pageTitle === '404') {
// Initialize the Pagefind UI for the 404 page
new PagefindUI({ element: "#page-404-search" });
}
});
</script>




{% if page.notice %}<!-- {{ page.notice }} -->{% endif %}
{% if page.license %}<!-- {{ page.license }} -->{% endif %}
Expand Down