Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions doc/source/_static/js/landing_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ function collectFamilies(data) {
for (const project of projects) {
if (!project || typeof project !== "object") continue;

const family = project.family;
// Handle families array
const projectFamilies = project.families || ["Other"];

const icon = project.icon || "ansys-icon-light.svg"; // Fallback icon

if (family) {
if (!familyData[family]) {
familyData[family] = { count: 0, icon: icon };
projectFamilies.forEach((family) => {
if (family) {
if (!familyData[family]) {
familyData[family] = { count: 0, icon: icon };
}
familyData[family].count += 1;
}
familyData[family].count += 1;
}
});
}

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

projectCards.forEach((card) => {
const family = card.getAttribute("data-family").toLowerCase();
const rawTags = card.getAttribute("data-tags");
// Handle families from data attributes
const rawFamilies = card.getAttribute("data-families");
let cardFamilies = [];

if (rawFamilies) {
try {
// Parse as JSON array
cardFamilies = JSON.parse(rawFamilies.replace(/'/g, '"')).map(
(family) => family.toLowerCase(),
);
} catch (error) {
// Fallback to treating as single family string
cardFamilies = [rawFamilies.toLowerCase()];
}
}

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

// Check if the card matches the selected families
const matchesAllFamilies =
selectedFamilies.length === 0 || selectedFamilies.includes(family);
selectedFamilies.length === 0 ||
selectedFamilies.some((selectedFamily) =>
cardFamilies.includes(selectedFamily),
);

// Check if the card matches the selected tags
const matchesAllTags =
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PyAnsys packages API reference
:gutter: 3 3 4 4

{% for project, metadata in projects['projects'].items() %}
{% if 'Tools' not in metadata['family'] %}
{% if 'Tools' not in metadata.get('families', []) %}
.. grid-item-card:: {{ metadata['name'] }}
:img-top: {{ metadata['thumbnail'] }}
:link: {{ metadata['documentation']['api'] }}
Expand Down
2 changes: 1 addition & 1 deletion doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PyAnsys packages examples
:gutter: 3 3 4 4

{% for project, metadata in projects['projects'].items() %}
{% if 'Tools' not in metadata['family'] %}
{% if 'Tools' not in metadata.get('families', []) %}
.. grid-item-card:: {{ metadata['name'] }}
:img-top: {{ metadata['thumbnail'] }}
:link: {{ metadata['documentation']['examples'] }}
Expand Down
13 changes: 9 additions & 4 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ it is now a collection of many Python packages for using Ansys products through
<div class="projects">
{% for project, metadata in projects['projects'].items() %}

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

<div
class="project-card sd-card sd-shadow-sm sd-card-hover"
data-family="{{ family }}"
data-families="{{ families }}"
data-family="{{ family_display }}"
data-tags="{{ tags }}"
onclick="window.location.href='{{ metadata['documentation']['base'] }}';"
>
Expand All @@ -36,7 +39,9 @@ it is now a collection of many Python packages for using Ansys products through
<p class="sd-card-title sd-font-weight-bold"> {{ metadata['name'] }} </p>
<p class="sd-card-body-text"> {{ metadata['description'] }} </p>
<p class="sd-card-text">
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ family.capitalize() }}</span>
{% for family in families %}
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ family }}</span>
{% endfor %}
{% for tag in metadata['tags'] %}
<span class="sd-sphinx-override sd-badge sd-bg-muted sd-text-primary">{{ tag }}</span>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PyAnsys packages user guides
:gutter: 3 3 4 4

{% for project, metadata in projects['projects'].items() %}
{% if 'Tools' not in metadata['family'] %}
{% if 'Tools' not in metadata.get('families', []) %}
.. grid-item-card:: {{ metadata['name'] }}
:img-top: {{ metadata['thumbnail'] }}
:link: {{ metadata['documentation']['user_guide'] }}
Expand Down
Loading
Loading