Skip to content

Commit feeef09

Browse files
Remove: legacy docs from search (#742)
This pr removes the legacy docs from the search indexing script, which will also remove them from the actual search in runtime. Also it adds logging to increase build observability.
1 parent bf7e862 commit feeef09

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

apps/web/src/mdx/search.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,15 @@ export default function (nextConfig = {}) {
6868
let appDir = path.resolve('./src/app')
6969
this.addContextDependency(appDir)
7070

71+
console.log('Starting MDX processing for search...')
72+
7173
let files = glob.sync('**/*.mdx', { cwd: appDir })
72-
let data = files.map((file) => {
74+
// Exclude legacy docs
75+
files = files.filter(file => !file.includes('docs/legacy'))
76+
77+
let data = files.map((file, index, arr) => {
78+
console.log(`Processing MDX file ${index + 1}/${arr.length}: ${file}`)
79+
7380
let url = '/' + file.replace(/(^|\/)page\.mdx$/, '')
7481
let mdx = fs.readFileSync(path.join(appDir, file), 'utf8')
7582

@@ -114,20 +121,20 @@ export default function (nextConfig = {}) {
114121
continue
115122
}
116123
117-
const isLegacy = url.includes('docs/legacy')
118-
119124
for (let [title, hash, content] of sections) {
120125
sectionIndex.add({
121126
url: url + (hash ? ('#' + hash) : ''),
122127
title,
123128
content: [title, ...content].join('\\n'),
124129
pageTitle: hash ? sections[0][0] : undefined,
125130
preview: content.join('\\n'),
126-
badge: isLegacy ? 'Legacy' : undefined,
131+
badge: undefined,
127132
})
128133
}
129134
}
130135
136+
console.log('MDX processing complete. Search index populated.')
137+
131138
export function search(query, options = {}) {
132139
let result = sectionIndex.search(query, {
133140
...options,

0 commit comments

Comments
 (0)