mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-25 14:35:24 +02:00
Package-page markdown (READMEs, descriptions, release notes) was rendered as a plain document, so relative links and images resolved against the site root and 404'd. This renders it in the context of the package's linked repository instead, falling back to plain rendering when the package has no linked repo. For a README link `[usage](docs/usage.md)` in a package linked to `user/repo` (default branch `main`): | | Resolved link | |---|---| | Before | `/docs/usage.md` | | After | `/user/repo/src/branch/main/docs/usage.md` | For an npm monorepo package with `repository.directory: packages/foo`, an image `` resolves to `/user/repo/src/branch/main/packages/foo/logo.png`. Applied to every package content template that renders markdown: `cargo`, `chef`, `composer`, `npm`, `nuget`, `pub`, `pypi`. Links resolve against the repository default branch (metadata records no publish commit). Only the web package detail page is affected; registry API responses are unchanged. Note: as part of restructuring `npm.tmpl`, the package description and README now render as separate sections instead of the README replacing the description, matching the existing `cargo`/`composer`/`pub` layout. Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
64 lines
2.4 KiB
Handlebars
64 lines
2.4 KiB
Handlebars
{{if eq .PackageDescriptor.Package.Type "cargo"}}
|
|
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.installation"}}</h4>
|
|
<div class="ui attached segment">
|
|
<div class="ui form">
|
|
<div class="field">
|
|
<label>{{svg "octicon-code"}} {{ctx.Locale.Tr "packages.cargo.registry"}}</label>
|
|
<div class="markup"><pre class="code-block"><code>[registry]
|
|
default = "gitea"
|
|
|
|
[registries.gitea]
|
|
index = "sparse+{{ctx.AppFullLink}}/api/packages/{{.PackageDescriptor.Owner.Name}}/cargo/" # Sparse index
|
|
# index = "{{ctx.AppFullLink}}/{{.PackageDescriptor.Owner.Name}}/_cargo-index.git" # Git
|
|
|
|
[net]
|
|
git-fetch-with-cli = true</code></pre></div>
|
|
</div>
|
|
<div class="field">
|
|
<label>{{svg "octicon-terminal"}} {{ctx.Locale.Tr "packages.cargo.install"}}</label>
|
|
<div class="markup"><pre class="code-block"><code>cargo add {{.PackageDescriptor.Package.Name}}@{{.PackageDescriptor.Version.Version}}</code></pre></div>
|
|
</div>
|
|
<div class="field">
|
|
<label>{{ctx.Locale.Tr "packages.registry.documentation" "Cargo" "https://docs.gitea.com/usage/packages/cargo/"}}</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{if or .PackageDescriptor.Metadata.Description .PackageDescriptor.Metadata.Readme}}
|
|
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.about"}}</h4>
|
|
{{if .PackageDescriptor.Metadata.Description}}<div class="ui attached segment">{{.PackageDescriptor.Metadata.Description}}</div>{{end}}
|
|
{{if .PackageDescriptor.Metadata.Readme}}<div class="ui attached segment">{{ctx.RenderUtils.RenderPackageMarkdown .PackageDescriptor.Metadata.Readme .PackageDescriptor.Repository}}</div>{{end}}
|
|
{{end}}
|
|
|
|
{{if .PackageDescriptor.Metadata.Dependencies}}
|
|
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.dependencies"}}</h4>
|
|
<div class="ui attached segment">
|
|
<table class="ui single line very basic table">
|
|
<thead>
|
|
<tr>
|
|
<th class="ten wide">{{ctx.Locale.Tr "packages.dependency.id"}}</th>
|
|
<th class="six wide">{{ctx.Locale.Tr "packages.dependency.version"}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .PackageDescriptor.Metadata.Dependencies}}
|
|
<tr>
|
|
<td>{{.Name}}</td>
|
|
<td>{{.Req}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .PackageDescriptor.Metadata.Keywords}}
|
|
<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.keywords"}}</h4>
|
|
<div class="ui attached segment">
|
|
{{range .PackageDescriptor.Metadata.Keywords}}
|
|
{{.}}
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|