Skip to content

Commit c63be68

Browse files
committed
Fix search aliases not applying properly on versioned docs
Fixes freeCodeCamp#461.
1 parent fd56262 commit c63be68

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

assets/javascripts/models/doc.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ class app.models.Doc extends app.Model
3939
"#{app.indexHost()}/#{@slug}/#{app.config.index_filename}?#{@mtime}"
4040

4141
toEntry: ->
42-
@entry ||= new app.models.Entry
42+
return @entry if @entry
43+
@entry = new app.models.Entry
4344
doc: @
4445
name: @fullName
4546
path: 'index'
47+
@entry.addAlias(@name) if @version
48+
@entry
4649

4750
findEntryByPathAndHash: (path, hash) ->
4851
if hash and entry = @entries.findBy 'path', "#{path}##{hash}"

assets/javascripts/models/entry.coffee

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ class app.models.Entry extends app.Model
55

66
constructor: ->
77
super
8-
@text = app.Searcher.normalizeString(@name)
9-
@text = applyAliases(@text)
8+
@text = applyAliases(app.Searcher.normalizeString(@name))
9+
10+
addAlias: (name) ->
11+
text = applyAliases(app.Searcher.normalizeString(name))
12+
@text = [@text] unless Array.isArray(@text)
13+
@text.push(if Array.isArray(text) then text[1] else text)
14+
return
1015

1116
fullPath: ->
1217
@doc.fullPath if @isIndex() then '' else @path
@@ -45,8 +50,9 @@ class app.models.Entry extends app.Model
4550
return string
4651

4752
@ALIASES = ALIASES =
53+
'angular': 'ng'
4854
'angular.js': 'ng'
49-
'backbone': 'bb'
55+
'backbone.js': 'bb'
5056
'c++': 'cpp'
5157
'coffeescript': 'cs'
5258
'elixir': 'ex'

0 commit comments

Comments
 (0)