Skip to content

Commit

Permalink
Add documentation for featured content
Browse files Browse the repository at this point in the history
resolving #34
  • Loading branch information
friendofdog committed Jan 8, 2022
1 parent 585d4f0 commit 060b9cb
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/optionTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [searchOptions](#searchOptions)
- [geoOptions](#geoOptions)
- [eventOptions](#eventOptions)
- [fcOptions](#fcOptions)
- [pdfOptions](#pdfOptions)

### pageOptions
Expand Down Expand Up @@ -79,6 +80,20 @@ The options for the onThisDay function on wiki object.
- `month : string`(default = date.getMonth()) - Use this to pass the month you want as a string. By default, it will take current month.
- `day : string`(default = date.getDay()) - Use this to pass the day you want as a string. By default, it will take current day.

### fcOptions
```js
interface fcOptions {
year?: string,
month?: string,
day?: string
}
```
The options for the featured content function on wiki object.

- `year : string`(default = date.getYear()) - Use this to pass the year you want as a string. By default, it will take current year.
- `month : string`(default = date.getMonth()) - Use this to pass the month you want as a string. By default, it will take current month.
- `day : string`(default = date.getDay()) - Use this to pass the day you want as a string. By default, it will take current day.

### pdfOptions
```js
interface pdfOptions {
Expand Down
54 changes: 54 additions & 0 deletions docs/resultTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [languageResult](#languageResult)
- [wikiMediaResult](#wikiMediaResult)
- [eventResult](#eventResult)
- [fcResult](#fcResult)
- [relatedResult](#relatedResult)
- [titleItem](#titleItem)
- [mobileSections](#mobileSections)
Expand Down Expand Up @@ -211,6 +212,59 @@ interface eventResult {
}
```

### fcResult

The result for the `featuredContent` function call.
```js
interface fcResult {
tfa: wikiSummary;
mostread: {
date: string;
articles: Array<wikiSummary>
};
image: {
title: string;
thumbnail: {
source: string;
width: number;
height: number;
};
image: {
source: string;
width: number;
height: number;
};
file_page: string;
artist: Artist;
credit: htmlText;
license: {
type: string;
code: string;
};
description: Description;
wb_entity_id: string;
structured: {
captions: {
[key: string]: string;
}
};
};
news: [
{
links: Array<wikiSummary>;
story: string;
}
];
onthisday: [
{
text: string;
pages: Array<wikiSummary>;
year: number;
}
]
}
```

### relatedResult

The related result.
Expand Down
24 changes: 24 additions & 0 deletions docs/wiki.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [page()](#page)
- [geoSearch()](#geoSearch)
- [onThisDay()](#onThisDay)
- [featuredContent()](#featuredContent)
- [languages()](#languages)
- [setLang()](#setLang)
- [suggest()](#suggest)
Expand Down Expand Up @@ -70,6 +71,28 @@ console.log(events); // returns all the events which happened today
console.log(deaths); // returns all deaths which happened on Feb 28
```

### featuredContent()

Returns featured content of a given day, depending on input `year`, `month`, `day` arguments. By default, it will return featured content of the current day. Returns a array of [fcResult][27] object.

```js
featuredContent = async ({year: string, month: string, day: string}): Promise<fcResult>
```
- @param year - The year to search for. Takes current year by default.
- @param month - The month to search for. Takes current month by default.
- @param day - The day to search for. Takes current day by default.
- @result [fcResult][27] - a fcResult object.

```js
//example
const content = await wiki.featuredContent();
const contentNewYear2020 = await wiki.featuredContent({year:'2020', month:'01', day:'01'});
const contentNewYear = await wiki.featuredContent({month:'01', day:'01'});
console.log(content); // returns featured content from today
console.log(contentNewYear2020); // returns featured content from 2020-01-01
console.log(contentNewYear); // returns featured content from 01-01 of this year
```

### geoSearch()

Searches for a page based on input `latitude`, `longitude` coordinates. Optionally takes a `limit` and `radius`(the search radius in meters) parameter in the [geoOptions][5] object. Returns an array of [geoSearchResult][6] object.
Expand Down Expand Up @@ -210,5 +233,6 @@ console.log(html); //Returns html for the environmentalist
[24]: https://github.com/dopecodez/wikipedia/blob/master/docs/resultTypes.md#eventResult
[25]: https://github.com/dopecodez/wikipedia/blob/master/docs/PAGE.md#mobileHtml
[26]: https://github.com/dopecodez/wikipedia/blob/master/docs/PAGE.md#pdf
[27]: https://github.com/dopecodez/wikipedia/blob/master/docs/resultTypes.md#fcResult


0 comments on commit 060b9cb

Please sign in to comment.