Skip to content

Commit

Permalink
Rearrange the post layout to put the title above the image. Set to Da…
Browse files Browse the repository at this point in the history
…rk mode by default.
  • Loading branch information
pbassham committed Sep 3, 2024
1 parent 2110106 commit a6f6ca9
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 57 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Uses Github Projects (v2) as CMS.

#### Features:
- Issue = Page or Post
- Category Pages (using custom field in project)
- Category Pages (using custom field in the Github project)
- Tag Pages using github Labels
- MDX Components
- public editing option
-
- Live updating site without a redeploy to Vercel. Just need to refresh the homepage and it checks for new issues and builds the pages.

## Instructions

Expand All @@ -28,7 +28,7 @@ Uses Github Projects (v2) as CMS.
### Github Project Configuration

1. Create a Project
2. Enter the Project Number \_\_\_
2. Enter the Project Number \_\_\_ in the configuration file `githubCMS.config.ts`
3. Create Custom fields (fields with no space will be used as is, if the name has a space it will turn to camelCase)
1. Category
2. Cover Image
Expand Down Expand Up @@ -57,3 +57,6 @@ Example:
project_num: 1,
}
```
### Make a Category Page
1. Create a new issue in the project and title it the category name (eg. Posts)
2. Set a subtitle that will show up on the category page as a description.
8 changes: 8 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ const NextConfig = {
experimental: {
appDir: false,
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**.githubusercontent.com',
},
],
},
}
module.exports = NextConfig
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const Footer = (props: FlexProps) => (
<IconButton as="a" href={`https://github.com/${config.github_account}`} target="_blank" aria-label="GitHub" icon={<FaGithub fontSize="1.25rem" />} />
<IconButton
as="a"
href={`https://twitter.com/${config.twitter_account}`}
href={`https://x.com/${config.twitter_account}`}
target="_blank"
aria-label="Twitter"
aria-label="X"
_hover={{
background: "whiteAlpha.100",
color: "blue.300",
Expand Down
64 changes: 40 additions & 24 deletions src/components/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import NextLink from "next/link"
import { HTMLChakraProps } from "@chakra-ui/system"
import Summary from "./Summary"
import { Hero } from "./Hero"
// import NextImage from "next/image"

const Hr = () => {
const borderColor = mode("gray.200", "gray.600")
Expand Down Expand Up @@ -128,15 +129,36 @@ const Intro = (props) => {
</Box>
)
}
// import { Image, chakra } from '@chakra-ui/react';
// export const ChakraNextImage = (props) => {
// const { src, alt, ...rest } = props
// return (
// <Box position="relative" {...rest}>
// <NextImage
// objectFit="cover"
// // layout="fill"
// fill
// src={src}
// alt={alt}
// />
// </Box>
// )
// }

export const MDXComponents: import("mdx/types").MDXComponents | undefined = {
h1: (props: HeadingProps): ReactElement => <H as="h1" size="xl" my="1.25rem" {...props} />,
h2: (props: HeadingProps): ReactElement => <H as="h2" size="xl" my="1.5rem" {...props} />,
h3: (props: HeadingProps): ReactElement => <H as="h3" size="lg" my="3rem" {...props} />,
h4: (props: HeadingProps): ReactElement => <H as="h4" size="lg" my="3rem" {...props} />,
p: (props): ReactElement => <Text as="p" lineHeight="1.6" my="1.25rem"
// px={10}
{...props} />,
p: (props): ReactElement => (
<Text
as="p"
lineHeight="1.6"
my="1.25rem"
// px={10}
{...props}
/>
),
// a: (props): ReactElement => <StylishLink {...props} />,
a: (props): ReactElement => <NextChakraLink href={props?.href} {...props} />,
ul: (props): ReactElement => <UnorderedList pl={4} {...props} />,
Expand All @@ -157,27 +179,21 @@ export const MDXComponents: import("mdx/types").MDXComponents | undefined = {
hr: Hr,
inlineCode: (props): ReactElement => <InlineCode {...props} />,
blockquote: Blockquote,
img: (props): ReactElement => <Image
ml={'-50vw'}
// mr={'-50vw'}
borderRadius='xl'
// w='5xl'
// w={'4xl'}
// maxW={'5xl'}
// maxW={'container.sm'}
left='48vw'
// right='50vw'
position={'relative'}

//
// margin-left: -50vw;
// margin-right: -50vw;
// max-width: 100vw;
// width: 100vw;
// left: 50%;
// position: relative;
// right: 50%;
{...props} />,
img: (props): ReactElement => (
<Image
ml={"-50vw"}
borderRadius="xl"
left="48vw"
// right='50vw'
position={"relative"}
// mr={'-50vw'}
// w='5xl'
// w={'4xl'}
// maxW={'5xl'}
// maxW={'container.sm'}
{...props}
/>
),
// Small,
// SideNote,
// Asterisk,
Expand Down
64 changes: 37 additions & 27 deletions src/components/PostList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,26 @@ const PostList = (props: { allPosts: PostType[] }) => {
morePosts.map((post: PostType) => {
const { slug, category, coverImage, tags, title, subTitle, excerpt } = post
// if (post.slug === "about") return
// console.log("post", post)
return (
// <Link href={`/${category || "posts"}/${slug}`} key={slug}>
<Link href={`/${slug}`} key={slug}>
<Box pt={8} role="group">
{coverImage && (
<Image
src={coverImage}
borderRadius={"md"}
cursor="pointer"
as={motion.img}
whileHover={{ scale: 1.01 }}
boxShadow="xl"
// whileTap={{ scale: 0.97 }}
/>
)}
<Container maxW={"90%"} px={0}>
<Box pt={0} role="group">

<Container maxW={"90%"} px={0} py={5}>
<Text
fontSize={"2xl"}
cursor={"pointer"}
fontWeight="bold"
fontFamily={"mono"}
pt={10}
// pt={10}
_groupHover={{ fontWeight: "semibold", color: "pink.500" }}
>
{title}
</Text>
<Stack
// direction="row"

>
<Text
// fontSize={""}
Expand All @@ -57,26 +49,44 @@ const PostList = (props: { allPosts: PostType[] }) => {
// fontWeight="bold"
// fontFamily={"mono"}
// fontStyle='italic'
// py={10}
// pb={10}
_groupHover={{ color: "pink.500" }}
>
{subTitle}
</Text>
<Tags tags={tags} />
</Stack>
<Text
// fontSize={""}
cursor={"pointer"}
// fontWeight="bold"
// fontFamily={"mono"}
pt={3}
pb={10}
// _groupHover={{ color: "pink.500" }}
>
{excerpt}
</Text>
<Divider />


</Container>
{coverImage && (
<Image
src={coverImage}
borderRadius={"md"}
cursor="pointer"
as={motion.img}
whileHover={{ scale: 1.01 }}
boxShadow="xl"
paddingY={5}
// whileTap={{ scale: 0.97 }}
/>
)}
{excerpt && (
<Container maxW={"90%"} px={0}>
<Text
// fontSize={""}
cursor={"pointer"}
// fontWeight="bold"
// fontFamily={"mono"}
pt={3}
pb={10}
// _groupHover={{ color: "pink.500" }}
>
{excerpt}
</Text>
</Container>
)}
<Divider py={5} />
</Box>
</Link>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class Document extends NextDocument {
<Head />
<body>
{/* Make Color mode to persists when you refresh the page. */}
<ColorModeScript />
<ColorModeScript initialColorMode='dark'/>
<Main />
<NextScript />
</body>
Expand Down

0 comments on commit a6f6ca9

Please sign in to comment.