Skip to content

Commit e2f9ae2

Browse files
feat: add multiple families and update families align with pyansys tags (#1024)
* fix: update families * feat: add multiple tags * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: add families --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 46bb4ec commit e2f9ae2

File tree

6 files changed

+97
-71
lines changed

6 files changed

+97
-71
lines changed

doc/source/_static/js/landing_page.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ function collectFamilies(data) {
1111
for (const project of projects) {
1212
if (!project || typeof project !== "object") continue;
1313

14-
const family = project.family;
14+
// Handle families array
15+
const projectFamilies = project.families || ["Other"];
16+
1517
const icon = project.icon || "ansys-icon-light.svg"; // Fallback icon
1618

17-
if (family) {
18-
if (!familyData[family]) {
19-
familyData[family] = { count: 0, icon: icon };
19+
projectFamilies.forEach((family) => {
20+
if (family) {
21+
if (!familyData[family]) {
22+
familyData[family] = { count: 0, icon: icon };
23+
}
24+
familyData[family].count += 1;
2025
}
21-
familyData[family].count += 1;
22-
}
26+
});
2327
}
2428

2529
return familyData;
@@ -239,9 +243,23 @@ function applyFilters() {
239243
const projectCards = document.querySelectorAll(".project-card");
240244

241245
projectCards.forEach((card) => {
242-
const family = card.getAttribute("data-family").toLowerCase();
243-
const rawTags = card.getAttribute("data-tags");
246+
// Handle families from data attributes
247+
const rawFamilies = card.getAttribute("data-families");
248+
let cardFamilies = [];
249+
250+
if (rawFamilies) {
251+
try {
252+
// Parse as JSON array
253+
cardFamilies = JSON.parse(rawFamilies.replace(/'/g, '"')).map(
254+
(family) => family.toLowerCase(),
255+
);
256+
} catch (error) {
257+
// Fallback to treating as single family string
258+
cardFamilies = [rawFamilies.toLowerCase()];
259+
}
260+
}
244261

262+
const rawTags = card.getAttribute("data-tags");
245263
let cardTags = [];
246264
if (rawTags) {
247265
try {
@@ -255,7 +273,10 @@ function applyFilters() {
255273

256274
// Check if the card matches the selected families
257275
const matchesAllFamilies =
258-
selectedFamilies.length === 0 || selectedFamilies.includes(family);
276+
selectedFamilies.length === 0 ||
277+
selectedFamilies.some((selectedFamily) =>
278+
cardFamilies.includes(selectedFamily),
279+
);
259280

260281
// Check if the card matches the selected tags
261282
const matchesAllTags =

doc/source/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PyAnsys packages API reference
2424
:gutter: 3 3 4 4
2525

2626
{% for project, metadata in projects['projects'].items() %}
27-
{% if 'Tools' not in metadata['family'] %}
27+
{% if 'Tools' not in metadata.get('families', []) %}
2828
.. grid-item-card:: {{ metadata['name'] }}
2929
:img-top: {{ metadata['thumbnail'] }}
3030
:link: {{ metadata['documentation']['api'] }}

doc/source/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyAnsys packages examples
1919
:gutter: 3 3 4 4
2020

2121
{% for project, metadata in projects['projects'].items() %}
22-
{% if 'Tools' not in metadata['family'] %}
22+
{% if 'Tools' not in metadata.get('families', []) %}
2323
.. grid-item-card:: {{ metadata['name'] }}
2424
:img-top: {{ metadata['thumbnail'] }}
2525
:link: {{ metadata['documentation']['examples'] }}

doc/source/index.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ it is now a collection of many Python packages for using Ansys products through
2222
<div class="projects">
2323
{% for project, metadata in projects['projects'].items() %}
2424

25-
{% set family = metadata.get('family', 'other') | lower | replace(' ', '-') %}
26-
{% set tags = metadata.get('tags', 'other') | lower %}
25+
{% set families = metadata.get('families', ['Other']) %}
26+
{% set family_attr = families | join(',') | lower | replace(' ', '-') %}
27+
{% set family_display = families[0] | lower | replace(' ', '-') %}
28+
{% set tags = metadata.get('tags', []) %}
2729

2830
<div
2931
class="project-card sd-card sd-shadow-sm sd-card-hover"
30-
data-family="{{ family }}"
32+
data-families="{{ families }}"
33+
data-family="{{ family_display }}"
3134
data-tags="{{ tags }}"
3235
onclick="window.location.href='{{ metadata['documentation']['base'] }}';"
3336
>
@@ -36,7 +39,9 @@ it is now a collection of many Python packages for using Ansys products through
3639
<p class="sd-card-title sd-font-weight-bold"> {{ metadata['name'] }} </p>
3740
<p class="sd-card-body-text"> {{ metadata['description'] }} </p>
3841
<p class="sd-card-text">
39-
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ family.capitalize() }}</span>
42+
{% for family in families %}
43+
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ family }}</span>
44+
{% endfor %}
4045
{% for tag in metadata['tags'] %}
4146
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ tag }}</span>
4247
{% endfor %}

doc/source/user_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PyAnsys packages user guides
1616
:gutter: 3 3 4 4
1717

1818
{% for project, metadata in projects['projects'].items() %}
19-
{% if 'Tools' not in metadata['family'] %}
19+
{% if 'Tools' not in metadata.get('families', []) %}
2020
.. grid-item-card:: {{ metadata['name'] }}
2121
:img-top: {{ metadata['thumbnail'] }}
2222
:link: {{ metadata['documentation']['user_guide'] }}

0 commit comments

Comments
 (0)