package lib import ( "fmt" "net/http" ) type WikiResponse struct { Data struct { Pages struct { List []struct { UpdatedAt string Title string Path string } } } } type WikiFetcher struct { BaseFetcher } func (f *WikiFetcher) Name() string { return "WikiJS" } func (f *WikiFetcher) Fetch() []Entry { query := `{"query":"{ pages { list(orderBy: UPDATED, orderByDirection: DESC, limit: 1){ path, updatedAt, title }}}"}` req := FetcherRequest{ BaseURL: f.BaseURL, Path: "/graphql", Method: http.MethodPost, Headers: map[string]string{ "Authorization": "Bearer " + f.Token, "Content-Type": "application/json", }, Body: []byte(query), } var resp WikiResponse if err := req.Run(&resp); err != nil { return nil } if len(resp.Data.Pages.List) == 0 { return nil } page := resp.Data.Pages.List[0] entry := f.TryCreateEntry( "wiki", page.UpdatedAt, fmt.Sprintf("📖 [%s] - %s", f.Name(), page.Title), fmt.Sprintf("%s/%s", f.BaseURL, page.Path), ) if entry != nil { return []Entry{*entry} } return nil }