@@ -11,15 +11,17 @@ export default function extendTagOverview() {
1111
1212 if ( app . forum . attribute ( 'blogHideTags' ) == false ) return markup ;
1313
14- // Get knowledge base tag ID's
15- const knowledgeBaseTags = app . forum . attribute ( 'blogTags' ) || [ ] ;
14+ // Get blog tag ID's
15+ const blogTags = app . forum . attribute ( 'blogTags' ) || [ ] ;
16+
17+ const tag_tiles_parent = findChild ( markup , 'TagsPage-content' , true ) ;
18+ const tag_tiles = tag_tiles_parent ?. children [ 0 ] ;
1619
17- // Get tiles
18- let tag_tiles = markup . children [ 1 ] . children [ 1 ] . children [ 0 ] . children ;
20+ if ( ! tag_tiles_parent || ! tag_tiles ) return markup ;
1921
20- // Map through the tiles and remove tiles that are part of the knowledge base
21- markup . children [ 1 ] . children [ 1 ] . children [ 0 ] . children = tag_tiles . map ( ( tile , i ) => {
22- return knowledgeBaseTags . indexOf ( this . tags [ i ] . id ( ) ) >= 0 ? null : tile ;
22+ // Map through the tiles and remove tiles that are part of the blog
23+ tag_tiles . children = tag_tiles . children . map ( ( tile , i ) => {
24+ return blogTags . indexOf ( this . tags [ i ] . id ( ) ) >= 0 ? null : tile ;
2325 } ) ;
2426
2527 return markup ;
@@ -37,3 +39,39 @@ export default function extendTagOverview() {
3739 return items ;
3840 } ) ;
3941}
42+
43+ function findChild ( parent , childClass , recursive = false , maxDepth = 50 , depth = 0 ) {
44+ const children = getChildren ( parent ) ;
45+ let child = null ;
46+
47+ for ( let i = 0 ; i < children . length ; i ++ ) {
48+ const childClassName = children [ i ] ?. attrs ?. className || '' ;
49+ if ( childClassName . includes ( childClass ) ) {
50+ child = children [ i ] ;
51+ break ;
52+ }
53+ }
54+
55+ // Recursive search
56+ if ( recursive && ! child && depth < maxDepth ) {
57+ for ( let subParent of children ) {
58+ const subChild = findChild ( subParent , childClass , true , maxDepth , depth + 1 ) ;
59+ if ( subChild ) {
60+ return subChild ;
61+ }
62+ }
63+ }
64+
65+ return child ;
66+ }
67+
68+ function getChildren ( parent ) {
69+ if ( Array . isArray ( parent ) ) {
70+ return parent ;
71+ }
72+ const children = parent ?. children || [ ] ;
73+ if ( ! Array . isArray ( children ) ) {
74+ return [ ] ;
75+ }
76+ return children ;
77+ }
0 commit comments