FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs: fix showcase by sxzz · Pull Request #614 · unjs/unplugin · GitHub

/ unplugin Public

docs: fix showcase - #614

Merged
sxzz merged 8 commits into
mainfrom
docs/fix-showcase
Jul 31, 2026
Merged

docs: fix showcase#614
sxzz merged 8 commits into
mainfrom
docs/fix-showcase

Conversation

sxzz commented Jul 31, 2026
edited by coderabbitai Bot
Loading

Copy link
Copy Markdown
Member

Fixes #613

Summary by CodeRabbit

  • Documentation
    • Improved the reliability and consistency of generated repository documentation.
    • Repository metadata is now retrieved in a single request and written directly to showcase pages.
    • Branch information is handled consistently across generated README links and documentation.
    • Missing repository metadata and generation errors now cause the documentation build to fail clearly, preventing incomplete pages from being published.

coderabbitai Bot commented Jul 31, 2026
edited
Loading

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The repository metadata generator now fetches all configured repositories in one GraphQL request. It matches results by generated IDs and writes each repository directly to a showcase Markdown file. Repository metadata uses branch for README branch selection. The GitHub Pages workflow uses GH_TOKEN.

Changes

Showcase generation

Layer / File(s) Summary
Repository metadata contract and branch handling
docs/.vitepress/data/meta.ts, docs/.vitepress/plugins/markdownTransform.ts
RepositoryMeta defines repository metadata. The optional defaultBranch property is renamed to branch. README URL generation reads the new property.
Batch repository fetch and showcase writing
docs/.vitepress/data/gen-files.ts
The generator builds one GraphQL query for all configured repositories, performs one request, matches results by generated IDs, and writes each README to showcase/${meta.name}.md. Per-repository requests, repository.json output, result filtering, and Promise.allSettled handling are removed.
Documentation build authentication
.github/workflows/gh-pages.yml
The documentation build reads the GH_TOKEN secret instead of GITHUB_TOKEN.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Generator as gen-files.ts
  participant GitHub as GitHub GraphQL API
  participant Showcase as Showcase Markdown files
  Generator->>GitHub: Request metadata and README content for all repositories
  GitHub-->>Generator: Return aliased repository results
  Generator->>Generator: Match results by generated repository ID
  Generator->>Showcase: Write each repository README to its showcase file
Loading

Possibly related issues

  • Issue 613: The generator writes showcase files used by showcase links, addressing the reported broken showcase pages.
  • unjs/website issue 356: The changes update showcase repository metadata and generation, which affects the showcase links described in the issue.
🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies a documentation change that fixes the showcase, matching the PR objective.
Linked Issues check ✅ Passed The generator and metadata changes address the broken showcase link generation reported in issue [#613].
Out of Scope Changes check ✅ Passed All changes support showcase generation or the documentation build workflow and remain within the linked issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1 🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/fix-showcase

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

pkg-pr-new Bot commented Jul 31, 2026
edited
Loading

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unplugin@614

commit: 12da52a

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/.vitepress/data/gen-files.ts`:
- Around line 49-72: Update the generator flow around Promise.allSettled and
repoMeta so any rejected fetchRepo result is detected and causes an error to be
thrown before writeFileSync or either consola.success call executes. Preserve
metadata generation only for fully successful repository fetches; do not filter
rejected results into partial repository.json output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info ⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f51fdde-1ca5-4b3d-9f68-f9032d979328

📥 Commits

Reviewing files that changed from the base of the PR and between 9542f2d and 4f2f3a2.

📒 Files selected for processing (1)
  • docs/.vitepress/data/gen-files.ts

Comment thread docs/.vitepress/data/gen-files.ts Outdated

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/.vitepress/data/gen-files.ts`:
- Around line 80-81: Remove the console.log(results) debug statement from the
GraphQL result handling in gen-files.ts. Do not log the full results object; if
logging is required, use consola with only the repository name and status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info ⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 770bda2c-20dd-4897-ab13-029cc99aa127

📥 Commits

Reviewing files that changed from the base of the PR and between 7dcceb9 and d46198a.

📒 Files selected for processing (1)
  • docs/.vitepress/data/gen-files.ts

Comment thread docs/.vitepress/data/gen-files.ts Outdated

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/.vitepress/data/gen-files.ts`:
- Around line 32-39: Validate the GraphQL response before iterating in the
repository generation flow: surface resp.errors with a clear failure, and reject
any null aliased repository result with an error naming its key before calling
writeReadme. Remove the unsafe Record<string, Repository> assumption or narrow
it after validation, while preserving the existing metadata lookup and
writeReadme behavior for valid repositories.
- Around line 17-20: Update the GraphQL query template in the repository query
construction to remove the empty parentheses from the repositoryQuery operation
header, preserving the existing generated field selections and formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info ⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4cf6dccf-b299-4389-9e3d-ad39abb9b1d6

📥 Commits

Reviewing files that changed from the base of the PR and between d46198a and 3ccb359.

📒 Files selected for processing (3)
  • docs/.vitepress/data/gen-files.ts
  • docs/.vitepress/data/meta.ts
  • docs/.vitepress/plugins/markdownTransform.ts

Comment on lines +17 to +20
const gql = `#graphql
query repositoryQuery() {
${repositoryMeta.map(repository => buildRepoQuery(repository)).join('\n ')}
}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does GitHub's GraphQL API accept a query operation with empty parentheses like "query repositoryQuery() { ... }" when no variables are declared, or does it reject it as a syntax error?

💡 Result:

GitHub's GraphQL API will reject a query operation defined with empty parentheses, such as query repositoryQuery {... }, as a syntax error [1][2]. According to the official GraphQL specification, the parentheses following an operation name are specifically reserved for the VariablesDefinition [1][2]. If an operation defines no variables, the parentheses must be omitted entirely; including them when there are no variables is syntactically invalid [1][2]. To correctly format your query, you should either remove the empty parentheses or use the shorthand syntax if the operation is unnamed and has no variables [1][2]: Valid options: 1. Named query without variables: query repositoryQuery {... } 2. Unnamed shorthand: {... } If you must include the parentheses, they are only permitted when they contain at least one variable declaration [1][2].

Citations:


🌐 Web query:

GraphQL spec OperationDefinition variableDefinitions empty parentheses query repositoryQuery() syntax error

💡 Result:

The GraphQL specification defines VariableDefinitions as an optional, non-empty list of variable definitions enclosed in parentheses [1][2]. Specifically, the grammar is defined as: VariablesDefinition: ( VariableDefinition+) [1][3] Because the grammar requires at least one VariableDefinition (indicated by the + quantifier in EBNF notation), providing empty parentheses () for variable definitions is syntactically invalid [1][4]. If you encounter a syntax error like repositoryQuery(), it is likely due to the inclusion of empty parentheses where no variables are defined, or a misunderstanding of how the operation name and variables are structured. To resolve this: 1. If your query requires no variables, simply omit the parentheses entirely [2]. 2. If you are attempting to name your query, the correct syntax is query RepositoryName { ... } [2]. 3. If you see code like repositoryQuery() in a client-side library (such as JavaScript/TypeScript SDKs), it is likely a function call in your code, not a GraphQL query string. Ensure you are passing the correct arguments to the function and that the actual GraphQL query string contained within it follows the valid query { ... } or query Name { ... } syntax [5][6][7]. In summary, () cannot be used in a GraphQL document to represent an empty variable definition block; if no variables are required, the parentheses must be removed [1][2].

Citations:


🌐 Web query:

GitHub GraphQL API error message "Syntax Error" "query..." empty parentheses

💡 Result:

The "Syntax Error: Expected Name, found)" error when using empty parentheses in a GraphQL query occurs because the GraphQL specification does not permit empty argument lists [1][2]. In GraphQL, if a field or query does not require arguments, you must omit the parentheses entirely rather than leaving them empty [3][1][2]. If you are encountering this error while querying the GitHub GraphQL API, check your query for any fields that include empty parentheses like field() and remove them to simply use field [3][2]. For example: - Incorrect: query { repository(name: "example") { issues {... } } } - Correct: query { repository(name: "example") { issues {... } } } If you intend to provide arguments, ensure they are correctly formatted within the parentheses. If you are dealing with dynamic query generation (where arguments might sometimes be absent), you must adjust your logic to conditionally omit the parentheses when no arguments are provided, rather than defaulting to an empty set [1].

Citations:


Remove the empty parentheses from the query header.

query repositoryQuery() { is invalid GraphQL because the VariableDefinitions block is optional when no variables are used, and parentheses cannot be empty. Use query repositoryQuery { so GitHub’s GraphQL API does not reject the generated document during showcase generation.

Proposed fix
 const gql = `#graphql
-query repositoryQuery() {
+query repositoryQuery {
   ${repositoryMeta.map(repository => buildRepoQuery(repository)).join('\n  ')}
 }`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const gql = `#graphql
query repositoryQuery() {
${repositoryMeta.map(repository => buildRepoQuery(repository)).join('\n ')}
}`
const gql = `#graphql
query repositoryQuery {
${repositoryMeta.map(repository => buildRepoQuery(repository)).join('\n ')}
}`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/.vitepress/data/gen-files.ts` around lines 17 - 20, Update the GraphQL
query template in the repository query construction to remove the empty
parentheses from the repositoryQuery operation header, preserving the existing
generated field selections and formatting.

Comment on lines +32 to +39
const data = resp.data as Record<string, Repository>
for (const [key, repo] of Object.entries(data)) {
const meta = repositoryMeta.find(meta => getRepoId(meta) === key)
if (!meta) {
throw new Error(`Repository meta not found for ${key}`)
}
writeReadme(repo, meta)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Check for GraphQL errors and null repository results before writing files.

resp.data is cast to Record<string, Repository> without checking resp.errors. GitHub's repository field is nullable. If a configured repository is renamed, moved, or otherwise inaccessible, its aliased field resolves to null while the HTTP response still returns 200 with an errors entry describing the field failure. The loop at Line 33 then passes repo === null into writeReadme, which crashes at Line 65 (repo.name) with an uninformative TypeError instead of a clear error naming the failing repository.

This is exactly the class of failure (renamed/inaccessible repos causing 404s) the PR is meant to fix. Surface it explicitly instead of letting it crash blindly.

Proposed fix
 const data = resp.data as Record<string, Repository>
+if (resp.errors?.length) {
+  throw new Error(`GraphQL errors: ${JSON.stringify(resp.errors)}`)
+}
 for (const [key, repo] of Object.entries(data)) {
   const meta = repositoryMeta.find(meta => getRepoId(meta) === key)
   if (!meta) {
     throw new Error(`Repository meta not found for ${key}`)
   }
+  if (!repo) {
+    throw new Error(`Repository data not found for ${meta.owner}/${meta.name} (possibly renamed or inaccessible)`)
+  }
   writeReadme(repo, meta)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const data = resp.data as Record<string, Repository>
for (const [key, repo] of Object.entries(data)) {
const meta = repositoryMeta.find(meta => getRepoId(meta) === key)
if (!meta) {
throw new Error(`Repository meta not found for ${key}`)
}
writeReadme(repo, meta)
}
const data = resp.data as Record<string, Repository>
if (resp.errors?.length) {
throw new Error(`GraphQL errors: ${JSON.stringify(resp.errors)}`)
}
for (const [key, repo] of Object.entries(data)) {
const meta = repositoryMeta.find(meta => getRepoId(meta) === key)
if (!meta) {
throw new Error(`Repository meta not found for ${key}`)
}
if (!repo) {
throw new Error(`Repository data not found for ${meta.owner}/${meta.name} (possibly renamed or inaccessible)`)
}
writeReadme(repo, meta)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/.vitepress/data/gen-files.ts` around lines 32 - 39, Validate the GraphQL
response before iterating in the repository generation flow: surface resp.errors
with a clear failure, and reject any null aliased repository result with an
error naming its key before calling writeReadme. Remove the unsafe
Record<string, Repository> assumption or narrow it after validation, while
preserving the existing metadata lookup and writeReadme behavior for valid
repositories.

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
🧹 Nitpick comments (1)
.github/workflows/gh-pages.yml (1)

25-25: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add GH_TOKEN to the workflow docs or keep GITHUB_TOKEN.

This workflow now reads secrets.GH_TOKEN, but repository docs only document setting GITHUB_TOKEN for docs generation. Add a GH_TOKEN setup step or update .docs/.env.example and docs/README.md to use GH_TOKEN, so deploy runs do not fail due to a missing token.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/gh-pages.yml at line 25, Align the token name used by the
workflow with the documented configuration: either change the GITHUB_TOKEN
assignment in the workflow to use secrets.GITHUB_TOKEN, or update
.docs/.env.example and docs/README.md to document GH_TOKEN consistently. Ensure
docs deployment uses the same token name everywhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/gh-pages.yml:
- Line 25: Align the token name used by the workflow with the documented
configuration: either change the GITHUB_TOKEN assignment in the workflow to use
secrets.GITHUB_TOKEN, or update .docs/.env.example and docs/README.md to
document GH_TOKEN consistently. Ensure docs deployment uses the same token name
everywhere.

ℹ️ Review info ⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb7be91a-619c-4c20-9f85-60e7b53f31d6

📥 Commits

Reviewing files that changed from the base of the PR and between 3ccb359 and b09c2e8.

📒 Files selected for processing (1)
  • .github/workflows/gh-pages.yml

sxzz merged commit ed8ae0b into main Jul 31, 2026
12 checks passed
sxzz deleted the docs/fix-showcase branch July 31, 2026 14:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Showcase plugins with broken links on website

1 participant


Back | FazBrowse Home | New Git URL