Skip to content

Commit dafd3ad

Browse files
authored
add tags using handlebars, update styles (#37)
* add tags using handlebards, update styles * fix split helper * add tag class, add char to split helper
1 parent 43013e8 commit dafd3ad

File tree

6 files changed

+34
-33
lines changed

6 files changed

+34
-33
lines changed

preview-src/examples/quickstart.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:astra-link: https://astra.datastax.com
88
:astra-nodejs-link: https://docs.datastax.com/en/astra-serverless/docs/develop/sdks/rest-nodejs-client.html
99
:astra-json-link: https://docs.datastax.com/en/astra-serverless/docs/develop/dev-with-json.html
10+
:page-tags: Machine Learning Frameworks, Embeding Services, Astra, SDK
1011
:keywords: Machine Learning Frameworks, Embeding Services, Astra, SDK
1112

1213
== Objective

src/css/toc.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
color: var(--toc-heading-font-color);
1515
font-size: calc(16 / var(--rem-base) * 1rem);
1616
font-weight: var(--body-font-weight-bold);
17-
line-height: 1.3;
18-
margin: 0 -0.5px;
17+
line-height: 1.5;
18+
margin: 0;
1919
padding-bottom: var(--ds-space-2);
2020
}
2121

@@ -103,7 +103,7 @@
103103

104104
.toc .toc-menu a.is-active {
105105
border-left-color: var(--link-font-color);
106-
color: var(--doc-font-color);
106+
color: var(--link-font-color);
107107
}
108108

109109
.sidebar.toc .toc-menu a:focus {
@@ -131,7 +131,8 @@
131131
flex-wrap: wrap;
132132
}
133133

134-
.toc .toc-tags span,
134+
.toc .toc-tags .tag,
135+
.tags-container .tag,
135136
.tags-container span {
136137
display: flex;
137138
padding: var(--ds-space-q) var(--ds-space-1h);

src/css/vars.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
--table-footer-background: linear-gradient(to bottom, var(--ds-background-level1) 0%, var(--ds-background-body) 100%);
9696
/* toc */
9797
--toc-font-color: var(--ds-text-secondary);
98-
--toc-heading-font-color: var(--doc-font-color);
98+
--toc-menu-font-weight: var(--body-font-weight-bold);
99+
--toc-heading-font-color: var(--ds-text-primary);
99100
--toc-border-color: var(--ds-divider);
100101
--toc-line-height: 1.5;
101102
/* footer */

src/helpers/split.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 = (val, char) => {
4+
if (typeof val === 'string') {
5+
const arr = val.split(char)
6+
return arr
7+
} else {
8+
throw new Error('{{split}} helper expects a string argument')
9+
}
10+
}

src/js/08-toc-rail.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
;(function () {
2-
'use strict'
1+
/* content rail */
32

4-
/* toc container */
5-
var toc = document.querySelector('aside.toc.sidebar')
6-
7-
if (toc) {
8-
tags(toc)
9-
}
10-
11-
function tags (toc) {
12-
var tagList = document.getElementsByTagName('meta').keywords
13-
if (tagList) {
14-
var title = document.createElement('h3')
15-
title.textContent = 'Tags'
16-
var list = tagList.content.split(',')
17-
var container = toc.querySelector('.toc-tags')
18-
var tags = document.createElement('div')
19-
list.forEach((s) => {
20-
var el = document.createElement('span')
21-
el.textContent = s
22-
tags.appendChild(el)
23-
})
24-
container.appendChild(title)
25-
container.appendChild(tags)
26-
}
27-
}
28-
})()
3+
// ;(function () {
4+
// 'use strict'
5+
// // content
6+
//
7+
// })()

src/partials/toc.hbs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<aside class="toc sidebar" data-title="{{{or page.attributes.toctitle 'Contents'}}}" data-levels="{{{or page.attributes.toclevels 2}}}">
22
<div class="toc-menu-container">
33
<div class="toc-menu"></div>
4-
<div class="toc-menu toc-tags"></div>
4+
<div class="toc-menu toc-tags">
5+
{{#if page.attributes.tags}}
6+
<h3>Tags</h3>
7+
<div>
8+
{{#each (split page.attributes.tags ", ") }}
9+
<span class="tag">{{this}}</span>
10+
{{/each}}
11+
</div>
12+
{{/if}}
13+
</div>
514
<div class="toc-menu toc-dev">
615
{{#if page.versions}}
716
<h3>Developer Resources</h3>

0 commit comments

Comments
 (0)