@@ -126,6 +126,11 @@ export function help() {
126126 '--project-generate-cache' ,
127127 ' Only generate new files, if they do not exist.' ,
128128 )
129+ COLOR . command (
130+ null ,
131+ '--project-search' ,
132+ ' Enable full-text fuzzy search across all courses and sections.' ,
133+ )
129134}
130135
131136export interface ProjectExportArguments {
@@ -146,6 +151,7 @@ export interface ProjectExportArguments {
146151 'project-generate-scorm2004' ?: boolean
147152 'project-generate-android' ?: boolean
148153 'project-generate-cache' ?: boolean
154+ 'project-search' ?: boolean
149155}
150156
151157export const format = 'project'
@@ -179,7 +185,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
179185 true ,
180186 )
181187
182- if ( searchEntry ) searchIndex . push ( searchEntry )
188+ if ( searchEntry && argument [ 'project-search' ] ) searchIndex . push ( searchEntry )
183189 subCards += `<div class='col-sm-6 col-md-4 col-lg-3 ${
184190 course . grid ? 'mb-3' : ''
185191 } '>
@@ -230,7 +236,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
230236 let { html, json, searchEntry } = await toCard ( argument , course )
231237
232238 cards += "<div class='col'>" + html + '</div>'
233- if ( searchEntry ) searchIndex . push ( searchEntry )
239+ if ( searchEntry && argument [ 'project-search' ] ) searchIndex . push ( searchEntry )
234240 itemList . push ( json )
235241 }
236242 }
@@ -381,7 +387,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
381387<body>
382388
383389 ${ generateNavbar ( json . navbar , ! ! searchIndex . length ) }
384- <!-- Search Modal -->
390+ ${ searchIndex . length ? ` <!-- Search Modal -->
385391 <div class="modal fade" id="searchModal" tabindex="-1" aria-labelledby="searchModalLabel" aria-hidden="true">
386392 <div class="modal-dialog modal-lg modal-dialog-scrollable">
387393 <div class="modal-content">
@@ -403,7 +409,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
403409 <style>
404410 .search-highlight { background-color: rgba(255, 193, 7, 0.4); padding: 0 1px; border-radius: 2px; font-weight: 600; }
405411 .text-truncate-multiline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
406- </style>
412+ </style>` : '' }
407413 <main>
408414 <div class="container-fluid" ${ background } >
409415 <section class="py-5 text-center container">
@@ -445,7 +451,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
445451 </footer>
446452
447453 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
448- <script src="https://cdn.jsdelivr.net/npm/fuse.js@7.0.0/dist/fuse.min.js"></script>
454+ ${ searchIndex . length ? ` <script src="https://cdn.jsdelivr.net/npm/fuse.js@7.0.0/dist/fuse.min.js"></script>
449455 <script>
450456 // Compact index: [{t, g, i, u, s: [[sectionTitle, sectionContent, indentation], ...]}]
451457 // Denormalize into flat records for Fuse
@@ -592,7 +598,7 @@ export async function exporter(argument: ProjectExportArguments, json: any) {
592598 document.getElementById('searchResults').innerHTML = '<p class="text-muted px-3">Start typing to search…</p>';
593599 });
594600 });
595- </script>
601+ </script>` : '' }
596602</body>
597603</html>
598604`
0 commit comments