-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move title generation to its own liquid template.
- Loading branch information
Showing
2 changed files
with
38 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% comment %} | ||
Determine the HTML <title>. Default is project title in meta.yml. | ||
If we're in a book, the metadata include sets the book title as 'title'. | ||
If the page has a title in its YAML frontmatter, append it after a n-dash, | ||
unless (a) this is the home page, in which case only use the page title, or | ||
(b) it's the same as the project/book title, in which case don't duplicate. | ||
{% endcomment %} | ||
|
||
{% capture html-title %}{{ project-name }}{% endcapture %} | ||
{% if title and title != "" %} | ||
{% capture html-title %}{{ title }}{% endcapture %} | ||
{% endif %} | ||
{% if page.title and page.title != "" and html-title != page.title %} | ||
{% if is-homepage %} | ||
{% capture html-title %}{{ page.title }}{% endcapture %} | ||
{% else %} | ||
{% capture html-title %}{{ page.title }} – {{ html-title }}{% endcapture %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% comment %} | ||
If we're generating a PDF, the first HTML doc in the file list will set | ||
the entire PDF document title. So if we are outputting more than one file, | ||
we want the doc name to be the book title, not only the first doc's title. | ||
{% endcomment %} | ||
|
||
{% if site.output == "print-pdf" %} | ||
{% if print-pdf-file-list.size > 1 %} | ||
{% capture html-title %}{{ title }}{% endcapture %} | ||
{% endif %} | ||
{% elsif site.output == "screen-pdf" %} | ||
{% if screen-pdf-file-list.size > 1 %} | ||
{% capture html-title %}{{ title }}{% endcapture %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% capture book-title %}{{ title }}{% endcapture %} |