Skip to content

Add homepage latest release badge - #277

Merged
waruqi merged 2 commits into
xmake-io:masterfrom
Arteiimis:feat/homepage-release-badge
Apr 11, 2026
Merged

Add homepage latest release badge#277
waruqi merged 2 commits into
xmake-io:masterfrom
Arteiimis:feat/homepage-release-badge

Conversation

@Arteiimis

Copy link
Copy Markdown
Contributor

Add a homepage badge synced with the latest xmake release.

@vercel

vercel Bot commented Apr 11, 2026

Copy link
Copy Markdown

@Arteiimis is attempting to deploy a commit to the waruqi's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Apr 11, 2026

Copy link
Copy Markdown

Deploy Preview for mellow-creponne-9cce3d ready!

Name Link
🔨 Latest commit 45e7372
🔍 Latest deploy log https://app.netlify.com/projects/mellow-creponne-9cce3d/deploys/69da524e83688c00089c09a9
😎 Deploy Preview https://deploy-preview-277--mellow-creponne-9cce3d.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a dynamic release badge for the home page by fetching the latest release information from the GitHub API. Key changes include a new script to generate release data, a dedicated Vue component for the badge, and integration into the VitePress theme layout. The review feedback highlights several improvement opportunities: refining the hero configuration types and rendering logic to handle VitePress's object-based name property, adopting a more robust method for home page detection via frontmatter, and implementing a time-based cache to prevent hitting GitHub API rate limits during frequent builds.

Comment on lines +6 to +10
type HeroConfig = {
name?: string
text?: string
tagline?: string
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The HeroConfig type for the name property is too restrictive. In VitePress, the hero name can be either a string or an object containing text and an optional tag. If an object is provided in the configuration, the current implementation will render [object Object] because of the v-html binding on line 40.

type HeroConfig = {
  name?: string | { text: string; tag?: string }
  text?: string
  tagline?: string
}

<template>
<h1 class="heading">
<span class="xmake-hero-name-row">
<span v-if="hero.name" v-html="hero.name" class="name clip"></span>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Handle cases where hero.name is an object (a standard VitePress configuration pattern) to ensure the text is correctly extracted for rendering, preventing [object Object] from appearing in the UI.

      <span v-if="hero.name" v-html="typeof hero.name === 'string' ? hero.name : hero.name.text" class="name clip"></span>

Comment on lines +41 to +43
const isHomePage = computed(() => {
return page.value.relativePath === 'index.md' || page.value.relativePath === 'zh/index.md'
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current check for the home page is restricted to specific file paths (index.md and zh/index.md). This approach is brittle as it will break if new languages are added or if the home page file is named differently. It is more idiomatic and robust to rely on the layout: home property in the frontmatter, which is the standard VitePress way to identify a home page.

    const isHomePage = computed(() => page.value.frontmatter.layout === 'home')

Comment on lines +77 to +79
const cachedRelease = readCachedRelease()

try {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The script fetches the latest release data from the GitHub API on every build or dev server start. Unauthenticated requests to the GitHub API are rate-limited to 60 per hour. To avoid hitting this limit during local development or frequent CI builds, consider adding a simple time-based cache check to skip fetching if the data was updated recently (e.g., within the last hour).

  const cachedRelease = readCachedRelease()
  const cacheAge = Date.now() - new Date(cachedRelease.fetchedAt || 0).getTime()
  if (cacheAge < 3600000 && cachedRelease.tagName) {
    console.log('Using cached release data: ' + cachedRelease.tagName)
    return
  }

  try {

@waruqi
waruqi merged commit 9bb5364 into xmake-io:master Apr 11, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants