Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-29 13:16:10 +01:00
forgejo/templates/base
Xavier Vello 147ae2c5be Fix opengraph meta for wiki pages (#4427)
Fixes https://codeberg.org/forgejo/forgejo/issues/4417 by adding a conditional branch to the `head_opengraph` template to match wiki pages. I tried to be consistent with the other types:

- `og:title` is the wiki page title
- `og:url` is built via `{{AppUrl}}{{.Link}}` like it is done for commit and file views. This has the caveat of doubling the slash (see test below). Should we `{{trimSuffix "/" AppUrl}}` to remove this, if sprig is available?
- `og:description` is the repository description to match GH behaviour. Also, the first sentences of the page might not be descriptive enough. Should we prefix the repo description with the repo name?
- `og:type` and `og:image` are common

Added a `TestOpenGraphProperties` integration test using existing fixtures. Coverage is not 100% but can be improved later.

## Output on a test repo

```html
<meta property="og:title" content="Project architecture">
<meta property="og:url" content="http://localhost:3000//xvello/wiki-test/wiki/Project-architecture">
<meta property="og:description" content="description for a test project">
<meta property="og:type" content="object">
<meta property="og:image" content="http://localhost:3000/avatars/3dd4d1e4eef065d1b4ad4bdb081ab6e7">
```

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4427
Co-authored-by: Xavier Vello <xavier.vello@gmail.com>
Co-committed-by: Xavier Vello <xavier.vello@gmail.com>
2024-07-10 18:29:35 +00:00
..
alert.tmpl Rename Str2html to SanitizeHTML and clarify its behavior (#29516) 2024-03-06 12:10:45 +08:00
alert_details.tmpl Rename Str2html to SanitizeHTML and clarify its behavior (#29516) 2024-03-06 12:10:45 +08:00
disable_form_autofill.tmpl Disable form autofill (#17291) 2021-10-19 01:08:41 +03:00
footer.tmpl Remove DataRaceCheck (#29258) 2024-02-19 22:58:33 +01:00
footer_content.tmpl Add [other].SHOW_FOOTER_POWERED_BY setting to hide Powered by (#30253) 2024-04-07 15:40:31 +02:00
head.tmpl Add slogan config (#3752) 2024-06-07 17:12:48 +00:00
head_navbar.tmpl Migrate gt-hidden to tw-hidden (#30046) 2024-03-30 07:17:29 +01:00
head_opengraph.tmpl Fix opengraph meta for wiki pages (#4427) 2024-07-10 18:29:35 +00:00
head_script.tmpl Add <overflow-menu>, rename webcomponents (#29400) 2024-03-20 08:46:29 +01:00
head_style.tmpl Rename the default themes to gitea-light, gitea-dark, gitea-auto (#27419) 2023-10-06 09:46:36 +02:00
modal_actions_confirm.tmpl cleanup locale function usage (#27227) 2023-09-24 20:31:58 +00:00
paginate.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00