Skip to content

Commit

Permalink
Use correct page title in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
szeiger committed Oct 9, 2016
1 parent 729618b commit 5bf24fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/src/main/scala/com/novocode/ornate/Site.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Site(val pages: Vector[Page], val toc: Vector[TocEntry]) {
def getPageFor(uri: URI): Option[Page] =
if(uri.getScheme == Util.siteRootURI.getScheme) pageMap.get(uri.getPath)
else None

def findTocEntry(p: Page): Option[TocEntry] = toc.find(te => te.page eq p)
}

class Page(val sourceFileURI: Option[URI], val uri: URI, val suffix: String, val doc: Node, val config: Config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class HtmlTheme(global: Global) extends Theme(global) { self =>
logger.debug(s"Excluding page ${p.uri} from search index")
else {
val body = NodeUtil.extractText(p.doc).trim
val title = p.section.title.getOrElse("").trim
val title = site.findTocEntry(p).flatMap(_.title).orElse(p.section.title).getOrElse("").trim
val excerpt = if(excerptLength > 0) {
val bodyOnly = NodeUtil.extractText(p.doc, withCodeBlocks=false, withFirstHeading=false, limit=excerptLength).trim
val short = bodyOnly.indexOf(' ', excerptLength) match {
Expand Down

0 comments on commit 5bf24fb

Please sign in to comment.