-
Notifications
You must be signed in to change notification settings - Fork 38
chore: refine shared build targets and npm scripts across docs and academy repos #174
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,9 @@ This repository offers a starter template for creating your own, dedicated acade | |||||
| Before you begin, ensure you have the following installed on your system: | ||||||
|
|
||||||
| 1. [**Go**](https://go.dev/doc/install) (use the version required by the root `go.mod` file) | ||||||
| 2. [**Hugo**](https://gohugo.io/getting-started/installing/) (extended version, minimum `0.146.0` as defined in `hugo.yaml`) | ||||||
| 2. [**Node.js / npm**](https://nodejs.org/) (LTS recommended) | ||||||
|
|
||||||
| > Hugo Extended is installed locally by `make setup` and does not need to be installed globally. | ||||||
|
|
||||||
| ## Getting Started | ||||||
|
|
||||||
|
|
@@ -64,7 +66,7 @@ First, create a copy of this repository under your own GitHub account. | |||||
|
|
||||||
| ### 3. Configure Your Organization Directories | ||||||
|
|
||||||
| The Academy platform uses an **Organization UID** to keep content separate and secure. You must get this ID from the Layer5 CLoud before proceeding. | ||||||
| The Academy platform uses an **Organization UID** to keep content separate and secure. You must get this ID from the Layer5 Cloud before proceeding. | ||||||
|
|
||||||
| Once you have your UID, rename the placeholder directories: | ||||||
|
|
||||||
|
|
@@ -127,30 +129,35 @@ questions: | |||||
|
|
||||||
| ### 5. Add Assets (Images & Videos) | ||||||
|
|
||||||
| Enhance your course with images and other visual aids. To ensure compatibility with the multi-tenant Academy platform, **do not use standard Markdown image links**. Instead, use the `usestatic` shortcode, which generates the correct, tenant-aware path for your assets. | ||||||
| Enhance your course with images and other visual aids using the **Page Bundling** method, which keeps assets alongside the content that references them and ensures they resolve correctly for each organization. | ||||||
|
|
||||||
| **How to Add an Image** | ||||||
|
|
||||||
| 1. Place your image file (e.g., `hugo-logo.png`) in your scoped static directory: | ||||||
| 1. Place your image file directly in the same directory as your Markdown content: | ||||||
|
|
||||||
| ```text | ||||||
| static/<your-organization-uid>/images/hugo-logo.png | ||||||
| ``` | ||||||
| 2. In your `lesson-1.md` file, embed the image using the `usestatic` shortcode. The `path` is relative to your scoped static folder: | ||||||
| ```text | ||||||
| content/learning-paths/<your-organization-uid>/ | ||||||
| └── <your-course>/ | ||||||
| └── <your-module>/ | ||||||
| ├── _index.md | ||||||
| └── hugo-logo.png | ||||||
| ``` | ||||||
|
|
||||||
| ```text | ||||||
|  | ||||||
| ``` | ||||||
| 2. In your `lesson-1.md` file, reference the image using standard Markdown syntax: | ||||||
|
|
||||||
| ```markdown | ||||||
|  | ||||||
| ``` | ||||||
|
|
||||||
| Then the system will automatically convert this into the correct URL when building the site. | ||||||
| > **Note:** The `usestatic` shortcode is **deprecated** and should not be used in new content. Use the Page Bundling method above. | ||||||
|
|
||||||
| **How to Add a Video** | ||||||
|
|
||||||
| ```text | ||||||
| {{</* card | ||||||
| {{</* card | ||||||
| title="Video: Example" */>}} | ||||||
| <video width="100%" height="100%" controls> | ||||||
| <source src="https://exmaple.mp4" type="video/mp4"> | ||||||
| <source src="https://example.com/your-video.mp4" type="video/mp4"> | ||||||
| Your browser does not support the video tag. | ||||||
| </video> | ||||||
| {{</* /card */>}} | ||||||
|
|
@@ -164,38 +171,41 @@ This project includes a `Makefile` with helper targets to simplify local develop | |||||
| # Install necessary tools and modules | ||||||
| make setup | ||||||
|
|
||||||
| # Start the local Hugo development server | ||||||
| # Start the local Hugo development server with live reload | ||||||
| make site | ||||||
|
|
||||||
| # Build the site for local consumption | ||||||
| # Serve the site once with the file watcher off (no live reload) | ||||||
| make serve | ||||||
|
|
||||||
| # Build the site locally with draft and future content enabled | ||||||
| make build | ||||||
|
|
||||||
| # Build the preview site with configured base URL | ||||||
| # Build the site for a deploy preview (honors DEPLOY_PRIME_URL) | ||||||
| make build-preview | ||||||
|
|
||||||
| # Build production site output (CI) | ||||||
| # Build the site for production (pass BASE_URL=... to set the base URL) | ||||||
| make build-production | ||||||
|
|
||||||
| # Clean the Hugo cache and restart local setup | ||||||
| # Empty the build cache, reinstall dependencies, and run the site locally | ||||||
| make clean | ||||||
|
|
||||||
| # Check Markdown for linting issues | ||||||
| make lint | ||||||
|
|
||||||
| # Fix Markdown linting issues | ||||||
| make lint-fix | ||||||
|
|
||||||
| # Check internal links in the built site | ||||||
| make check-links | ||||||
|
|
||||||
| # Verify Go is installed before starting the local site | ||||||
| make check-go | ||||||
|
|
||||||
| # Update the academy-theme package version | ||||||
| make theme-update | ||||||
|
Comment on lines
204
to
205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Remove or implement the unavailable The Makefile states that this repository has no Remove these lines or document Proposed documentation fix-# Update the academy-theme package version
-make theme-update📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| ``` | ||||||
|
|
||||||
| To preview your content locally, you can also run the Hugo server directly from the project root: | ||||||
|
|
||||||
| ```bash | ||||||
| hugo server | ||||||
| ``` | ||||||
|
|
||||||
| This will start a local server. You can view your content and check for formatting issues before publishing. | ||||||
| Run `make site` to view your content and check for formatting issues before publishing. | ||||||
|
|
||||||
| > The local preview uses basic styling. Full Academy branding and styles will be applied after your content is integrated into the cloud platform. | ||||||
|
|
||||||
|
|
@@ -262,5 +272,4 @@ Contributors are expected to follow the [CNCF Code of Conduct](https://github.co | |||||
| [figma]: https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs | ||||||
| [figma-invite]: https://www.figma.com/team_invite/redeem/GvB8SudhEOoq3JOvoLaoMs | ||||||
| [forum]: https://discuss.layer5.io | ||||||
| [slack]: https://slack.layer5.io | ||||||
|
|
||||||
| [slack]: https://slack.layer5.io | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: layer5io/academy-example
Length of output: 162
🏁 Script executed:
Repository: layer5io/academy-example
Length of output: 15035
🌐 Web query:
Hugo render hooks page resources bundle context Resources.GetMatch parent resources💡 Result:
To access page resources within a Hugo render hook, you use the.Page object available in the render hook context to call resource methods like.Resources.GetMatch [1][2][3]. Key considerations for accessing these resources include: 1. Accessing Page Resources: Inside a render hook, the.Page object represents the page currently being rendered [3]. You can access its bundled resources by calling.Page.Resources.GetMatch.Destination (or.Get) [4][5][2]. Note that.Destination contains the link or image path from the Markdown file [5][2]. 2. Bundle Context: Page resources are only available if the content file is part of a page bundle (a directory with an index.md or _index.md file) [1][6]. If the page is not a bundle, or if the resource is not correctly associated with that bundle, the lookup will fail [7][3]. 3. Branch Bundles: If you are working with a branch bundle (e.g., a sub-page within a section), you may need to access the parent page's resources if the current page itself is not a bundle or does not contain the target resource [7]. In such cases, you can use.Page.Parent.Resources.GetMatch [7]. 4. Fallback Strategy: Because render hooks are applied globally to images or links, it is a common best practice to implement a fallback mechanism [5][3]. You can attempt to find the resource in the page bundle first, and if not found, fall back to global assets using the resources.Get function [5]. Example implementation pattern: {{ $r:=.Page.Resources.GetMatch.Destination }} {{ if not $r }} {{ $r = resources.Get.Destination }} {{ end }} {{ with $r }} <img src="{{.RelPermalink }}"...> {{ end }} This ensures your render hook gracefully handles both page-local resources and global assets [5].
Citations:
🌐 Web query:
Hugo image render hook markdown image syntax Resources.GetMatch relative to markdown page💡 Result:
In Hugo, image render hooks use the
{{ else }}
{{ end }} 3. Pathing: Ensure your Markdown image syntax uses a path relative to the page bundle (e.g.,
.Pagecontext to resolve resources. To resolve an image relative to the current Markdown page (typically a leaf bundle), you use the.Page.Resources.GetMatchmethod within yourrender-image.htmlhook [1][2]. Key considerations for implementation: 1. Context: Use.Pageto access the page-level resources [1]. Inside a render hook, the.Destinationvariable contains the image URL provided in your Markdown [1][3]. 2. Resolution Strategy: Because Markdown image links are treated as destinations, they are not automatically resolved to page resources by default in the same wayreforrelrefwork unless you use a render hook [1][4]. A robust implementation typically checks for the resource in the current page bundle first, and often falls back to the globalassetsdirectory [3]: {{ $destination:=.Destination }} {{ $image:=.Page.Resources.GetMatch $destination }} {{ if not $image }} {{ $image = resources.Get $destination }} {{ end }} {{ with $image }}or, not an absolute path starting with/) [5][6]. If you use a leading slash, Hugo may attempt to resolve the image from the root of the site, causingGetMatchto fail because it is scoped to the page bundle [6]. 4. Advanced Note: If you are using components or nested structures where content might be included (e.g., viaRenderShortcodes), you may consider using.PageInnerinstead of.Pageto ensure the context remains consistent with the file currently being rendered [1]. Always wrap your resource access inwithorifstatements to handle cases where the file cannot be found, preventing your build from failing with a nil pointer error [3][6].Citations:
Use a leaf-bundle image path for the Page Bundling example.
The example puts
hugo-logo.pngin<your-module>/but then haslesson-1.mdreference it. Hugo resolves Markdown images relative to the Markdown page unless the image render hook specifically searches parent resources, so place the image in the referenced page’s bundle.Proposed documentation fix
📝 Committable suggestion
🤖 Prompt for AI Agents