Skip to content

Commit ebb34ac

Browse files
Merge pull request #3 from subhendupsingh/dev
Removed hardcoded text in PostLists
2 parents 6d68476 + e48263c commit ebb34ac

File tree

6 files changed

+32
-25
lines changed

6 files changed

+32
-25
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltekit-notion-blog",
3-
"version": "0.1.1",
3+
"version": "0.1.3",
44
"scripts": {
55
"dev": "vite dev",
66
"build": "vite build && npm run package",

src/lib/components/PostsList.svelte

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
{#if data.pages}
99
<div class="min-h-screen bg-white py-8 flex flex-col gap-20 relative overflow-hidden lg:py-8">
1010
<div class="relative w-full px-6 py-12 md:max-w-3xl md:mx-auto lg:max-w-4xl lg:pt-12 lg:pb-28">
11-
<div class="flex flex-col gap-12 mb-8">
12-
<h1 class="font-bold text-4xl">Welcome to StoreBud blog - Platform for growing D2C brands!</h1>
11+
<div class="flex flex-col gap-6 mb-8">
12+
<h1 class="font-bold text-4xl">{ data.settings.blogTitle }</h1>
1313

1414
<p class="text-lg">
15-
StoreBud blogs cover variuos topics related to setting up your own ecommerce website in India and
16-
other parts of the world, including tips and tricks, best practices and success stroies of the
17-
growing D2C brands.
15+
{ data.settings.blogDescription }
1816
</p>
1917
</div>
2018

src/lib/index.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import BlogPost from "$lib/components/BlogPost.svelte";
55
import PostsList from "$lib/components/PostsList.svelte";
66

77
type Tokens = { notionToken: string, databaseId: string, vercelByPassToken?: string };
8-
export type BlogClient = {client: Client, config: Tokens};
8+
type BlogSettings = { blogTitle: string, blogDescription: string };
9+
type InitConfig = { tokens: Tokens, settings: BlogSettings };
10+
export type BlogClient = { client: Client, config: Tokens, settings: BlogSettings };
911

1012
let notionCLient: BlogClient;
1113

12-
export const initNotion = ( config: Tokens ): BlogClient | null => {
13-
if(config?.notionToken && config?.notionToken){
14-
const client = new Client({
15-
auth: config.notionToken,
16-
});
17-
notionCLient = { client, config};
18-
return notionCLient;
19-
}else{
20-
return null;
21-
}
14+
export const initNotionBlog = ( config: InitConfig ): BlogClient | null => {
15+
if(config?.tokens?.notionToken && config?.tokens?.notionToken){
16+
const client = new Client({
17+
auth: config.tokens.notionToken,
18+
});
19+
notionCLient = { client, config: config.tokens, settings: config.settings };
20+
return notionCLient;
21+
}else{
22+
return null;
23+
}
2224
}
2325

2426
export const getAllPosts = async () => {
@@ -38,7 +40,8 @@ export const getAllPosts = async () => {
3840
if(res.isOk()){
3941
if(res.value?.length > 0){
4042
return {
41-
pages: res.value
43+
pages: res.value,
44+
settings: notionCLient.settings
4245
}
4346
}else{
4447
return {

src/lib/notion/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BlogClient } from "$lib";
22
import type { FAQ } from "$lib/types";
3-
import { Client, APIErrorCode, isNotionClientError, ClientErrorCode, isFullPage, isFullBlock } from "@notionhq/client";
3+
import { APIErrorCode, isNotionClientError, ClientErrorCode, isFullPage, isFullBlock } from "@notionhq/client";
44
import type { BlockObjectResponse, PageObjectResponse, UserObjectResponse } from "@notionhq/client/build/src/api-endpoints";
55
import { ok, err, Result } from 'neverthrow';
66

src/routes/+layout.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { PUBLIC_NOTION_TOKEN, PUBLIC_NOTION_DATABASE_ID } from "$env/static/public";
2-
import { initNotion } from "$lib";
2+
import { initNotionBlog } from "$lib";
33

44
export const prerender = true;
55

6-
initNotion({
7-
databaseId: PUBLIC_NOTION_DATABASE_ID,
8-
notionToken: PUBLIC_NOTION_TOKEN,
6+
initNotionBlog({
7+
tokens: {
8+
databaseId: PUBLIC_NOTION_DATABASE_ID,
9+
notionToken: PUBLIC_NOTION_TOKEN,
10+
},
11+
settings: {
12+
blogTitle: "Notion Blog",
13+
blogDescription: "A blog powered by Notion"
14+
}
915
});

0 commit comments

Comments
 (0)