Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanPreusse committed Jan 5, 2024
1 parent b4913cb commit 703c9fe
Show file tree
Hide file tree
Showing 28 changed files with 155 additions and 217 deletions.
4 changes: 2 additions & 2 deletions app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { NotionRenderer } from 'react-notion';
import notion from '@/lib';
import { convertToPost } from '@/functions/convertToPost';
import TopScrollButton from '@/components/TopScrollButton';
import { aboutPageId } from "@/site";
import { siteData } from "@/site";

export default async function AboutPage({
searchParams,
}: {
searchParams: { [key: string]: string };
}) {
const pageid = aboutPageId
const pageid = siteData.aboutPageId

// Fetching blockMap
const response = await fetch(`https://notion-api.splitbee.io/v1/page/${pageid}`, {
Expand Down
15 changes: 13 additions & 2 deletions app/articles/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import TopScrollButton from "../../../components/TopScrollButton";
import Container from '@/components/Container';
import ArticleList from '@/components/ArticleList';
import { getAllPosts } from "@/functions/getAllPosts";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import getLocalizedDate from '@/app/utils/getLocalizedDate';
import { getTagFilteredPosts } from "@/functions/articleFilteredPosts";
import SocialshareButtons from "@/components/SocialshareButtons";



export default async function Page({
searchParams,
Expand All @@ -36,7 +39,7 @@ export default async function Page({

return (
<div className="space-y-5 max-w-7xl m-auto min-h-screen">
<img className="object-cover w-full h-52 rounded-[20px] aspect-video" src={postDetails.coverImage} />
<img className="object-cover w-full h-52 lg:rounded-[20px] aspect-video" src={postDetails.coverImage} />

<div>
<div className="text-center space-y-5 text-sm mx-auto mt-3">
Expand All @@ -50,9 +53,17 @@ export default async function Page({
<div className="font-semibold">
{postDetails.author}
</div>
<SocialshareButtons
shareUrl={`http://localhost:3000/${postDetails.slug}?id=${postDetails.id}`}
title={postDetails.title}
/>
</div>



</div>


<div className="max-w-4xl px-6 mx-auto mb-24 space-y-8 md:px-8 pt-4 border-t mt-4">
<NotionRenderer blockMap={blockMap} />

Expand Down
2 changes: 1 addition & 1 deletion app/articles/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAllPosts } from "@/functions/getAllPosts";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import Search from "../../components/Search";
import { calculateTagFrequency } from "@/functions/getAllTags";

Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAllPosts } from "@/functions/getAllPosts";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import { postsPerPage } from "@/site";
import Feed from "@/components/Feed";
import HeroSection from "../components/HeroSection";
Expand Down
2 changes: 1 addition & 1 deletion app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAllPosts } from "@/functions/getAllPosts";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import Search from "../../components/Search";
import { calculateTagFrequency } from "@/functions/getAllTags";

Expand Down
2 changes: 1 addition & 1 deletion app/tag/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Search from "@/components/Search";
import { getAllPosts } from "@/functions/getAllPosts";
import { calculateTagFrequency } from "@/functions/getAllTags";
import { getTagFilteredPosts } from "@/functions/tagFilteredPosts";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";

export default async function Page({ params }: { params: { slug: string } }) {
const { slug } = params;
Expand Down
2 changes: 1 addition & 1 deletion app/utils/filterArticles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";

export function filterArticles(articles: Article[], selectedTag: string | null): Article[] {
return articles
Expand Down
2 changes: 1 addition & 1 deletion components/ArticleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from '@/layouts/types';
import { Article } from '@/lib/types';
import slugify from 'slugify';
import getLocalizedDate from '../app/utils/getLocalizedDate';

Expand Down
2 changes: 1 addition & 1 deletion components/ArticleList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from '@/layouts/types';
import { Article } from '@/lib/types';
import ArticleCard from './ArticleCard';

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion components/Feed.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from '../layouts/types';
import { Article } from '../lib/types';
import ArticleCard from './ArticleCard';

type Props = {
Expand Down
25 changes: 0 additions & 25 deletions components/HeroHeader.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "@/components/button";
import { PaginationProps } from "@/layouts/types";
import { PaginationProps } from "@/lib/types";
import Link from "next/link";

const Pagination: React.FC<PaginationProps> = ({ currentPage, totalPages }) => {
Expand Down
2 changes: 1 addition & 1 deletion components/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Input } from "@/components/input";
import { Article, TagFrequencyMap } from "@/layouts/types";
import { Article, TagFrequencyMap } from "@/lib/types";
import { useState } from "react";
import Tags from "./Tags";
import { useParams } from "next/navigation";
Expand Down
8 changes: 4 additions & 4 deletions components/SocialshareButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ const SocialshareButtons = ({
return (
<div className="space-x-3">
<FacebookShareButton url={shareUrl}>
<FacebookIcon size={32} round />
<FacebookIcon size={25} round />
</FacebookShareButton>

<TwitterShareButton url={shareUrl} title={title}>
<XIcon size={32} round />
<XIcon size={25} round />
</TwitterShareButton>

<TelegramShareButton url={shareUrl} title={title}>
<TelegramIcon size={32} round />
<TelegramIcon size={25} round />
</TelegramShareButton>

<WhatsappShareButton url={shareUrl} title={title}>
<WhatsappIcon size={32} round />
<WhatsappIcon size={25} round />
</WhatsappShareButton>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion components/Tags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "@/components/button";
import { TagFrequencyMap } from "@/layouts/types";
import { TagFrequencyMap } from "@/lib/types";
import Link from "next/link";
import { useParams } from "next/navigation";

Expand Down
2 changes: 1 addition & 1 deletion functions/articleFilteredPosts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import notion from "@/lib";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import { convertToPost } from "./convertToPost";

export const getTagFilteredPosts = async ({
Expand Down
2 changes: 1 addition & 1 deletion functions/convertToPost.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";

export const convertToPost = (item: any): Article => ({
id: item.id,
Expand Down
21 changes: 16 additions & 5 deletions functions/getAllPosts.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import notion from "@/lib";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import { convertToPost } from "./convertToPost";

export const getAllPosts = async (): Promise<Article[]> => {
const databaseId = process.env.NOTION_DATABASE_ID!;
const response = await notion.databases.query({
database_id: databaseId,
filter: {
property: "status",
select: {
equals: "Published",
},
and: [
{
property: "status",
select: {
equals: "Published",
},
},
{
property: "type",
select: {
equals: "Post",
},
},
// Add more conditions if needed
],
},
sorts: [
{
Expand Down
2 changes: 1 addition & 1 deletion functions/getAllTags.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article, TagFrequencyMap } from "@/layouts/types";
import { Article, TagFrequencyMap } from "@/lib/types";

export const calculateTagFrequency = async ({
publishedPosts,
Expand Down
88 changes: 46 additions & 42 deletions functions/getTagPosts.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
// Import necessary libraries and components
import notion from "@/lib";
import { Article } from "@/layouts/types";
import { convertToPost } from "./convertToPost";
// // Import necessary libraries and components
// import notion from "@/lib";
// import { Article } from "@/lib/types";
// import { convertToPost } from "./convertToPost";

export const getPublishedPostsByTag = async (tags?: string[]): Promise<Article[]> => {
const databaseId = process.env.NOTION_DATABASE_ID!;
// export const getPublishedPostsByTag = async (tags?: string[]): Promise<Article[]> => {
// const databaseId = process.env.NOTION_DATABASE_ID!;

// Create filter based on whether tags are provided
const filter = tags
? [
{
property: "status",
select: {
equals: "Published",
},
},
{
property: "tags", // Assuming tags is the property name in your database
multi_select: {
contains_all: tags,
},
},
]
: {
property: "status",
select: {
equals: "Published",
},
};
// // Create filter based on whether tags are provided
// const filter = {
// and: [
// {
// property: "status",
// select: {
// equals: "Published",
// },
// },
// {
// property: "type",
// select: {
// equals: "Post",
// },
// },
// {
// property: "tags", // Assuming "tags" is the property name in your database
// multi_select: {
// contains_all: tags,
// },
// },
// ]
// };

const response = await notion.databases.query({
database_id: databaseId,
sorts: [
{
property: "date",
direction: "ascending",
},
],
});
// const response = await notion.databases.query({
// database_id: databaseId,
// filter: {
// or: [filter], // Wrap filter inside an array if needed
// },
// sorts: [
// {
// property: "date",
// direction: "ascending",
// },
// ],
// });

const getPublishedPostsByTag: Article[] = response.results.map((e) =>
convertToPost(e)
);
// const getPublishedPostsByTag: Article[] = response.results.map((e) =>
// convertToPost(e)
// );

return getPublishedPostsByTag;
};
// return getPublishedPostsByTag;
// };
2 changes: 1 addition & 1 deletion functions/tagFilteredPosts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import notion from "@/lib";
import { Article } from "@/layouts/types";
import { Article } from "@/lib/types";
import { convertToPost } from "./convertToPost";

export const getTagFilteredPosts = async ({
Expand Down
17 changes: 0 additions & 17 deletions layouts/Footer.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions layouts/Layout.tsx

This file was deleted.

Loading

0 comments on commit 703c9fe

Please sign in to comment.