Skip to content

On the package search results page: Show a "docs" link only when the package has documentation #1576

@sabine

Description

@sabine

Task

Currently, every search result on the packages search results page (e.g. https://ocaml.org/packages/search?q=sundial) has a "Documentation" link, but not every package has documentation.

Screenshot 2023-10-05 at 10-41-06 OCaml Packages · Search Result

Instead, when a package has no documentation, no documentation link should be rendered.

How to solve this issue:

  1. Look at handler.ml for an example how to find out if a package has documentation:
    let* latest_documented_version =
    Ocamlorg_package.latest_documented_version t name
    in
    match latest_documented_version with
    | None -> response_404_page
    | Some version ->
    Dream.redirect req ~code:302
    (Url.Package.documentation ?hash
    ~version:(Ocamlorg_package.Version.to_string version)
    ~page:path
    (Ocamlorg_package.Name.to_string name))
  2. modify the packages_search function in handler.ml and the packages_search.eml template to omit the "Documentation" link when there is no documentation.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions