Skip to content

Commit ec8d70d

Browse files
authored
Merge pull request #5 from neo4j-documentation/propagate-page-cdn-attr
2 parents da0cea4 + a904ee3 commit ec8d70d

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

lib/generate-site.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ async function generateSite (args, env) {
2323
])
2424
const pages = convertDocuments(contentCatalog, asciidocConfig)
2525
knowledgeBase.generateKnowledgeBasePageDescription(pages)
26-
knowledgeBase.addCategoryPages(pages, contentCatalog)
27-
knowledgeBase.addTagPages(pages, contentCatalog)
26+
knowledgeBase.addCategoryPages(pages, contentCatalog, asciidocConfig)
27+
knowledgeBase.addTagPages(pages, contentCatalog, asciidocConfig)
2828
const navigationCatalog = buildNavigation(contentCatalog, asciidocConfig)
2929
training.attachNavigationSlug(contentCatalog, navigationCatalog)
3030
const composePage = createPageComposer(playbook, contentCatalog, uiCatalog, env)

lib/knowledge-base.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const cheerio = require('cheerio')
44

55
// tag::add-category-pages[]
6-
function addKnowledgeBaseCategoryPages (pages, contentCatalog) {
6+
function addKnowledgeBaseCategoryPages (pages, contentCatalog, asciidocConfig) {
77
const pagesPerCategory = pages
88
.filter((page) => {
99
return page.src.component === 'kb' &&
@@ -25,22 +25,23 @@ function addKnowledgeBaseCategoryPages (pages, contentCatalog) {
2525
return acc
2626
}, {})
2727
for (const [category, associatedPages] of Object.entries(pagesPerCategory)) {
28-
pages.push(contentCatalog.addFile(createKnowledgeBaseCategoryPage(category, associatedPages)))
28+
pages.push(contentCatalog.addFile(createKnowledgeBaseCategoryPage(category, associatedPages, asciidocConfig)))
2929
}
3030
}
3131
// end::add-category-pages[]
3232

33-
function createKnowledgeBaseCategoryPage (category, pages) {
33+
function createKnowledgeBaseCategoryPage (category, pages, asciidocConfig) {
34+
const asciidocAttributes = {
35+
...asciidocConfig.attributes,
36+
'page-layout': 'kb-category',
37+
'page-category': category,
38+
'page-category-pages': pages,
39+
'page-breadcrumb': category
40+
}
3441
return {
3542
title: `Category ${category}`,
3643
asciidoc: {
37-
attributes: {
38-
'page-layout': 'kb-category',
39-
'page-category': category,
40-
'page-category-pages': pages,
41-
'page-theme': 'kb',
42-
'page-breadcrumb': category
43-
}
44+
attributes: asciidocAttributes
4445
},
4546
src: {
4647
component: 'kb',
@@ -55,7 +56,7 @@ function createKnowledgeBaseCategoryPage (category, pages) {
5556
}
5657

5758
// tag::generate-tag-pages[]
58-
function addKnowledgeBaseTagPages (pages, contentCatalog) {
59+
function addKnowledgeBaseTagPages (pages, contentCatalog, asciidocConfig) {
5960
const pagesPerTag = pages
6061
.filter((page) => {
6162
return page.src.component === 'kb' &&
@@ -79,22 +80,24 @@ function addKnowledgeBaseTagPages (pages, contentCatalog) {
7980
return acc
8081
}, {})
8182
for (const [tag, associatedPages] of Object.entries(pagesPerTag)) {
82-
pages.push(contentCatalog.addFile(createKnowledgeBaseTagPage(tag, associatedPages)))
83+
pages.push(contentCatalog.addFile(createKnowledgeBaseTagPage(tag, associatedPages, asciidocConfig)))
8384
}
8485
}
8586
// end::generate-tag-pages[]
8687

87-
function createKnowledgeBaseTagPage (tag, pages) {
88+
function createKnowledgeBaseTagPage (tag, pages, asciidocConfig) {
89+
console.log({asciidocConfig})
90+
const asciidocAttributes = {
91+
...asciidocConfig.attributes,
92+
'page-layout': 'kb-tag',
93+
'page-tag': tag,
94+
'page-tag-pages': pages,
95+
'page-breadcrumb': tag,
96+
}
8897
return {
8998
title: `Tag ${tag}`,
9099
asciidoc: {
91-
attributes: {
92-
'page-layout': 'kb-tag',
93-
'page-tag': tag,
94-
'page-tag-pages': pages,
95-
'page-theme': 'kb',
96-
'page-breadcrumb': tag
97-
}
100+
attributes: asciidocAttributes
98101
},
99102
src: {
100103
component: 'kb',

0 commit comments

Comments
 (0)