Skip to content

Commit

Permalink
Merge pull request #81 from feelpp/79-allow-arbitrary-nesting-of-modules
Browse files Browse the repository at this point in the history
filter based on catalog parent-id and tags #79
  • Loading branch information
prudhomm authored Sep 23, 2024
2 parents 5dbdaea + 05d5f65 commit d86119c
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 5 deletions.
Binary file added docs/modules/ROOT/images/A-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/A-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
** xref:copy-to-clipboard.adoc[]
//** xref:plotly.adoc[]
** xref:pseudocode.adoc[]
* xref:page-layouts.adoc[]
7 changes: 7 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/catalog.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:page-layout: toolboxes
:page-tags: toolbox, catalog, catalog-base
:parent-catalogs: page-layouts
:description: Example of the catalog page layout.
:page-illustration: ROOT:grid.png

= Catalog
6 changes: 6 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/itemA.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= Item A
:page-layout: toolboxes
:page-tags: toolbox, catalog, itemA
:parent-catalogs: catalog-base
:description: Item containing 2 subitems.
:page-illustration: ROOT:A.png
6 changes: 6 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/itemB.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= Item B
:page-layout: toolboxes
:page-tags: toolbox, catalog, itemB
:parent-catalogs: catalog-base
:description: Item containing 1 shared subitem.
:page-illustration: ROOT:B.png
33 changes: 33 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/itemC.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
= Item C
:page-tags: toolbox, catalog, itemC
:parent-catalogs: catalog-base, itemB
:description: Leaf item.
:page-illustration: ROOT:C.png

This is a leaf item, shared between the Item B and the catalog base.

Note that this page appears twice, without duplicating the content.

To replicate this page structure:

- Base page
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, catalog-base
----
- Item B
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, itemB
:parent-catalogs: catalog-base
----
- Item C
[asciidoc]
----
:page-tags: catalog, itemC
:parent-catalogs: catalog-base, itemB
----
32 changes: 32 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/subitemA1.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
= Subitem A-1
:page-tags: toolbox, catalog, subitemA-1
:parent-catalogs: itemA
:page-illustration: ROOT:A-1.png

== Leaf Item
This is a leaf item of the catalog.
It is a children from Item A, which is a children from the catalog base.

To replicate this page structure:

- Base page
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, catalog-base
----

- Item A
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, itemA
:parent-catalogs: catalog-base
----

- Subitem A-1
[asciidoc]
----
:page-tags: catalog, subitemA-1
:parent-catalogs: itemA
----
32 changes: 32 additions & 0 deletions docs/modules/ROOT/pages/catalogExample/subitemA2.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
= Subitem A-2
:page-tags: toolbox, catalog, subitemA-2
:parent-catalogs: itemA
:page-illustration: ROOT:A-2.png

== Leaf Item
This is a leaf item of the catalog.
It is a children from Item A, which is a children from the catalog base.

To replicate this page structure:

- Base page
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, catalog-base
----

- Item A
[asciidoc]
----
:page-layout: toolboxes
:page-tags: catalog, itemA
:parent-catalogs: catalog-base
----

- Subitem A-2
[asciidoc]
----
:page-tags: catalog, subitemA-2
:parent-catalogs: itemA
----
4 changes: 4 additions & 0 deletions docs/modules/ROOT/pages/page-layouts.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= Page Layouts
:navtitle: Page Layouts
:page-layout: toolboxes
:page-tags: catalog, page-layouts
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"generate-fontawesome-icon-defs": "node tasks/generate-fontawesome-icon-defs.js"
},
"dependencies": {
"@antora/cli": "^3.1.9",
"@antora/cli": "^3.1",
"@antora/collector-extension": "^1.0.0-beta.2",
"@antora/site-generator": "^3.1.9",
"@antora/site-generator": "^3.1",
"@asciidoctor/core": "~2.2.8",
"asciidoctor": "~2.2.8",
"asciidoctor-jupyter": "^0.7.0",
Expand Down
6 changes: 6 additions & 0 deletions src/helpers/get-page-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = (parentPage, tag, withinParentModule = true, { data: { root } }
(withinParentModule && src.module !== parentPage.module) ||
src.version !== parentPage.componentVersion.version) return
const pageTags = asciidoc.attributes['page-tags']
if (pageTags && pageTags.split(',').map((tag) => tag.trim()).includes('catalog') &&
parentPage.attributes.tags && asciidoc.attributes['parent-catalogs'] &&
asciidoc.attributes['parent-catalogs'].split(',').map((parentCat) => parentCat.trim()).every((parentCat) =>
!parentPage.attributes.tags.split(',').map((parentTag) => parentTag.trim()).includes(parentCat)
)
) return
return pageTags && pageTags.split(',').map((v) => v.trim()).includes(tag)
}).sort((a, b) => (a.title || '').localeCompare((b.title || '')))
if (pages && pages.length > 0) {
Expand Down

0 comments on commit d86119c

Please sign in to comment.