CodeOwners.md - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
CodeOwners.md (1974B)
---
1 ---
2 title: CodeOwners
3 description: Returns of slice of code owners for the given page, derived from the CODEOWNERS file in the root of the project directory.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: '[]string'
9 signatures: [PAGE.CodeOwners]
10 ---
11
12 GitHub and GitLab support CODEOWNERS files. This file specifies the users responsible for developing and maintaining software and documentation. This definition can apply to the entire repository, specific directories, or to individual files. To learn more:
13
14 - [GitHub CODEOWNERS documentation]
15 - [GitLab CODEOWNERS documentation]
16
17 Use the `CodeOwners` method on a `Page` object to determine the code owners for the given page.
18
19 [GitHub CODEOWNERS documentation]: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
20 [GitLab CODEOWNERS documentation]: https://docs.gitlab.com/ee/user/project/code_owners.html
21
22 To use the `CodeOwners` method you must enable access to your local Git repository:
23
24 {{< code-toggle file=hugo >}}
25 enableGitInfo = true
26 {{< /code-toggle >}}
27
28 Consider this project structure:
29
30 ```text
31 my-project/
32 ├── content/
33 │ ├── books/
34 │ │ └── les-miserables.md
35 │ └── films/
36 │ └── the-hunchback-of-notre-dame.md
37 └── CODEOWNERS
38 ```
39
40 And this CODEOWNERS file:
41
42 ```text
43 * @jdoe
44 /content/books/ @tjones
45 /content/films/ @mrichards @rsmith
46 ```
47
48 The table below shows the slice of code owners returned for each file:
49
50 Path|Code owners
51 :--|:--
52 `books/les-miserables.md`|`[@tjones]`
53 `films/the-hunchback-of-notre-dame.md`|`[@mrichards @rsmith]`
54
55 Render the code owners for each content page:
56
57 ```go-html-template
58 {{ range .CodeOwners }}
59 {{ . }}
60 {{ end }}
61 ```
62
63 Combine this method with [`resources.GetRemote`] to retrieve names and avatars from your Git provider by querying their API.
64
65 [`resources.GetRemote`]: /functions/resources/getremote/