Skip to content

Commit 9294c7f

Browse files
committed
Updated build to generate stats and all consistently for all categories
1 parent d428b3c commit 9294c7f

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# tech-quotes
22

3+
[![main](https://github.com/FullStackBulletin/tech-quotes/actions/workflows/test.yaml/badge.svg)](https://github.com/FullStackBulletin/tech-quotes/actions/workflows/test.yaml)
4+
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5+
![ts](https://badgen.net/badge/Built%20With/TypeScript/blue)
6+
7+
38
An API to get interesting tech-related quotes (powered by GitHub pages)
49

10+
## Usage
11+
12+
The base URL of the API is `https://fullStackbulletin.github.io/tech-quotes`.
13+
14+
There are some endpoints available:
15+
16+
### `/quotes/stats.json`
17+
18+
Returns statistics about all the available quotes.
19+
20+
#### Example
21+
22+
```bash
23+
curl https://fullStackbulletin.github.io/tech-quotes/quotes/stats.json | jq .
24+
```
25+
26+
27+
528
WIP

scripts/build.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ const stats = {
3636
all: `${baseUrl}/quotes/all.json`,
3737
first: `${baseUrl}/quotes/0.json`,
3838
last: `${baseUrl}/quotes/${quotes.length - 1}.json`,
39-
urlPrefix: baseUrl
39+
urlPrefix: `${baseUrl}/quotes`
4040
}
4141

42-
await writeFile(`${destPath}/stats.json`, JSON.stringify(stats, null, 2))
43-
console.log(`Written ${destPath}/stats.json`)
42+
await writeFile(`${quotesPath}/stats.json`, JSON.stringify(stats, null, 2))
43+
console.log(`Written ${quotesPath}/stats.json`)
4444

4545
// Creates a JSON file for each quote and an all.json file with all the quotes
4646
function mapQuote (id: string, quote: RawQuote): Quote {
@@ -106,6 +106,16 @@ for (const author of authorsWithQuotes.values()) {
106106
totalAuthors++
107107
}
108108

109+
// creates stats.json for authors
110+
const authorsStats = {
111+
total: totalAuthors,
112+
all: `${baseUrl}/authors/all.json`,
113+
urlPrefix: `${baseUrl}/authors`
114+
}
115+
116+
await writeFile(`${authorsPath}/stats.json`, JSON.stringify(authorsStats, null, 2))
117+
console.log(`Written ${authorsPath}/stats.json`)
118+
109119
// Create all.json for authors
110120
const allAuthors = {
111121
metadata: {

0 commit comments

Comments
 (0)