/** * @fileoverview Search Page Component for Rantii * @author retoor * @description Search results and search interface page * @keywords search, page, results, find, query */ import { BaseComponent } from '../components/base-component.js'; class SearchPage extends BaseComponent { static get observedAttributes() { return ['query']; } init() { this.render(); this.bindEvents(); } render() { const query = this.getAttr('query') || ''; this.addClass('page', 'search-page'); this.setHtml(`
${query ? `` : `

Enter a search term

`}
`); if (query) { this.search(query); } } bindEvents() { this.on(this, 'submit', this.handleSubmit); } handleSubmit(e) { e.preventDefault(); const input = this.$('.search-input'); if (input && input.value.trim()) { this.getRouter()?.goToSearch(input.value.trim()); } } async search(query) { const feed = this.$('rant-feed'); if (feed) { await feed.search(query); } } onAttributeChanged(name, oldValue, newValue) { if (name === 'query') { this.render(); if (newValue) { this.search(newValue); } } } } customElements.define('search-page', SearchPage); export { SearchPage };