-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from processing/feat/libraries-directory
Add directory for all libraries
- Loading branch information
Showing
5 changed files
with
158 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
interface Props { | ||
href: string | ||
selected?: boolean | ||
} | ||
const { href, selected = false } = Astro.props; | ||
--- | ||
|
||
<a href={href} class={`rounded-button ${selected ? 'selected' : ''}`}> | ||
<slot /> | ||
</a> | ||
|
||
<style lang="scss"> | ||
.rounded-button { | ||
display: inline-block; | ||
margin: var(--spacing-md); | ||
margin-left: 0; | ||
padding: var(--spacing-xs) var(--spacing-sm); | ||
border: 1px solid var(--type-black); | ||
color: var(--type-black); | ||
border-radius: 999px; | ||
} | ||
.rounded-button.selected { | ||
color: var(--type-black); | ||
background: var(--accent-color); | ||
} | ||
</style> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
import { getCurrentLocale } from "@/src/i18n/utils"; | ||
import { getLibraryLink } from "@/src/pages/_utils"; | ||
import Image from "@components/Image/index.astro"; | ||
import type { CollectionEntry } from "astro:content"; | ||
interface Props { | ||
item: CollectionEntry<"libraries">; | ||
} | ||
const { item } = Astro.props; | ||
const authorsFormatter = new Intl.ListFormat( | ||
getCurrentLocale(Astro.url.pathname), | ||
{ | ||
style: "long", | ||
type: "conjunction", | ||
} | ||
); | ||
const authorsString = authorsFormatter.format( | ||
item.data.author.map((a) => a.name) | ||
); | ||
let description = item.data.description.trim(); | ||
// If the description didn't end with punctuation, add it, since we will be | ||
// appending another sentence afterwards. | ||
if (!/[.!]\)?$/.test(description)) { | ||
description += "."; | ||
} | ||
--- | ||
|
||
<a class="group hover:no-underline flex mt-sm items-center" href={getLibraryLink(item)}> | ||
<Image | ||
src={item.data.featuredImage} | ||
alt={item.data.featuredImageAlt} | ||
width="80" | ||
class="mr-2" | ||
/> | ||
<div class="flex-1"> | ||
<!-- visible alt text class keeps the alt text within | ||
the narrower image width given in class prop --> | ||
<p | ||
class="text-xl mt-0 text-wrap break-words break-keep group-hover:underline" | ||
> | ||
{item.data.name} | ||
</p> | ||
<p class="text-body-caption mt-xxs"> | ||
{description} By {authorsString} | ||
</p> | ||
</div> | ||
</a> |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
import { getCollectionInDefaultLocale } from "../../_utils"; | ||
import LibrariesLayout from "@/src/layouts/LibrariesLayout.astro"; | ||
const libraries = await getCollectionInDefaultLocale("libraries"); | ||
--- | ||
|
||
<LibrariesLayout full title="Libraries" entries={libraries} /> |