Skip to content

Commit 7f1b39a

Browse files
authored
Add task file (#24)
* Add task file and move the helper to a utils directory * Clean up
1 parent 4cd340c commit 7f1b39a

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

Taskfile.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# https://taskfile.dev
2+
3+
version: '3'
4+
5+
tasks:
6+
build:posts:
7+
silent: true
8+
dir: data
9+
cmds:
10+
- npm run build:posts
11+
12+
build:rss:
13+
silent: true
14+
dir: data
15+
cmds:
16+
- npm run build:rss
17+
18+
build:frontend:
19+
silent: true
20+
dir: frontend
21+
cmds:
22+
- npm run build
23+
24+
run:frontend:
25+
silent: true
26+
dir: frontend
27+
cmds:
28+
- npm run dev
29+

frontend/src/lib/config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// import { config } from '$lib/config.json';
21
import {
32
PUBLIC_DATASOURCE_TYPE,
43
PUBLIC_DATASOURCE,
5-
PUBLIC_LOGGING_ENABLED
64
} from '$env/static/public';
75

6+
import { log } from '$lib/utils/logger.js';
7+
88

99
let POSTS_CACHE = null;
1010

@@ -18,7 +18,7 @@ export const getPosts = (fetch) => {
1818
};
1919

2020
if (PUBLIC_DATASOURCE_TYPE == 'local') {
21-
return import('../posts.json').then(posts => {
21+
return import('../../posts.json').then(posts => {
2222
POSTS_CACHE = posts.default
2323
}).then(() => POSTS_CACHE);
2424
}
@@ -30,10 +30,3 @@ export const getPosts = (fetch) => {
3030
})
3131
.then(() => POSTS_CACHE);
3232
};
33-
34-
35-
export const log = (obj, message) => {
36-
if (PUBLIC_LOGGING_ENABLED == 'true') {
37-
console.log(`${obj} => ${message}`)
38-
}
39-
};

frontend/src/lib/utils/logger.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PUBLIC_LOGGING_ENABLED } from '$env/static/public';
2+
3+
4+
export const log = (obj, message) => {
5+
if (PUBLIC_LOGGING_ENABLED == 'true') {
6+
console.log(`${obj} => ${message}`)
7+
}
8+
};

frontend/src/routes/posts/+page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPosts } from '$lib/helpers.js';
1+
import { getPosts } from '$lib/utils/loader.js';
22

33

44
export const load = ({fetch}) => {

frontend/src/routes/posts/[post]/+page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPosts } from '$lib/helpers.js';
1+
import { getPosts } from '$lib/utils/loader.js';
22

33

44
export const load = ({fetch, params}) => {

0 commit comments

Comments
 (0)