Skip to content

Commit 050df95

Browse files
Merge pull request #6 from subhendupsingh/dev
minor bug fixes, style improvements
2 parents 7c30266 + 4ecd4bd commit 050df95

File tree

7 files changed

+29
-14
lines changed

7 files changed

+29
-14
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltekit-notion-blog",
3-
"version": "0.1.4",
3+
"version": "0.1.6",
44
"scripts": {
55
"dev": "vite dev",
66
"build": "vite build && npm run package",
@@ -10,7 +10,10 @@
1010
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1111
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1212
"lint": "prettier --plugin-search-dir . --check . && eslint .",
13-
"format": "prettier --plugin-search-dir . --write ."
13+
"format": "prettier --plugin-search-dir . --write .",
14+
"patch": "npm version patch",
15+
"minor": "npm version minor",
16+
"publish": "npm publish"
1417
},
1518
"exports": {
1619
".": {

src/lib/components/Block.svelte

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import BulletList from "./BulletList.svelte";
88
import Embed from "./Embed.svelte";
99
export let block: BlockObjectResponse;
10-
//$: console.log(block.type, block);
11-
10+
//$: console.log("type",block.type);
1211
</script>
1312

1413

src/lib/components/BlogPost.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
if(block.type==="heading_1"){
1414
return {
1515
type: block.type,
16-
text: block.heading_1?.rich_text?.[0]?.plain_text,
16+
text: block.heading_1?.rich_text?.map((t)=> t.plain_text)?.join(" "),
1717
id: block.id
1818
}
1919
}else if(block.type==="heading_2"){
2020
return {
2121
type: block.type,
22-
text: block.heading_2?.rich_text?.[0]?.plain_text,
22+
text: block.heading_2?.rich_text?.map((t)=> t.plain_text)?.join(" "),
2323
id: block.id
2424
}
2525
}else if(block.type==="heading_3"){
2626
return {
2727
type: block.type,
28-
text: block.heading_3?.rich_text?.[0]?.plain_text,
28+
text: block.heading_3?.rich_text?.map((t)=> t.plain_text)?.join(" "),
2929
id: block.id
3030
}
3131
}else{

src/lib/components/Heading.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
{#if heading}
88
{#if heading.type=="heading_1"}
9-
<h1 id={heading.id}>{heading.heading_1.rich_text?.[0]?.plain_text}</h1>
9+
<h1 id={heading.id}>{heading.heading_1.rich_text?.map((t)=> t.plain_text)?.join(" ")}</h1>
1010
{:else if heading.type=="heading_2"}
11-
<h2 id={heading.id}>{heading.heading_2.rich_text?.[0]?.plain_text}</h2>
11+
<h2 id={heading.id}>{heading.heading_2.rich_text?.map((t)=> t.plain_text)?.join(" ")}</h2>
1212
{:else if heading.type=="heading_3"}
13-
<h3 id={heading.id} class="">{heading.heading_3.rich_text?.[0]?.plain_text}</h3>
13+
<h3 id={heading.id} class="">{heading.heading_3.rich_text?.map((t)=> t.plain_text)?.join(" ")}</h3>
1414
{/if}
1515
{/if}

src/lib/components/TableOfContent.svelte

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
export let tableOfContent: (TableOfContentItems | undefined)[] | undefined;
44
</script>
55

6+
<h3>Table of Contents</h3>
7+
68
{#if tableOfContent && tableOfContent?.length > 0}
7-
<ul class="not-prose bg-slate-100 rounded-md w-full py-6 list-none">
9+
<ul>
810
{#each tableOfContent as content }
911
{#if content}
1012
{#if content.type == "heading_2"}
@@ -21,4 +23,14 @@
2123
a {
2224
@apply text-slate-700;
2325
}
26+
27+
ul {
28+
background-color: rgb(248 250 252 / 1);
29+
list-style-type: none;
30+
padding: 4px;
31+
border-radius: 0.375rem;
32+
padding-top: 1.5rem;
33+
padding-bottom: 1.5rem;
34+
padding-left: 1.5rem;
35+
}
2436
</style>

src/lib/notion/api.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const getBlocks = async (blogClient: BlogClient, blockId: string): Promi
9696
if(!isFullBlock(block)) continue;
9797
blocks.push(block);
9898
}
99+
99100
return ok(blocks);
100101
}else if(results && results.length == 0){
101102
return ok([]);
@@ -153,7 +154,7 @@ export const getFAQs = async (blogClent: BlogClient, id: string): Promise<Result
153154
if(row.type=="table_row"){
154155
return {
155156
question: row.table_row.cells?.[0]?.[0]?.plain_text,
156-
answer: row.table_row.cells?.[1]?.[0]?.plain_text
157+
answer: row.table_row.cells?.[1]?.map((r)=> r.plain_text)?.join("")
157158
}
158159
}else{
159160
return {

0 commit comments

Comments
 (0)