Skip to content

Commit cc59403

Browse files
Update format of page <title> tag (#128)
* Update format of page title tag * filter out component title when page title includes it * add optional ignoreCase param and enable for page title * reuse the head-title partial for meta tags --------- Co-authored-by: Cole Goldsmith <[email protected]>
1 parent 2472368 commit cc59403

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/helpers/includes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
module.exports = (searchValue, start, ignoreCase = false) => {
4+
if (!searchValue || !start) return false
5+
if (ignoreCase && typeof searchValue === 'string' && typeof start === 'string') {
6+
searchValue = searchValue.toLowerCase()
7+
start = start.toLowerCase()
8+
}
9+
return start.includes(searchValue)
10+
}

src/partials/head-meta.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta property="og:site_name" content="DataStax Documentation">
1111
<meta property="og:type" content="article">
1212
<meta property="og:url" content="{{page.canonicalUrl}}">
13-
<meta property="og:title" content="{{page.title}} :: {{site.title}}">
13+
<meta property="og:title" content="{{> head-title}}">
1414
<meta property="og:description" content="{{page.description}}">
1515
<meta property="og:image" content="{{{site.url}}}{{{site.ui.url}}}/img/datastax-docs-banner.png">
1616
<meta property="og:image:type" content="image/png">
@@ -22,7 +22,7 @@
2222
<meta name="twitter:site" content="@datastax">
2323
<meta name="twitter:creator" content="@datastax">
2424
<meta name="twitter:url" content="{{page.canonicalUrl}}">
25-
<meta name="twitter:title" content="{{page.title}} :: {{site.title}}">
25+
<meta name="twitter:title" content="{{> head-title}}">
2626
<meta name="twitter:description" content="{{page.description}}">
2727
<meta name="twitter:image" content="{{{site.url}}}{{{site.ui.url}}}/img/datastax-docs-banner.png">
2828
<script type="application/ld+json">

src/partials/head-title.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<title>{{{detag (or page.title defaultPageTitle)}}}{{#with site.title}} :: {{this}}{{/with}}</title>
1+
{{{detag (or page.title defaultPageTitle)}}}{{#with page.component.title}}{{#if (not (includes this (or ../page.title ../defaultPageTitle) true))}} | {{this}}{{/if}}{{/with}}{{#with site.title}} | {{this}}{{/with}}

src/partials/head.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{> head-prelude}}
3-
{{> head-title}}
3+
<title>{{> head-title}}</title>
44
{{> head-info}}
55
{{> head-styles}}
66
{{> head-meta}}

0 commit comments

Comments
 (0)