Skip to content

Refactor: Update asset handling to use Page Bundles #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 10, 2025

Conversation

zihanKuang
Copy link
Contributor

@zihanKuang zihanKuang commented Aug 8, 2025

Notes for Reviewers

This PR fixes #91

The goal is to change how asset URLs for banners and badges are handled in the theme. The previous method used the /static directory. This update moves the implementation to the Page Bundle model to create consistent behavior for all assets.

Summary of Changes

The implementation includes the following changes:

  • Replaced Asset Logic

    • The old banner-url.html partial has been deleted.
    • A new partial, resolve-local-resource.html, has been added. It finds local asset paths within a Page Bundle and returns an absolute permalink.
  • Updated Partials

    • All layouts that previously used banner-url.html (learning-path.json.html, common-curricula-properties.html, badge.html) have been refactored to use the new partials.
    • The badge.html partial retains its original function to support both remote URLs and local file paths. The local path logic is now handled by the new resolve-local-resource.html partial.
  • Bug Fix

    • Fixed a bug in badge.html where the PNG image path was incorrectly referencing the SVG variable. It now correctly references the PNG variable.

Relevant docs PR for banner update: layer5io/docs#758 (merged)
Relevant schema PR for banner update: meshery/schemas#399

The changes are incompatible with the existing format. The original content needs to be modified before the relevant PRs can be merged.

@zihanKuang
Copy link
Contributor Author

This is the test I performed:

  • Case 1: Learning Path with a valid local banner

    • Setup: The Exoscale 101 learning path has banner: "exoscale-icon.svg" in its front matter, and the image file exists in its page bundle.
    • Result: The JSON output correctly contains the full, absolute permalink for the banner.

      "banner": "https://cloud.layer5.io/academy/learning-paths/orgID/exoscale-101/exoscale-icon.svg"

  • Case 2: Nested Course with a valid local banner

    • Setup: The nested Exoscale - Advanced course also correctly references an image in its page bundle (banner: "exoscale-icon.svg").
    • Result: The logic successfully resolves the banner URL for the nested content.

      "banner": "https://cloud.layer5.io/academy/learning-paths/orgID/exoscale-101/advanced-course/exoscale-icon.svg"

  • Case 3: Content with an invalid path

    • Setup: The End-to-End Kubernetes learning path references its banner using a subdirectory (banner: "images/exoscale-icon.svg"), which doesn't exist.
    • Result: The system correctly fails to find the resource and returns an empty string, ensuring the JSON output remains valid.

      "banner": ""

@zihanKuang zihanKuang requested a review from aabidsofi19 August 8, 2025 08:49
@zihanKuang zihanKuang added the pr/on hold PR/Issue on hold label Aug 8, 2025
@zihanKuang zihanKuang merged commit 83605fa into layer5io:master Aug 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor academy-theme to use page bundles for all banner and badge images
1 participant