Skip to content

Astro 5.0 & Custom Content Loader #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
256aa27
chore(deps): update dependencies for notro-tail (loader)
mosugi Dec 23, 2024
64c96a1
fix: update TypeScript configuration and dependencies for loader (123)
mosugi Dec 23, 2024
826fb23
```
mosugi Dec 23, 2024
d1f40a5
fix(loader): handle nested structure in numbered lists (loader)
mosugi Dec 24, 2024
039fab6
feat(loader): refactor loader and add dynamic slug pages (loader)
mosugi Jan 6, 2025
2338b65
fix(loader): update loader to use Array.fromAsync for pagination (loa…
mosugi Jan 6, 2025
e473c3b
feat(loader): refactor Notion block handling and optimize image rende…
mosugi Jan 7, 2025
07a2611
feat: refactor NotionBlocks to NotionCustomBlocks and improve renderi…
mosugi Jan 7, 2025
9f993e1
feat: add link to page functionality and update RichText component (l…
mosugi Jan 18, 2025
6583d98
refactor: update NotionCustomBlocks props to make url and title optional
mosugi Jan 18, 2025
aa5c5e7
fix: update astro dependency to version 5.1.7
mosugi Jan 18, 2025
8a53c48
fix: remove old notrotail components
mosugi Jan 27, 2025
a10b2c7
fix: remove old notrotail components
mosugi Jan 27, 2025
ceee70f
feat: update README and add footer/header components support (loader)
mosugi Jan 27, 2025
303242e
feat: add options for optimizing remote images in Block component
mosugi Jan 31, 2025
ed8d9aa
feat: enhance CalloutOrContainer component to support custom containe…
mosugi Jan 31, 2025
1354a19
feat: refactor imports in NotionCustomBlocks and related components f…
mosugi Jan 31, 2025
1fddc96
refactor: remove Tailwind integration and related dependencies
mosugi Feb 8, 2025
f727a22
feat: integrate Tailwind CSS and update configuration for global styles
mosugi Feb 8, 2025
4bfd375
feat: add custom utility styles for NotroTail components in global CSS
mosugi Feb 8, 2025
a87cfec
fix: correct import path for global CSS in Layout component
mosugi Feb 8, 2025
0c5df38
feat: add Zod schemas for block and page objects in loader
mosugi Feb 8, 2025
5dae9c4
fix: update slug retrieval logic and improve schema integration in co…
mosugi Feb 8, 2025
cb3e066
fix: update slug retrieval logic and add filter for public entries in…
mosugi Feb 8, 2025
16ec9d8
fix: update slug retrieval logic and improve page store management in…
mosugi Feb 8, 2025
a1226fd
feat: add blog page routing and optimized database cover component
mosugi Feb 9, 2025
58d81a6
feat: add DatabaseProperty component and enhance blog post display wi…
mosugi Feb 9, 2025
4659055
refactor: rename getPagePropertyText to getPlainText and update usage…
mosugi Feb 17, 2025
20f284c
refactor: rename getPagePropertyText to getPlainText and update usage…
mosugi Feb 17, 2025
f393eb3
feat: update package.json with project metadata and add release workflow
mosugi Feb 26, 2025
f694e62
feat: update package.json to include additional files and enhance REA…
mosugi Feb 26, 2025
e7ae057
chore: update astro version in package.json and remove unused scripts
mosugi Feb 26, 2025
2ebec5f
feat: enhance README with usage instructions and add NotionBlocks exa…
mosugi Feb 26, 2025
1beaa92
chore: update tailwindcss and vite versions in package.json and packa…
mosugi Mar 8, 2025
cc73807
refactor: update loader and schema types for improved type safety and…
mosugi Mar 8, 2025
1bb9f7d
refactor: update block types and class names for consistency and impr…
mosugi Mar 8, 2025
75603ae
refactor: update type imports and improve type safety across components
mosugi Mar 8, 2025
94702f4
refactor: improve type safety by updating type imports and usage in c…
mosugi Mar 28, 2025
1d1574c
refactor: improve type imports for consistency and clarity across com…
mosugi Mar 28, 2025
3907ecb
refactor: improve type imports and formatting for consistency and cla…
mosugi Mar 28, 2025
6d6be38
refactor: add custom callout CSS classes and source data for improved…
mosugi Mar 28, 2025
ba63dec
refactor: implement static paths for blog posts and update BlogList p…
mosugi Mar 28, 2025
dba687b
refactor: add optional id prop to various components for improved fle…
mosugi Mar 28, 2025
f5616bb
refactor: update data source paths in global.css for improved accessi…
mosugi Apr 26, 2025
5d444cd
feat: add notion image service configuration and integrate with astro…
mosugi May 2, 2025
d760946
refactor: remove debug log level from Notion client options and enhan…
mosugi May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: add optional id prop to various components for improved fle…
…xibility
  • Loading branch information
mosugi committed Mar 28, 2025
commit dba687be99cd836442f02e5d236ccc983e41589d
2 changes: 2 additions & 0 deletions apps/notro-tail/src/components/NotionCustomBlocks.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface RenderOptions {
optimizeRemoteImage: boolean;
useRawHTML: boolean;
useCalloutContainer: boolean;
useNotionId: boolean;
}

const {
Expand All @@ -28,6 +29,7 @@ const {
optimizeRemoteImage: true,
useRawHTML: false,
useCalloutContainer: false,
useNotionId: false,
},
} = Astro.props;

Expand Down
1 change: 1 addition & 0 deletions apps/notro-tail/src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const options = {
optimizeRemoteImage: true,
useRawHTML: true,
useCalloutContainer: true,
useNotionId: false,
};
---

Expand Down
5 changes: 3 additions & 2 deletions apps/notro-tail/src/pages/blog/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ const options = {
optimizeRemoteImage: true,
useRawHTML: true,
useCalloutContainer: true,
useNotionId: false,
};
---

<Layout title={entry.id}>
<main class="nt-page" id={entry.id}>
<Layout title={entry.data.properties.Name.title[0]?.plain_text}>
<main class="nt-page" id={options.useNotionId ? entry.id : undefined}>
<NotionCustomBlocks
blocks={entry.data.blocks as BlockObjectResponseWithChildrenType[]}
options={options}
Expand Down
9 changes: 3 additions & 6 deletions packages/notro/src/components/Bookmark.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import type { BookmarkBlockObjectResponseType } from "../loader/schema.ts";
import RichText from "./RichText.astro";
interface Props {
block: BookmarkBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<a
id={block.id}
class=`nt-selectable nt-bookmark-block`
href={block.bookmark.url}
>
<a {id} class=`nt-selectable nt-bookmark-block` href={block.bookmark.url}>
{
block.bookmark.caption.length > 0 ? (
<RichText richText={block.bookmark.caption} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/BulletedListItem.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import RichText from "./RichText.astro";

interface Props {
block: BulletedListItemBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<li
id={block.id}
{id}
class=`nt-selectable nt-bulleted_list-block nt-color-${block.bulleted_list_item.color}`
>
<RichText richText={block.bulleted_list_item.rich_text} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/Callout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import RichText from "./RichText.astro";

interface Props {
block: CalloutBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<div
id={block.id}
{id}
class={`notion-selectable notion-callout-block notion-color-${block.callout.color}`}
>
<RichText richText={block.callout.rich_text} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/Code.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import type { CodeBlockObjectResponseType } from "../loader/schema.ts";
interface Props {
block: CodeBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<code id={block.id} class="nt-selectable nt-code-block">
<code {id} class="nt-selectable nt-code-block">
{block.code.rich_text[0].plain_text}
</code>
5 changes: 3 additions & 2 deletions packages/notro/src/components/Column.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import type { ColumnBlockObjectResponseType } from "../loader/schema.ts";
interface Props {
block: ColumnBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { id } = Astro.props;
---

<div id={block.id} class=`nt-selectable nt-column-block`>
<div {id} class=`nt-selectable nt-column-block`>
<slot />
</div>
5 changes: 3 additions & 2 deletions packages/notro/src/components/ColumnList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import type { ColumnListBlockObjectResponseType } from "../loader/schema.ts";
interface Props {
block: ColumnListBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { id } = Astro.props;
---

<div id={block.id} class=`nt-selectable nt-column_list-block`>
<div {id} class=`nt-selectable nt-column_list-block`>
<slot />
</div>
5 changes: 3 additions & 2 deletions packages/notro/src/components/Divider.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import type { DividerBlockObjectResponseType } from "../loader/schema.ts";
interface Props {
block: DividerBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { id } = Astro.props;
---

<hr id={block.id} class=`nt-selectable nt-divider-block` />
<hr {id} class=`nt-selectable nt-divider-block` />
5 changes: 3 additions & 2 deletions packages/notro/src/components/Heading1.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import type { Heading1BlockObjectResponseType } from "../loader/schema.ts";

interface Props {
block: Heading1BlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<h2
id={block.id}
id={id}
class=`nt-selectable nt-header-block ${getNotionColor(block.heading_1.color)}`
>
<RichText richText={block.heading_1.rich_text} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/Heading2.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import type { Heading2BlockObjectResponseType } from "../loader/schema.ts";

interface Props {
block: Heading2BlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<h3
id={block.id}
id={id}
class=`nt-selectable nt-sub_header-block ${getNotionColor(block.heading_2.color)}`
>
<RichText richText={block.heading_2.rich_text} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/Heading3.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import type { Heading3BlockObjectResponseType } from "../loader/schema.ts";

interface Props {
block: Heading3BlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
---

<h4
id={block.id}
{id}
class=`nt-selectable nt-sub_sub_header-block ${getNotionColor(block.heading_3.color)}`
>
<RichText richText={block.heading_3.rich_text} />
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/Image.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
import type { ImageBlockObjectResponseType } from "../loader/schema.ts";
interface Props {
block: ImageBlockObjectResponseType;
id?: string;
}

const { block } = Astro.props;
const { block, id } = Astro.props;
const imageUrl =
block.image.type === "file" ? block.image.file.url : block.image.external.url;
---

<img
id={block.id}
{id}
class="nt-selectable nt-image-block"
src={imageUrl}
alt={block.image.caption[0]?.plain_text ?? ""}
Expand Down
5 changes: 3 additions & 2 deletions packages/notro/src/components/LinkToPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ interface Props {
block: LinkToPageBlockObjectResponseType;
href?: string;
text?: string;
id?: string;
}

const { block, href, text } = Astro.props;
const { block, href, text, id } = Astro.props;
---

<a id={block.id} class=`nt-selectable nt-alias-block` href={href ?? block.id}>
<a {id} class=`nt-selectable nt-alias-block` href={href ?? block.id}>
{text ?? block.id}
</a>
46 changes: 25 additions & 21 deletions packages/notro/src/components/NotionBlockRenderer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ interface Props {

interface RenderOptions {
optimizeRemoteImage: boolean;
useNotionId: boolean;
}

const {
block,
options = {
optimizeRemoteImage: true,
useNotionId: false,
},
} = Astro.props;

const blockId = options.useNotionId ? block.id : undefined;

const unSupportedBlockTypes: BlockObjectResponseType["type"][] = [
"synced_block",
"child_database",
Expand All @@ -58,7 +62,7 @@ const unSupportedBlockTypes: BlockObjectResponseType["type"][] = [

{
block.type === "paragraph" && (
<Paragraph block={block}>
<Paragraph block={block} id={blockId}>
<slot />
</Paragraph>
)
Expand All @@ -67,11 +71,11 @@ const unSupportedBlockTypes: BlockObjectResponseType["type"][] = [
block.type === "heading_1" &&
(block.heading_1.is_toggleable ? (
<ToggleContainer>
<Heading1 block={block} slot="summary" />
<Heading1 block={block} id={blockId} slot="summary" />
<slot />
</ToggleContainer>
) : (
<Heading1 block={block}>
<Heading1 block={block} id={blockId}>
<slot />
</Heading1>
))
Expand All @@ -80,11 +84,11 @@ const unSupportedBlockTypes: BlockObjectResponseType["type"][] = [
block.type === "heading_2" &&
(block.heading_2.is_toggleable ? (
<ToggleContainer>
<Heading2 block={block} slot="summary" />
<Heading2 block={block} id={blockId} slot="summary" />
<slot />
</ToggleContainer>
) : (
<Heading2 block={block}>
<Heading2 block={block} id={blockId}>
<slot />
</Heading2>
))
Expand All @@ -93,80 +97,80 @@ const unSupportedBlockTypes: BlockObjectResponseType["type"][] = [
block.type === "heading_3" &&
(block.heading_3.is_toggleable ? (
<ToggleContainer>
<Heading3 block={block} slot="summary" />
<Heading3 block={block} id={blockId} slot="summary" />
<slot />
</ToggleContainer>
) : (
<Heading3 block={block}>
<Heading3 block={block} id={blockId}>
<slot />
</Heading3>
))
}
{
block.type === "column_list" && (
<ColumnList block={block}>
<ColumnList block={block} id={blockId}>
<slot />
</ColumnList>
)
}
{
block.type === "column" && (
<Column block={block}>
<Column block={block} id={blockId}>
<slot />
</Column>
)
}
{
block.type === "toggle" && (
<ToggleContainer block={block}>
<ToggleContainer block={block} id={blockId}>
<slot />
</ToggleContainer>
)
}
{block.type === "bookmark" && <Bookmark block={block} />}
{block.type === "divider" && <Divider block={block} />}
{block.type === "bookmark" && <Bookmark block={block} id={blockId} />}
{block.type === "divider" && <Divider block={block} id={blockId} />}
{
block.type === "quote" && (
<Quote block={block}>
<Quote block={block} id={blockId}>
<slot />
</Quote>
)
}
{
block.type === "image" && options.optimizeRemoteImage ? (
<OptimizedImage block={block} />
<OptimizedImage block={block} id={blockId} />
) : (
block.type === "image" && <Image block={block} />
block.type === "image" && <Image block={block} id={blockId} />
)
}
{block.type === "code" && <Code block={block} />}
{block.type === "code" && <Code block={block} id={blockId} />}
{
block.type === "bulleted_list_item" && (
<BulletedListItem block={block}>
<BulletedListItem block={block} id={blockId}>
<slot />
</BulletedListItem>
)
}
{
block.type === "numbered_list_item" && (
<NumberedListItem block={block}>
<NumberedListItem block={block} id={blockId}>
<slot />
</NumberedListItem>
)
}
{
block.type === "to_do" && (
<TodoListItem block={block}>
<TodoListItem block={block} id={blockId}>
<slot />
</TodoListItem>
)
}
{
block.type === "callout" && (
<Callout block={block}>
<Callout block={block} id={blockId}>
<slot />
</Callout>
)
}
{block.type === "link_to_page" && <LinkToPage block={block} />}
{block.type === "link_to_page" && <LinkToPage block={block} id={blockId} />}
{unSupportedBlockTypes.includes(block.type) && <Debug {block} />}
Loading