Skip to content

Commit

Permalink
fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lowk3v committed Oct 5, 2023
1 parent 9381f32 commit a95a568
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
54 changes: 34 additions & 20 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import Link from "next/link";
import styles from './styles/Home.module.css';
import React, { useEffect, useState } from "react";

interface IFeed {
title: string;
link: string;
isoDate: string;
contentSnippet: string;
source: string;
color: string;
}

const navigation = [
{ name: "Projects", href: "/projects" },
{ name: "About", href: "/about" },
Expand Down Expand Up @@ -136,26 +145,31 @@ export default function Home() {
<section className={styles.subSection}>
<h2 className={styles.heading}>Latest Post 👇</h2>
<div className={styles['issue-container']}>
{feeds && feeds.map((issue, i) => (
<a key={i} href={issue.link} className={styles['issue-line']}>
<div className={styles['issue-header']}>
<div
style={{ backgroundColor: issue.color }}
className={styles['issue-source']}
>
{issue.source}
</div>
<div className={styles['issue-date']}>
{/* {moment(issue.isoDate).fromNow()} */}
</div>
</div>
<div className={styles['issue-title']}>{issue.title}</div>
<div className={styles['issue-snippet']}>
{(issue.contentSnippet || '').substring(0, 100)}
{(issue.contentSnippet || '').length > 100 ? '...' : ''}
</div>
</a>
))}
{
feeds && feeds.map((issue, i) => {
const { title, link, isoDate, contentSnippet, source, color } = issue as IFeed;
return (
<a key={i} href={link} className={styles['issue-line']}>
<div className={styles['issue-header']}>
<div
style={{ backgroundColor: color }}
className={styles['issue-source']}
>
{source}
</div>
<div className={styles['issue-date']}>
{/* {moment(issue.isoDate).fromNow()} */}
</div>
</div>
<div className={styles['issue-title']}>{title}</div>
<div className={styles['issue-snippet']}>
{(contentSnippet || '').substring(0, 100)}
{(contentSnippet || '').length > 100 ? '...' : ''}
</div>
</a>
)
})
}
</div>
</section>
</div>
Expand Down
5 changes: 4 additions & 1 deletion app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { Eye } from "lucide-react";

export const revalidate = 60;
export default async function ProjectsPage() {
const views = {};
interface IView {
[slug: string]: number;
}
const views: IView = {};


const featured = allProjects.filter(
Expand Down
9 changes: 6 additions & 3 deletions pages/api/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export default async function feeds(
const parser = new Parser();
const newsletter = await parser.parseURL('https://lowk.substack.com/feed');
res.status(200).json({
updatedAt: `Last issue: ${fromNow(
new Date(newsletter.items[0].pubDate)
)}`,
// updatedAt: `Last issue: ${fromNow(
// new Date(newsletter.items[0].pubDate)
// )}`,
// @ts-ignore
feeds: [
...newsletter.items.map((item: any) => ({
...item,
Expand Down Expand Up @@ -62,6 +63,7 @@ function fromNow(
];
const now =
typeof nowDate === 'object'
// @ts-ignore
? nowDate.getTime()
: new Date(nowDate).getTime();
const diff =
Expand All @@ -72,6 +74,7 @@ function fromNow(
const x = Math.round(Math.abs(diff) / interval.divisor);
const isFuture = diff < 0;
return interval.unit
// @ts-ignore
? rft.format(isFuture ? x : -x, interval.unit)
: interval.text;
}
Expand Down

0 comments on commit a95a568

Please sign in to comment.