From 124934e6fb5019f92955cce5d59fee9240275660 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 19 Sep 2023 13:41:37 +0100 Subject: [PATCH] related posts tweaks --- .../2014-04-26-ai-weiwei-stools/index.md | 1 + .../2021-11-26-forever-bicycles/index.md | 2 +- .../2021-11-26-law-of-the-journey/index.md | 2 +- src/components/PhotoTeaser.astro | 43 +++++++------------ src/components/RelatedPosts/index.astro | 36 ++++++---------- src/components/RelatedPosts/index.module.css | 23 +++------- src/components/layouts/Archive.astro | 3 +- src/pages/index.astro | 1 - 8 files changed, 38 insertions(+), 73 deletions(-) diff --git a/content/photos/2014-04-26-ai-weiwei-stools/index.md b/content/photos/2014-04-26-ai-weiwei-stools/index.md index f8fcecbf..812bb131 100644 --- a/content/photos/2014-04-26-ai-weiwei-stools/index.md +++ b/content/photos/2014-04-26-ai-weiwei-stools/index.md @@ -5,6 +5,7 @@ author: Matthias Kretschmann --- Ai Weiwei - Evidence, Stools at Martin Gropius Bau + Processed with VSCOcam with b2 preset [flickr](https://www.flickr.com/photos/krema/14016811365/) | [EyeEm](http://www.eyeem.com/p/35839008) diff --git a/content/photos/2021-11-26-forever-bicycles/index.md b/content/photos/2021-11-26-forever-bicycles/index.md index a09753c2..091264ee 100644 --- a/content/photos/2021-11-26-forever-bicycles/index.md +++ b/content/photos/2021-11-26-forever-bicycles/index.md @@ -1,7 +1,7 @@ --- date: 2021-11-26T15:32:28.000Z -title: Forever Bicycles +title: Ai Weiwei, Forever Bicycles image: ./2021-11-26-forever-bicycles.jpg --- diff --git a/content/photos/2021-11-26-law-of-the-journey/index.md b/content/photos/2021-11-26-law-of-the-journey/index.md index c86ffc75..fbe58743 100644 --- a/content/photos/2021-11-26-law-of-the-journey/index.md +++ b/content/photos/2021-11-26-law-of-the-journey/index.md @@ -1,7 +1,7 @@ --- date: 2021-11-26T16:12:03.000Z -title: Law of the Journey +title: Ai Weiwei, Law of the Journey image: ./2021-11-26-law-of-the-journey.jpg --- diff --git a/src/components/PhotoTeaser.astro b/src/components/PhotoTeaser.astro index f8f80649..6600f44e 100644 --- a/src/components/PhotoTeaser.astro +++ b/src/components/PhotoTeaser.astro @@ -9,35 +9,22 @@ const { title, image } = data --- -
- { - image ? ( - - - - ) : null - } -
+{ + image ? ( + + + + ) : null +} diff --git a/src/components/RelatedPosts/index.astro b/src/components/RelatedPosts/index.astro index 2f942640..5bf31902 100644 --- a/src/components/RelatedPosts/index.astro +++ b/src/components/RelatedPosts/index.astro @@ -12,45 +12,35 @@ type Props = { } const { post, isPhotos } = Astro.props as Props const allPosts = await getAllPostsForSearch() +const allPostsWithoutCurrent = allPosts?.filter( + (post) => post.slug !== Astro.props.post.slug +) as CollectionEntry<'articles' | 'photos' | 'links'>[] // Configure fuse.js // https://fusejs.io/api/options.html -const fuseOptions: Fuse.IFuseOptions< - CollectionEntry<'articles' | 'photos' | 'links'> -> = { - keys: ['data.tags', 'data.title', 'data.lead', 'collection'], +const fuse = new Fuse(allPostsWithoutCurrent, { + keys: ['data.tags', 'data.title', 'data.lead'], useExtendedSearch: true, - minMatchCharLength: 3, - threshold: 0.8 -} -// TODO; figure out how to remove any -const allPostsWithoutCurrent = allPosts?.filter( - (post) => post.slug !== Astro.props.post.slug -) -const fuse = new Fuse(allPostsWithoutCurrent as any, fuseOptions) + threshold: 0.6 +}) const relatedPosts = fuse // https://www.fusejs.io/examples.html#extended-search .search( - `${post?.data?.tags?.join(' | ')} | ${post?.data?.title} | ${ - (post?.data as any)?.lead - } | ${post?.collection}` + `${post?.data?.tags?.join(' | ')} | "${post?.data?.lead}" | "${ + post?.data?.title + }"` ) .map((result) => result.item) .slice(0, 6) --- -
-

- Related {isPhotos ? 'Photos' : 'Posts'}{' '} - -

+
+

Related

    { relatedPosts?.map((post) => (
  • - {isPhotos ? ( + {post.collection === 'photos' ? ( } /> ) : ( div { margin-bottom: 0; } .relatedPosts a h1 { - font-size: var(--font-size-h4); -} - -.button { - font-size: var(--font-size-mini); - display: inline-block; - color: var(--text-color-light); - text-transform: uppercase; - margin-left: calc(var(--spacer) / 2); + font-size: var(--font-size-h5); } diff --git a/src/components/layouts/Archive.astro b/src/components/layouts/Archive.astro index 95fe867f..da68cbd6 100644 --- a/src/components/layouts/Archive.astro +++ b/src/components/layouts/Archive.astro @@ -22,12 +22,13 @@ const classes = `posts ${