multiple content per fetcher
This commit is contained in:
@@ -26,7 +26,8 @@ func (f *WikiFetcher) Name() string {
|
||||
}
|
||||
|
||||
func (f *WikiFetcher) Fetch() []Entry {
|
||||
query := `{"query":"{ pages { list(orderBy: UPDATED, orderByDirection: DESC, limit: 1){ path, updatedAt, title }}}"}`
|
||||
var entries []Entry
|
||||
query := fmt.Sprintf(`{"query":"{ pages { list(orderBy: UPDATED, orderByDirection: DESC, limit: %d){ path, updatedAt, title }}}"}`, f.ContentLimit)
|
||||
|
||||
req := FetcherRequest{
|
||||
BaseURL: f.BaseURL,
|
||||
@@ -39,25 +40,27 @@ func (f *WikiFetcher) Fetch() []Entry {
|
||||
Body: []byte(query),
|
||||
}
|
||||
|
||||
var resp WikiResponse
|
||||
if err := req.Run(&resp); err != nil {
|
||||
var response WikiResponse
|
||||
if err := req.Run(&response); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(resp.Data.Pages.List) == 0 {
|
||||
if len(response.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),
|
||||
)
|
||||
for _, content := range response.Data.Pages.List {
|
||||
entry := f.TryCreateEntry(
|
||||
"wiki_"+content.Path,
|
||||
content.UpdatedAt,
|
||||
fmt.Sprintf("📖 [%s] - %s", f.Name(), content.Title),
|
||||
fmt.Sprintf("%s/%s", f.BaseURL, content.Path),
|
||||
)
|
||||
|
||||
if entry != nil {
|
||||
return []Entry{*entry}
|
||||
if entry != nil {
|
||||
entries = append(entries, *entry)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user