Skip to content

Commit 5b44304

Browse files
heiskrCopilotCopilot
authored
Add README for src/changelogs (#58799)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: heiskr <1221423+heiskr@users.noreply.github.com>
1 parent abf0033 commit 5b44304

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/changelogs/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Changelogs (`src/changelogs`)
2+
3+
This directory contains the logic for fetching, parsing, and caching RSS feeds from the GitHub Blog to display changelog items on documentation pages.
4+
5+
## Purpose & Scope
6+
7+
The primary purpose is to provide a "What's New" section on specific documentation pages by pulling the latest updates from relevant GitHub Blog RSS feeds. It handles fetching RSS feeds, caching responses to prevent rate limiting, and parsing feed items for display.
8+
9+
## Architecture & Key Assets
10+
11+
### Core Logic
12+
13+
`lib/changelog.ts` is the main module. It uses `rss-parser` to fetch feeds and implements a two-layer caching strategy:
14+
15+
1. Memory Cache: `globalCache` Map for fast access within the process.
16+
2. Disk Cache: Writes JSON files to `os.tmpdir()` (or a custom path) to persist across server restarts in development/test environments.
17+
18+
`getChangelogItems` is the public API that returns a list of formatted changelog items.
19+
20+
### Consumers
21+
22+
The middleware `src/frame/middleware/context/whats-new-changelog.ts` uses this library to inject changelog data into the page context (`req.context.whatsNewChangelog`) based on page frontmatter.
23+
24+
Currently, the following product landing pages display a changelog:
25+
26+
- GitHub Actions (`content/actions/index.md`)
27+
- GitHub Education (`content/education/index.md`)
28+
- GitHub Enterprise (`content/admin/index.md`)
29+
- GitHub Packages (`content/packages/index.md`)
30+
31+
## Setup & Usage
32+
33+
### Enabling on a Page
34+
35+
To display a changelog on a documentation page, add the `changelog` property to the page's frontmatter:
36+
37+
```yaml
38+
changelog:
39+
label: packages
40+
prefix: "Packages: "
41+
```
42+
43+
- `label`: Determines the feed URL (e.g., `packages` -> `https://github.blog/changelog/label/packages`).
44+
- `prefix`: (Optional) A string to strip from the beginning of feed item titles.
45+
- `versions`: (Optional) Specifies which versions of the docs should display the changelog.
46+
47+
### Environment Variables
48+
49+
- `CHANGELOG_DISABLED`: Set to `true` to disable fetching (returns undefined). This is often necessary in tests where external network requests are flaky or blocked.
50+
- `CHANGELOG_CACHE_FILE_PATH`: (Optional) Override the default disk cache location.
51+
52+
## Data & External Dependencies
53+
54+
- Source: [GitHub Blog](https://github.blog) RSS feeds (e.g., `https://github.blog/changelog/label/packages/feed`).
55+
- Dependencies: `rss-parser` is used to parse the XML RSS feeds.
56+
57+
## Cross-links & Ownership
58+
59+
- **Owner**: Docs Engineering owns this code. Marketing Engineering owns the GitHub Blog and its feeds.
60+
- **Related Directories**:
61+
- `src/frame/middleware/context`: Contains the middleware that invokes this logic.
62+
- `src/changelogs/tests`: Contains tests for this module.
63+
64+
## Current State & Next Steps
65+
66+
- **Current State**: The system is stable and considered KTLO (Keep the Lights On). It fetches the latest 3 items from the specified feed.
67+
- **Next Steps**: None planned.

0 commit comments

Comments
 (0)