Skip to content

Commit

Permalink
Add GoodReads and Medium links
Browse files Browse the repository at this point in the history
  • Loading branch information
puf committed Jul 28, 2024
1 parent 01e8429 commit 49919c2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: 'How to perform geoqueries on Firestore (somewhat) efficiently'
description: 'Searching for documents in a gerographical range on Firestore always required workarounds, but not anymore.'
pubDate: 'May 30, 2024'
heroImage: 'https://miro.medium.com/v2/resize:fit:1400/format:webp/1*teIrX51jyNYyyCajHGYthA.png'
alsoOn: ['https://medium.com/p/6c2f10fd285f']
---

A geoquery allows you to find points-of-interest that are within a certain range of a specific location. For example, say you have a list of all restaurants and their location: how do you find the ones that are within 5km of the user’s current location?
Expand Down
12 changes: 11 additions & 1 deletion src/components/AlsoOn.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ function getSocialLinkType(link) {
if (new RegExp("https\://threads.net/").test(link)) return "threads";
if (new RegExp("https\://c.im/").test(link)) return "mastodon";
if (new RegExp("https\://linkedin.com/").test(link)) return "linkedin";
if (new RegExp("https\://(www\.)?goodreads.com/").test(link)) return "goodreads";
if (new RegExp("https\://(www\.)?medium.com/").test(link)) return "medium";
}
---
{ links?.length && (
<div class="social-links" style="margin-top: -2em">Also posted on:
<div class="social-links" style="margin-top: -2em"><span title="You may be able to comment there...">Also on: </span>
{links.map((link, index) => (
<a href={link}>
{getSocialLinkType(link) === "twitter" && (
Expand All @@ -30,6 +32,14 @@ function getSocialLinkType(link) {
<span class="sr-only">LinkedIn</span>
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24"><path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/></svg>
)}
{getSocialLinkType(link) === "goodreads" && (
<span class="sr-only">GoodReads</span>
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24"><path d="M19.525 15.977V.49h-2.059v2.906h-.064c-.211-.455-.481-.891-.842-1.307-.36-.412-.767-.777-1.232-1.094-.466-.314-.962-.561-1.519-.736C13.256.09 12.669 0 12.038 0c-1.21 0-2.3.225-3.246.67-.947.447-1.743 1.057-2.385 1.83-.642.773-1.133 1.676-1.47 2.711-.336 1.037-.506 2.129-.506 3.283 0 1.199.141 2.326.425 3.382.286 1.057.737 1.976 1.368 2.762.631.78 1.412 1.397 2.375 1.833.961.436 2.119.661 3.471.661 1.248 0 2.33-.315 3.262-.946s1.638-1.473 2.119-2.525h.061v2.284c0 2.044-.421 3.607-1.264 4.705-.84 1.081-2.224 1.638-4.146 1.638-.572 0-1.128-.061-1.669-.181-.542-.12-1.036-.315-1.487-.57-.437-.271-.827-.601-1.143-1.038-.316-.435-.526-.961-.632-1.593H5.064c.067.887.315 1.654.737 2.3.424.646.961 1.172 1.602 1.593.641.406 1.367.706 2.172.902.811.194 1.639.3 2.494.3 1.383 0 2.541-.195 3.486-.555.947-.376 1.714-.902 2.301-1.608.601-.708 1.021-1.549 1.293-2.556.27-1.007.42-2.134.42-3.367l-.044.062zm-7.484-.557c-.955 0-1.784-.189-2.479-.571-.697-.38-1.277-.882-1.732-1.503-.467-.621-.797-1.332-1.022-2.139s-.332-1.633-.332-2.484c0-.871.105-1.725.301-2.563.21-.84.54-1.587.992-2.24.451-.652 1.037-1.182 1.728-1.584s1.533-.605 2.51-.605 1.803.209 2.495.621c.676.415 1.247.959 1.683 1.634.436.677.751 1.429.947 2.255.195.826.285 1.656.285 2.482 0 .852-.12 1.678-.345 2.484-.226.807-.572 1.518-1.038 2.139-.465.621-1.021 1.123-1.698 1.503-.676.382-1.458.571-2.359.571h.064z"></path></svg>
)}
{getSocialLinkType(link) === "medium" && (
<span class="sr-only">Medium</span>
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 1043.63 592.71"><path d="M588.67 296.36c0 163.67-131.78 296.35-294.33 296.35S0 460 0 296.36 131.78 0 294.34 0s294.33 132.69 294.33 296.36M911.56 296.36c0 154.06-65.89 279-147.17 279s-147.17-124.94-147.17-279 65.88-279 147.16-279 147.17 124.9 147.17 279M1043.63 296.36c0 138-23.17 249.94-51.76 249.94s-51.75-111.91-51.75-249.94 23.17-249.94 51.75-249.94 51.76 111.9 51.76 249.94"></path></svg>
)}
</a>
))}
</div>
Expand Down

This file was deleted.

8 changes: 7 additions & 1 deletion src/layouts/IndexPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const slug = getSlugForNote(Astro.props)
const type = getTypeForNote(Astro.props)
title = type
function hasReview(note) {
return note.props.rawContent().trim().length > 0;
}
const notes = await getNotes({ keepIf: (note) => note.params.type === type && !/readme.md$/.test(note.props.file) });
---

Expand Down Expand Up @@ -75,11 +79,13 @@ const notes = await getNotes({ keepIf: (note) => note.params.type === type && !/
<div class="list">
<div>There are {notes.length} {type}:</div>
<ol>
{notes.map((note) => (
{notes.map((note) => (
<li>
<a href={note.params.slug}>{note.props.frontmatter.title}</a>
{type === 'books' && <span> - {note.props.frontmatter?.author}</span>}
{type === 'books' && <StarRating rating={note.props.frontmatter?.rating}/>}
Finished on: {note.params.pubDate}
{(type === 'books' && hasReview(note)) && <span title="I've written a review for this book">📝</span>}
</li>
))}
</ol>
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/NotePost.astro
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const typeurl = "/"+type
<li>Started on: {note.frontmatter.startedDate}</li>
<li>Finished on: {note.frontmatter.finishedDate}</li>
<li>Rating: {note.frontmatter.rating} out of 5 stars</li> <!-- render star rating -->
<StarRating rating={note.frontmatter.rating} />
<StarRating rating={note.frontmatter.rating} /><br/>
<li><AlsoOn links={[note.frontmatter.link]} /></li>
</ul>
<hr/>
) : ( "" )}
Expand Down

0 comments on commit 49919c2

Please sign in to comment.