@@ -39,6 +39,26 @@ function initializeSearchEnhancements() {
3939 const searchInput = document . querySelector ( '.md-search__input' ) ;
4040 if ( ! searchInput ) return ;
4141
42+ // External repositories metadata for enhanced search
43+ const externalRepos = {
44+ docs : {
45+ name : 'Documentation Hub' ,
46+ url : 'https://codebase-interface.github.io/docs' ,
47+ searchUrl : 'https://codebase-interface.github.io/docs/search/?q=' ,
48+ repoUrl : 'https://github.com/codebase-interface/docs' ,
49+ repoSearchUrl : 'https://github.com/codebase-interface/docs/search?q=' ,
50+ topics : [ 'templates' , 'guides' , 'specifications' , 'best-practices' , 'architecture' , 'frameworks' ]
51+ } ,
52+ cli : {
53+ name : 'CLI Tools' ,
54+ url : 'https://codebase-interface.github.io/cli' ,
55+ searchUrl : 'https://codebase-interface.github.io/cli/search/?q=' ,
56+ repoUrl : 'https://github.com/codebase-interface/cli' ,
57+ repoSearchUrl : 'https://github.com/codebase-interface/cli/search?q=' ,
58+ topics : [ 'automation' , 'validation' , 'generation' , 'commands' , 'installation' , 'configuration' ]
59+ }
60+ } ;
61+
4262 // Add search suggestions for common queries
4363 const commonQueries = [
4464 'documentation standards' ,
@@ -47,14 +67,21 @@ function initializeSearchEnhancements() {
4767 'contributing guidelines' ,
4868 'audience interfaces' ,
4969 'taskfile' ,
50- 'automation'
70+ 'automation' ,
71+ 'templates' ,
72+ 'validation' ,
73+ 'installation' ,
74+ 'configuration'
5175 ] ;
5276
5377 // Enhanced search with repository context
5478 searchInput . addEventListener ( 'input' , debounce ( function ( e ) {
5579 const query = e . target . value . toLowerCase ( ) ;
5680
5781 if ( query . length > 2 ) {
82+ // Add external search suggestions
83+ addExternalSearchSuggestions ( query , externalRepos ) ;
84+
5885 // Track search queries for analytics
5986 if ( typeof gtag !== 'undefined' ) {
6087 gtag ( 'event' , 'search' , {
@@ -64,6 +91,183 @@ function initializeSearchEnhancements() {
6491 }
6592 }
6693 } , 300 ) ) ;
94+
95+ // Add external search button to search results
96+ addExternalSearchOptions ( externalRepos ) ;
97+ }
98+
99+ /**
100+ * Add external repository search suggestions
101+ */
102+ function addExternalSearchSuggestions ( query , repos ) {
103+ // Look for existing external results container
104+ let externalContainer = document . querySelector ( '.external-search-results' ) ;
105+
106+ if ( ! externalContainer ) {
107+ externalContainer = document . createElement ( 'div' ) ;
108+ externalContainer . className = 'external-search-results' ;
109+ externalContainer . innerHTML = `
110+ <div class="external-search-header">
111+ <h4>🔍 Search External Resources</h4>
112+ <p>Find more detailed information in our specialized repositories:</p>
113+ </div>
114+ ` ;
115+
116+ const searchOutput = document . querySelector ( '.md-search__output' ) ;
117+ if ( searchOutput ) {
118+ searchOutput . appendChild ( externalContainer ) ;
119+ }
120+ }
121+
122+ // Clear existing suggestions
123+ const existingSuggestions = externalContainer . querySelectorAll ( '.external-suggestion' ) ;
124+ existingSuggestions . forEach ( s => s . remove ( ) ) ;
125+
126+ // Add suggestions for each repo based on query relevance
127+ Object . entries ( repos ) . forEach ( ( [ key , repo ] ) => {
128+ const relevantTopics = repo . topics . filter ( topic =>
129+ topic . includes ( query ) || query . includes ( topic )
130+ ) ;
131+
132+ if ( relevantTopics . length > 0 || query . length > 3 ) {
133+ const suggestion = document . createElement ( 'div' ) ;
134+ suggestion . className = 'external-suggestion' ;
135+ suggestion . innerHTML = `
136+ <div class="suggestion-content">
137+ <strong>${ repo . name } </strong>
138+ <p>Search for "${ query } " in ${ repo . name . toLowerCase ( ) } </p>
139+ ${ relevantTopics . length > 0 ? `<small>Related: ${ relevantTopics . join ( ', ' ) } </small>` : '' }
140+ </div>
141+ <div class="suggestion-buttons">
142+ <a href="${ repo . searchUrl } ${ encodeURIComponent ( query ) } "
143+ target="_blank"
144+ class="suggestion-link docs-search"
145+ onclick="CodebaseInterface.trackEvent('external_search', 'search', '${ key } :${ query } ')">
146+ Search Docs →
147+ </a>
148+ <a href="${ repo . repoSearchUrl } ${ encodeURIComponent ( query ) } "
149+ target="_blank"
150+ class="suggestion-link repo-search"
151+ onclick="CodebaseInterface.trackEvent('repo_search', 'search', '${ key } :${ query } ')">
152+ Search Repo →
153+ </a>
154+ </div>
155+ ` ;
156+
157+ externalContainer . appendChild ( suggestion ) ;
158+ }
159+ } ) ;
160+ }
161+
162+ /**
163+ * Add external search options to the search interface
164+ */
165+ function addExternalSearchOptions ( repos ) {
166+ const searchForm = document . querySelector ( '.md-search__form' ) ;
167+ if ( ! searchForm ) return ;
168+
169+ // Add CSS for external search styling
170+ if ( ! document . querySelector ( '#external-search-styles' ) ) {
171+ const styles = document . createElement ( 'style' ) ;
172+ styles . id = 'external-search-styles' ;
173+ styles . textContent = `
174+ .external-search-results {
175+ margin: 1rem 0;
176+ padding: 1rem;
177+ background: var(--md-code-bg-color);
178+ border-radius: 8px;
179+ border-left: 4px solid var(--ci-primary, #2563eb);
180+ }
181+
182+ .external-search-header h4 {
183+ margin: 0 0 0.5rem 0;
184+ color: var(--ci-primary, #2563eb);
185+ font-size: 0.9rem;
186+ }
187+
188+ .external-search-header p {
189+ margin: 0 0 1rem 0;
190+ font-size: 0.8rem;
191+ opacity: 0.8;
192+ }
193+
194+ .external-suggestion {
195+ display: flex;
196+ align-items: center;
197+ justify-content: space-between;
198+ padding: 0.75rem;
199+ margin: 0.5rem 0;
200+ background: var(--md-default-bg-color);
201+ border-radius: 6px;
202+ border: 1px solid var(--md-default-fg-color--lightest);
203+ transition: all 0.2s ease;
204+ }
205+
206+ .external-suggestion:hover {
207+ transform: translateX(4px);
208+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
209+ }
210+
211+ .suggestion-content {
212+ flex: 1;
213+ }
214+
215+ .suggestion-content strong {
216+ color: var(--ci-primary, #2563eb);
217+ font-size: 0.85rem;
218+ }
219+
220+ .suggestion-content p {
221+ margin: 0.25rem 0;
222+ font-size: 0.8rem;
223+ }
224+
225+ .suggestion-content small {
226+ color: var(--md-default-fg-color--light);
227+ font-size: 0.7rem;
228+ }
229+
230+ .suggestion-buttons {
231+ display: flex;
232+ gap: 0.5rem;
233+ flex-direction: column;
234+ }
235+
236+ @media (min-width: 768px) {
237+ .suggestion-buttons {
238+ flex-direction: row;
239+ }
240+ }
241+
242+ .suggestion-link {
243+ background: var(--ci-primary, #2563eb);
244+ color: white !important;
245+ padding: 0.4rem 0.8rem;
246+ border-radius: 4px;
247+ text-decoration: none;
248+ font-size: 0.75rem;
249+ font-weight: 500;
250+ transition: background 0.2s ease;
251+ text-align: center;
252+ min-width: 100px;
253+ }
254+
255+ .suggestion-link:hover {
256+ background: var(--ci-accent, #0ea5e9);
257+ text-decoration: none;
258+ }
259+
260+ .suggestion-link.repo-search {
261+ background: var(--md-default-fg-color--light);
262+ color: var(--md-default-bg-color) !important;
263+ }
264+
265+ .suggestion-link.repo-search:hover {
266+ background: var(--md-default-fg-color);
267+ }
268+ ` ;
269+ document . head . appendChild ( styles ) ;
270+ }
67271}
68272
69273/**
0 commit comments