diff --git a/README.md b/README.md index ff73a4c..a91882b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Create a [Remix](https://remix.run/) blog powered by [Contentful](https://www.co ![Screenshot](screenshot.png) ## Getting started -See our [official Contentful getting started guide](https://www.contentful.com/developers/docs/tutorials/general/get-started/). ### Get the source code and install dependencies ```shell diff --git a/app/components/article-preview.tsx b/app/components/article-preview.tsx index 7f0c267..41a1ec3 100644 --- a/app/components/article-preview.tsx +++ b/app/components/article-preview.tsx @@ -3,11 +3,16 @@ import {Link} from 'remix' import {ContentfulImage} from "~/components/contentful-image"; import {CssModuleWrapper} from "~/components/css-module-wrapper"; import {toReadableDate} from "~/utils/to-readable-date"; +import {TypePostPreview} from "../../types/contentful-graphql-types"; import Container from './container' import Tags from './tags' -const ArticlePreview = ({posts}) => { +type Props = { + posts: TypePostPreview[] +} + +const ArticlePreview: React.FC = ({posts}) => { if (!posts) return null if (!Array.isArray(posts)) return null @@ -21,22 +26,23 @@ const ArticlePreview = ({posts}) => {

{post.title}

-
-
+
{toReadableDate(post.publishDate)} - -
+ {post.tags && } + ) })} diff --git a/app/components/container.tsx b/app/components/container.tsx index 0cd5b64..1cb91ad 100644 --- a/app/components/container.tsx +++ b/app/components/container.tsx @@ -5,7 +5,7 @@ type Props = { children?: React.ReactNode } -const Container:React.FC = ({ children, as = 'div' }) => { +const Container:React.FC = ({ children, as = 'section' }) => { const Tag = as return ( = ( decoding = 'auto' }) => { - let mimeType = '' // extract mimeType from image.url + let mimeType = image.contentType // extract mimeType from image.url let query = {}; // should only allow ContentfulImage.Query props @@ -106,14 +101,14 @@ const ContentfulImage: React.FC = ( if (format === '8bit') { addToQuery({'fm': 'png'}) addToQuery({'fl': 'png8'}) - mimeType = 'png' + mimeType = 'image/png' } else if (format === 'progressive') { addToQuery({'fm': 'jpg'}) addToQuery({'fl': 'progressive'}) - mimeType = 'jpg' + mimeType = 'image/jpg' } else { addToQuery({[imagePropsMap['format']]: format.toString()}) - mimeType = format + mimeType = `image/${format}` } } @@ -129,10 +124,10 @@ const ContentfulImage: React.FC = ( return ( - + {alt} = ({className, children}) => { @@ -12,4 +12,4 @@ const CssModuleWrapper: React.FC = ({className, children}) => { ); }; -export { CssModuleWrapper }; +export {CssModuleWrapper}; diff --git a/app/components/hero.tsx b/app/components/hero.tsx index bc21fee..161cb57 100644 --- a/app/components/hero.tsx +++ b/app/components/hero.tsx @@ -11,23 +11,23 @@ type Props = { const Hero: React.FC = ({image, title, content}) => ( -
+
{image && ( -
+
-
+ )}

{title}

{content &&

{content}

}
-
+
) diff --git a/app/components/navigation.tsx b/app/components/navigation.tsx index 6faa0b2..46ce131 100644 --- a/app/components/navigation.tsx +++ b/app/components/navigation.tsx @@ -2,7 +2,7 @@ import React from 'react' import {Link} from 'remix' import {CssModuleWrapper} from "~/components/css-module-wrapper"; -const Navigation = () => ( +const Navigation: React.FC = () => (
- + ) } diff --git a/app/routes/blog.tsx b/app/routes/blog.tsx index 3c1907e..5123f76 100644 --- a/app/routes/blog.tsx +++ b/app/routes/blog.tsx @@ -6,7 +6,7 @@ import ArticlePreview from "~/components/article-preview"; import Hero from "~/components/hero"; import {TypePostPreview} from "../../types/contentful-graphql-types"; -type LoaderData = { posts: TypePostPreview }; +type LoaderData = { posts: TypePostPreview[] }; export const loader: LoaderFunction = async ({}) => { return json({ diff --git a/app/styles/modules/article-preview.module.css b/app/styles/modules/article-preview.module.css index 2a752f8..4523da3 100644 --- a/app/styles/modules/article-preview.module.css +++ b/app/styles/modules/article-preview.module.css @@ -1,30 +1,30 @@ .article-module .article-list { - margin: 0; - padding: 0; - list-style: none; - display: grid; - grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); - grid-gap: var(--space-3xl); + margin: 0; + padding: 0; + list-style: none; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + grid-gap: var(--space-3xl); } .article-module .title { - display: inline-block; - font-size: var(--text-lg); - margin-bottom: var(--space-xs); - margin-top: var(--space-lg); - border-bottom: 1.5px solid transparent; + display: inline-block; + font-size: var(--text-lg); + margin-bottom: var(--space-xs); + margin-top: var(--space-lg); + border-bottom: 1.5px solid transparent; } .article-module .link { - text-decoration: none; + text-decoration: none; } .article-module .link:hover .title { - border-bottom-color: var(--primary); + border-bottom-color: var(--primary); } .article-module .meta { margin-top: var(--space-md); - display: flex; - justify-content: space-between; + display: flex; + justify-content: space-between; } diff --git a/app/styles/modules/tags.module.css b/app/styles/modules/tags.module.css index e097537..550fb40 100644 --- a/app/styles/modules/tags.module.css +++ b/app/styles/modules/tags.module.css @@ -1,11 +1,12 @@ .tags-module .tags { - display: flex; - gap: var(--space-md); + display: flex; + gap: var(--space-md); + margin-top: var(--space-md); } .tags-module .tag { - background-color: var(--black-fade-5); - border-radius: var(--radius-sm); - line-height: var(--solid); - padding: var(--space-sm) var(--space-md); + background-color: var(--black-fade-5); + border-radius: var(--radius-sm); + line-height: var(--solid); + padding: var(--space-sm) var(--space-md); } diff --git a/app/utils/to-readable-date.ts b/app/utils/to-readable-date.ts index 49266bc..de07947 100644 --- a/app/utils/to-readable-date.ts +++ b/app/utils/to-readable-date.ts @@ -1,4 +1,4 @@ export function toReadableDate(dateString: string): string { const options: Intl.DateTimeFormatOptions = {year: "numeric", month: "long", day: "numeric"} - return new Date(dateString).toLocaleDateString(undefined, options) + return new Date(dateString).toLocaleDateString(["de-DE"], options) }