Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 21 additions & 3 deletions build/src/ApiGenerator/Application/ApiSearchGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,30 @@ private function generateDocumentationSearchItems(): array
// Remove frontmatter
$content = preg_replace('/\+\+\+.*?\+\+\+/s', '', $content);

// Remove markdown formatting and clean content
// Extract code blocks content (preserves important terms like SrcDirs, :pairs, etc.)
preg_match_all('/```\w*\n?([\s\S]*?)```/', $content, $codeBlocks);
$codeContent = '';
if (!empty($codeBlocks[1])) {
$codeContent = implode(' ', $codeBlocks[1]);
// Clean code content: remove extra whitespace but preserve all characters
$codeContent = preg_replace('/\s+/', ' ', trim($codeContent));
}

// Remove code blocks from main content
$content = preg_replace('/```[\s\S]*?```/', ' ', $content);

// Remove markdown formatting but preserve colons (:) for keywords like :pairs, :keys
// Remove: # (headers), ` (backticks), * (bold/italic), [] (links), () (links)
$content = preg_replace('/[#`*\[\]()]/', ' ', $content);

// Clean up whitespace
$content = preg_replace('/\s+/', ' ', trim($content));

// Limit content length for search index
$content = substr($content, 0, 500);
// Combine code content with main content (code first for better matching)
$content = trim($codeContent . ' ' . $content);

// Increase content length for search index to capture more content
$content = substr($content, 0, 200);

$result[] = [
'id' => 'doc_' . pathinfo($file, PATHINFO_FILENAME),
Expand Down
11 changes: 10 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ description = "The official website of the Phel language. Phel is a functional p
compile_sass = false

# Whether to build a search index to be used later on by a JavaScript library
build_search_index = false
build_search_index = true

[search]
# Include page content in the search index
include_title = true
include_description = true
include_path = false
include_content = true
# Include more content to make search more comprehensive
truncate_content_length = 5000

generate_feeds = false

Expand Down
156 changes: 146 additions & 10 deletions css/components/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
max-width: none;
width: 100%;
flex: 1;
margin-left: var(--space-md);
}
}

Expand Down Expand Up @@ -166,6 +167,7 @@
border-bottom: 2px solid transparent;
border-radius: inherit;
transition: border-color var(--duration-fast) var(--ease-out);
border-bottom: 1px solid var(--color-light-border);
}

.search-modal__icon {
Expand Down Expand Up @@ -228,17 +230,71 @@
background-color: var(--color-light-link);
border-color: var(--color-light-link);
color: white;
transform: scale(1.05);
}

/* Search Filters */
.search-modal__filters {
display: flex;
justify-content: center;
gap: var(--space-sm);
padding: var(--space-md) var(--space-lg);
margin: 0;
}

.search-filter {
padding: 0.5rem 2.5rem;
margin: 0;
font-size: var(--text-sm);
font-weight: 600;
line-height: 1.5;
color: var(--color-gray-dark);
background: var(--color-light-bg-secondary);
border: 1px solid var(--color-light-border);
border-radius: var(--radius-lg);
cursor: pointer;
transition: all var(--duration-fast) var(--ease-out);
white-space: nowrap;
letter-spacing: 0.01em;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
text-align: center;
}

.search-filter:hover {
background: var(--color-light-surface);
border-color: var(--color-light-link);
color: var(--color-light-link);
box-shadow: 0 2px 4px rgba(99, 102, 241, 0.1);
}

.search-filter--active {
background: var(--color-light-link);
border-color: var(--color-light-link);
color: white;
box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.search-filter--active:hover {
background: var(--color-light-link);
border-color: var(--color-light-link);
color: white;
opacity: 0.95;
box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
.search-filter {
padding: 0.45rem 0.9rem;
font-size: 0.8125rem;
line-height: 1.5;
flex: 1;
}
}

.search-modal__results {
max-height: 60vh;
overflow-y: auto;
display: none;
}

.search-modal__results[style*="display: block"] {
display: block;
display: flex;
flex-direction: column;
}

.search-modal__results::-webkit-scrollbar {
Expand All @@ -263,10 +319,15 @@

.search-modal__results-list {
list-style: none;
padding: var(--space-sm);
padding: 0 var(--space-sm) var(--space-sm);
margin: 0;
}

.search-modal__results-list:not(:empty) {
border-top: 1px solid var(--color-light-border);
padding-top: var(--space-md);
}

.search-modal__results-list li {
margin: 0;
padding: 0;
Expand Down Expand Up @@ -364,7 +425,6 @@
.search-results__item strong {
color: var(--color-light-link);
font-weight: 600;
font-size: var(--text-base);
}

.search-results__item .title {
Expand All @@ -383,6 +443,31 @@
width: 100%;
}

/* Highlighted search terms - only in descriptions, not titles */
.search-results__item .desc strong {
color: var(--color-light-link);
font-weight: 700;
background: rgba(99, 102, 241, 0.1);
padding: 0.1em 0.2em;
border-radius: var(--radius-sm);
}

.search-results__item .fn-name strong {
color: inherit;
font-weight: inherit;
background: rgba(99, 102, 241, 0.15);
padding: 0.1em 0.2em;
border-radius: var(--radius-sm);
}

/* Documentation titles - highlighted matches get slightly bolder */
.search-results__item .title strong {
font-weight: 700;
background: rgba(99, 102, 241, 0.12);
padding: 0.1em 0.2em;
border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
.search-modal {
padding: 8px;
Expand Down Expand Up @@ -505,7 +590,37 @@
background-color: var(--color-dark-text-accent);
border-color: var(--color-dark-text-accent);
color: var(--color-dark-bg);
transform: scale(1.05);
}

/* Dark mode search filters */

.dark .search-filter {
color: var(--color-dark-text-primary);
border-color: rgba(255, 255, 255, 0.15);
background: rgba(255, 255, 255, 0.08);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dark .search-filter:hover {
background: rgba(191, 164, 255, 0.12);
border-color: var(--color-dark-text-accent);
color: var(--color-dark-text-accent);
box-shadow: 0 2px 6px rgba(191, 164, 255, 0.15);
}

.dark .search-filter--active {
background: var(--color-dark-text-accent);
border-color: var(--color-dark-text-accent);
color: var(--color-dark-bg);
box-shadow: 0 2px 8px rgba(191, 164, 255, 0.3);
}

.dark .search-filter--active:hover {
background: var(--color-dark-text-accent);
border-color: var(--color-dark-text-accent);
color: var(--color-dark-bg);
opacity: 0.95;
box-shadow: 0 3px 10px rgba(191, 164, 255, 0.35);
}

.dark .search-modal__results::-webkit-scrollbar-thumb {
Expand All @@ -519,6 +634,10 @@
background-clip: padding-box;
}

.dark .search-modal__results-list:not(:empty) {
border-top-color: var(--color-dark-border);
}

.dark .search-modal__results-list li.selected .search-results__item {
background: var(--color-dark-surface-hover);
}
Expand Down Expand Up @@ -558,9 +677,26 @@
}

.dark .search-results__item .title {
color: var(--color-dark-text-primary);
color: var(--color-dark-text-accent);
}

.dark .search-results__item .desc {
color: var(--color-dark-text-primary);
}

/* Highlighted search terms in dark mode - only in descriptions, not titles */
.dark .search-results__item .desc strong {
color: var(--color-dark-text-accent);
background: rgba(191, 164, 255, 0.15);
}

.dark .search-results__item .fn-name strong {
color: inherit;
background: rgba(191, 164, 255, 0.2);
}

/* Documentation titles in dark mode - highlighted matches */
.dark .search-results__item .title strong {
font-weight: 700;
background: rgba(191, 164, 255, 0.18);
}
Loading
Loading