This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Footer from '../../components/Footer'; | |
import axios from 'axios'; | |
import parse from 'html-react-parser'; | |
import { getAuthor, getFeaturedImage } from '../../lib/utils'; | |
import { POSTS_API_URL } from '../../lib/constants'; | |
import Head from 'next/head'; | |
import styles from '../../styles/Post.module.css'; | |
export default function Post({ title, featuredImg, author, content, date }) { | |
return ( | |
<div className="flex flex-col items-center justify-center min-h-screen"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Footer from '../../components/Footer'; | |
import axios from 'axios'; | |
import { getAuthor, getFeaturedImage } from '../../lib/utils'; | |
import { POSTS_API_URL } from '../../lib/constants'; | |
export default function Post({ title, featuredImg, author, content, date }) { | |
return ( | |
<div className="flex flex-col items-center justify-center min-h-screen"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Link from 'next/link'; | |
import { useState, useEffect } from 'react'; | |
import { getAuthor, getFeaturedImage } from '../lib/utils'; | |
import parse from 'html-react-parser'; | |
export default function Post({ post }) { | |
const [postImgAndAuthor, setPostImgAndAuthor] = useState({ featImgUrl: '', author: '' }); | |
useEffect(() => { | |
let mounted = true; | |
if (mounted) { | |
const author = getAuthor(post.author); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Head from 'next/head'; | |
import Post from '../components/Post'; | |
import Footer from '../components/Footer'; | |
import { useState, useEffect } from 'react'; | |
import { getAllPostsFromServer } from '../lib/utils'; | |
export default function Home() { | |
const [posts, setPosts] = useState([]); | |
useEffect(async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import { POSTS_API_URL, AUTHORS_API_URL, MEDIA_API_URL } from './constants'; | |
export const getAllPostsFromServer = async () => { | |
// get all posts from Server | |
try { | |
const { data } = await axios.get(POSTS_API_URL); | |
return data; | |
} catch (error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pusher } from "../../../lib/pusher"; | |
// presence channel handler | |
export default async function handler(req, res) { | |
const { message, username, userLocation } = req.body; | |
// trigger a new post event via pusher | |
await pusher.trigger("presence-channel", "chat-update", { | |
message, | |
username, | |
userLocation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pusher from './index' | |
export default function handler({ req, res }) { | |
// trigger a new post event via pusher | |
pusher.trigger("presence-channel", "location-update", { | |
username: req.body.userName, | |
location: req.body.location, | |
}); | |
res.json({ status: 200 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {pusher} from '../../../../lib/pusher' | |
export default async function handler( req, res ) { | |
// see https://pusher.com/docs/channels/server_api/authenticating-users | |
const { socket_id, channel_name, username, userLocation } = req.body; | |
// use JWTs here to authenticate users before continuing | |
const randomString = Math.random().toString(36).slice(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
import Pusher from "pusher-js"; | |
import axios from "axios"; | |
const Chat = ({ sender }) => { | |
const [chats, setChats] = useState([]); | |
const [messageToSend, setMessageToSend] = useState(""); | |
useEffect(() => { | |
const pusher = new Pusher(process.env.NEXT_PUBLIC_KEY, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Button from "../components/Button"; | |
export default function Login({ handleLogin, handleLoginChange }) { | |
return ( | |
<div> | |
<div> | |
<h1>Chattr</h1> | |
<p>your chats, your way</p> | |
</div> | |
NewerOlder