Skip to content

refactor: combining shared code markdown renderer readme & changelog #2717

Open
WilcoSp wants to merge 249 commits into
npmx-dev:mainfrom
WilcoSp:feat/markdown-kit
Open

refactor: combining shared code markdown renderer readme & changelog #2717
WilcoSp wants to merge 249 commits into
npmx-dev:mainfrom
WilcoSp:feat/markdown-kit

Conversation

@WilcoSp
Copy link
Copy Markdown
Contributor

@WilcoSp WilcoSp commented May 11, 2026

click here to preview pr

🔗 Linked issue

This pr is part of #501

🧭 Context

Currently changelog uses a seperate marked markdown renderer from readme, this pr takes the shared code and makes it into a "markdown kit" so that code that can be shared will be shared

📚 Description

Moves shared code for both changelog & readme to a shared markdown kit while still allowing for each to have their unique needs.

additional changes

  • Heading have been changed to be more consistent and easier to use by users to the following:
    ## heading -> <hx><a href="#...>heading</a></hx>
    ## [Example](https://example.com) -> <hx><a href="https://example.com">Example</a><a href="#...></a></hx>
  • Tests have been added for the changelog markdown renderer for what not shared or changed for changelog.
  • Thanks to the tests also some bugs have been fixed.
  • Also for changelog.md the jumping to the requested version has been fixed, now if "3.5.1" is requested then "3.5.11" won't be selected.
  • 502 will now only be returned when ungh.cc is exhausted, others have been changed to 500
  • at package.takumi.vue & externallinks.vue the provider icons are now given via the useProviderIcon composable
  • change the unocss config to include useProviderIcon composable
  • fixed a bug to where when switching between package tabs that the message "package doesn't have changelogs" is being shown while earlier it did have it.
  • changed how the skeleton loaders is shown in package changelog, now pending is being used from useLazyFetch in the ChangelogReleases & ChangelogMarkdown components instead of using <suspense> at the package-changelog page, this should remove/reduce the blank screen between showing the skeleton laoders & showing data.
  • each release has now a direct link to the original release on github (and future git providers)
  • adding version_distribution_title translation and fixing a typo for Dutch (nl.json)
  • some further smaller refactors

AI usage

For app/utils/header-version-matcher.ts I've used Gemini to get the regex for matching more exact the requested version in a toc item text

notes

The branch of this pr was based on #1233 initially, that's why there are so many commits, file changes does show correctly what has changed

the createLink factory function will receive in future PRs changes, due to future plans to format git links to #pr, @person etc

WilcoSp and others added 30 commits February 4, 2026 21:17
excludes changelog releases due to needing api calls
…gelog info endpoint will return ChangelogMarkdownInfo instead of ChangelogReleaseInfo
…nge by ungh.cc

added version_distribution_title translation to Dutch
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/nl.json Localization changed, will be marked as complete. 🔄️
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@i18n/locales/nl.json`:
- Line 719: The translation string for the weekly downloads title has a typo:
update the value of the "version_distribution_title" key to use "Wekelijkse"
instead of "Weekelijkse" so the user-facing label reads "Wekelijkse downloads
voor versie {version}" (edit the JSON value for the version_distribution_title
entry).

In `@uno.config.ts`:
- Around line 36-40: The UnoCSS include currently references
'./src/composables/useProviderIcon.ts' but the project imports the module as
'~/composables/useProviderIcon' (the useProviderIcon composable) and UnoCSS
therefore isn't scanning the actual module; update the include array in
uno.config.ts to reference the same module used by imports (e.g. replace
'./src/composables/useProviderIcon.ts' with '~/composables/useProviderIcon' or
the correct module alias used in your code) so UnoCSS will scan useProviderIcon
and generate the provider icon classes.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5acb90f1-35a2-41d1-8ac1-2ec96b642f6e

📥 Commits

Reviewing files that changed from the base of the PR and between 568acc2 and 4ef1d58.

📒 Files selected for processing (8)
  • app/components/Changelog/Card.vue
  • app/components/Package/Header.vue
  • app/pages/package-changelog/[[org]]/[name].vue
  • i18n/locales/nl.json
  • server/api/changelog/md/[provider]/[owner]/[repo]/[...path].get.ts
  • server/utils/changelog/detectChangelog.ts
  • test/nuxt/a11y.spec.ts
  • uno.config.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/components/Changelog/Card.vue
  • test/nuxt/a11y.spec.ts
  • server/api/changelog/md/[provider]/[owner]/[repo]/[...path].get.ts
  • app/components/Package/Header.vue

Comment thread i18n/locales/nl.json Outdated
Comment thread uno.config.ts
@WilcoSp
Copy link
Copy Markdown
Contributor Author

WilcoSp commented May 30, 2026

I've just fixed a small issue with git provider icons not showing (for example codeberg), this happened because all the icons where moved to the useProviderIcon composable instead of being inside the .vue files.

I've just committed a fix that now includes the useProviderIcon into unocss's config (commits: 4ef1d58 & 4487bc1)

Copy link
Copy Markdown
Member

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

first pass 😅

Comment thread uno.config.ts
Comment on lines +36 to +40
include: [
/\.(vue|mdx|html)($|\?)/,
// git provider icons composable
'**/composables/useProviderIcon.ts',
],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How come?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the icons for the git providers have been moved to a single composable so that the map isn't writen again when needed.

but because the composable was in a rs file it wasn't being scanned by unocss for potential icons which caused blank to be shown for ecample codeberg.

if it should/ could be different let me know

Comment thread server/api/changelog/md/[provider]/[owner]/[repo]/[...path].get.ts
Comment thread server/api/changelog/releases/[provider]/[owner]/[repo].get.ts Outdated
Comment thread app/components/Changelog/Markdown.vue Outdated
@@ -0,0 +1,11 @@
<template>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a skeleton layer right? Why isn't that used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changelog doesn't use a skeleton layer, do you maybe have examples of skeleton layers as idk what it is?

Comment thread app/composables/useProviderIcon.ts Outdated
Comment thread i18n/locales/nl.json
"title_both": "Aanzienlijke toename in omvang en dependencies sinds v{version}",
"size": "De installatiegrootte is toegenomen met {percent} ({size} groter)",
"deps": "{count} meer dependencies"
"deps": "{count} meer dependency | {count} meer dependencies"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Try to keep distinct changes in a seperate PR if you can, makes reviewing easier and faster 😄

Comment thread app/composables/usePackageChangelog.ts Outdated
const response = await $fetch(`https://ungh.cc/repos/${ref.owner}/${ref.repo}/releases/latest`)

const path = matchedChangelog.replace(/^.*\/blob\/[^/]+\//i, '')
const { release } = v.parse(v.object({ release: GithubReleaseSchama }), response)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this validation error is getting lost I think, not sure if that's intentional - optionally, it could also be moved up and use safeParse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah in general the error management doesn't go well here, the only thing that should be stopped is a 404, anything else should be handled by the top level try catch.

I'll change it when I'm back home

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've fixed the returning of the errors for checkLatestGithubRelease and also changed it to a tuple return of [Result, null] | [null, Error].

I've changed it to a tuple to make it easier to read and understand when a normal result is given or an error.

Comment on lines +36 to +38
export function usePackageHasChangelogFromState() {
return useState<boolean>(key)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I find this has changelog composable a little hard to follow - what's the rationale? 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's there to fix the bug in the video of #1233 (comment), when using useLazyFetch when not having enough data to create the url & having a data null uri as placeholder causes the information to be removed when switching pages.

that's why for the commandpallet uses this composable instead to prevent the bug, at the packageHeader component the usePackageHasChangelog composable is used with setting the state enabled, that way the command pallet is still able to know whether it should include changelog or not.

the only other fix could be to always have changelog in the command pallet, many other ideas I had to fix it didn't work or where not trust able.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@server/utils/changelog/detectChangelog.ts`:
- Around line 115-118: The code in detectChangelog.ts calls Error.isError(e)
which may not exist on Node versions <24.3; change the guard to check
availability first and fall back to instanceof: replace the direct
Error.isError(e) usage in the function that handles errors (the block containing
the current "if (!Error.isError(e)) { return [false, null] }") with a
conditional that uses typeof Error.isError === 'function' ? Error.isError(e) : e
instanceof Error so the check is safe across Node versions.

In `@shared/schemas/changelog/release.ts`:
- Line 11: The release schema contains a stray required field "mario:
v.string()" that causes v.parse(v.object({ release: GithubReleaseSchama })) in
detectChangelog.ts to always throw; remove the "mario" field from the schema in
shared/schemas/changelog/release.ts (the object that defines
GithubReleaseSchama) so the schema matches actual ungh.cc release payloads and
lets checkLatestGithubRelease / detectChangelog parse real releases
successfully.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c159c333-992f-4c3b-801d-e0e381f10a35

📥 Commits

Reviewing files that changed from the base of the PR and between 93a14a2 and acdf8f8.

📒 Files selected for processing (7)
  • app/components/Changelog/Markdown.vue
  • app/composables/usePackageChangelog.ts
  • app/composables/useProviderIcon.ts
  • server/api/changelog/md/[provider]/[owner]/[repo]/[...path].get.ts
  • server/api/changelog/releases/[provider]/[owner]/[repo].get.ts
  • server/utils/changelog/detectChangelog.ts
  • shared/schemas/changelog/release.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/composables/useProviderIcon.ts
  • server/api/changelog/releases/[provider]/[owner]/[repo].get.ts
  • app/components/Changelog/Markdown.vue
  • app/composables/usePackageChangelog.ts

Comment thread server/utils/changelog/detectChangelog.ts Outdated
Comment thread shared/schemas/changelog/release.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review This PR is waiting for a review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants