feat: implement article search with PostgreSQL full-text search
- Configure Wagtail database search backend with English search config - Add django.contrib.postgres to INSTALLED_APPS for full PG FTS support - Expand ArticlePage.search_fields: body_text (excl. code blocks), AutocompleteField(title), RelatedFields(tags), FilterFields - Add search view at /search/?q= with query guards (strip, max 200 chars, empty/whitespace handling) and pagination preserving query param - Replace nav Subscribe CTA with compact search box (desktop + mobile) - Add search box to article index page alongside category/tag filters - Create search results template reusing article_card component - Add update_index to deploy entrypoint for automated reindexing - Update existing tests for nav change, add comprehensive search tests Closes #41 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,7 @@ INSTALLED_APPS = [
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.sitemaps",
|
||||
"django.contrib.postgres",
|
||||
"taggit",
|
||||
"modelcluster",
|
||||
"wagtail.contrib.forms",
|
||||
@@ -152,3 +153,10 @@ STORAGES = {
|
||||
}
|
||||
|
||||
TAILWIND_APP_NAME = "theme"
|
||||
|
||||
WAGTAILSEARCH_BACKENDS = {
|
||||
"default": {
|
||||
"BACKEND": "wagtail.search.backends.database",
|
||||
"SEARCH_CONFIG": "english",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ from wagtail import urls as wagtail_urls
|
||||
from wagtail.contrib.sitemaps.views import sitemap
|
||||
|
||||
from apps.blog.feeds import AllArticlesFeed, CategoryArticlesFeed, TagArticlesFeed
|
||||
from apps.blog.views import search as search_view
|
||||
from apps.core.views import consent_view, robots_txt
|
||||
|
||||
urlpatterns = [
|
||||
@@ -22,6 +23,7 @@ urlpatterns = [
|
||||
path("feed/tag/<slug:tag_slug>/", TagArticlesFeed(), name="rss_feed_by_tag"),
|
||||
path("sitemap.xml", sitemap),
|
||||
path("admin/", RedirectView.as_view(url="/cms/", permanent=False)),
|
||||
path("search/", search_view, name="search"),
|
||||
path("", include(wagtail_urls)),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user