Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristineTham committed Feb 3, 2023
1 parent 4aa502e commit 2094d1b
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 122 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ All commands are run from the root of the project, from a terminal:
- 2.0.0: New version supporting Astro collections! Also clarified that this is a
multipurpose theme. Search can now include both Markdown and MDX pages!
- 2.0.1: Updated screenshots, and improved landing page.
- 2.1.0: updated to latest packages, fixed dev links, backported features from
personal blog, including Next/Prev links, photo gallery support in Markdown,
and improved pagination control.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"devDependencies": {
"@akebifiky/remark-simple-plantuml": "^1.0.2",
"@astrojs/alpinejs": "^0.1.3",
"@astrojs/image": "^0.13.1",
"@astrojs/mdx": "^0.15.2",
"@astrojs/image": "^0.14.0",
"@astrojs/mdx": "^0.16.0",
"@astrojs/sitemap": "^1.0.1",
"@astrojs/tailwind": "^3.0.1",
"@tailwindcss/aspect-ratio": "^0.4.2",
Expand All @@ -26,7 +26,7 @@
"@types/leaflet": "^1.9.0",
"@types/photoswipe": "^4.1.2",
"alpinejs": "^3.11.1",
"astro": "2.0.4",
"astro": "2.0.6",
"astro-robots-txt": "^0.3.11",
"exifr": "^7.1.3",
"mdast-util-to-string": "^3.1.1",
Expand All @@ -45,7 +45,7 @@
"hero-patterns": "^2.1.0",
"katex": "^0.16.4",
"lunr": "^2.3.9",
"photoswipe": "^5.3.4",
"photoswipe": "^5.3.5",
"photoswipe-dynamic-caption-plugin": "^1.2.7"
}
}
27 changes: 14 additions & 13 deletions src/components/blogcard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ export interface Props {
const { post } = Astro.props
const image = post.data.coverImage || post.data.socialImage || categoryDetail(post.data.categories && post.data.categories[0]).socialImage
const svgimg = post.data.coverSVG || (post.data.coverImage ? null : categoryDetail(post.data.categories && post.data.categories[0]).coverSVG)
console.log(import.meta.env.BASE_URL, post.slug, Astro.url.origin)
const image = post.data.coverImage || (post.data.images && post.data.images[0]) || post.data.socialImage || categoryDetail(post.data.categories && post.data.categories[0]).socialImage
const svgimg = post.data.coverSVG || ((post.data.coverImage || post.data.images) ? null : categoryDetail(post.data.categories && post.data.categories[0]).coverSVG)
---

<section class="p-4 md:w-1/2 lg:w-1/3">
<div
class="h-full border-1 border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800 rounded-lg shadow-xl overflow-hidden p-2"
>
<a href={Astro.url.origin + import.meta.env.BASE_URL + 'blog/' + post.slug}>
<a href={import.meta.env.BASE_URL + 'blog/' + post.slug}>
{
svgimg ? (
<SVGImg
Expand All @@ -42,7 +41,7 @@ console.log(import.meta.env.BASE_URL, post.slug, Astro.url.origin)
</a>
<div class="p-6">
<Categories categories={post.data.categories} />
<a href={Astro.url.origin + import.meta.env.BASE_URL + 'blog/' + post.slug}>
<a href={import.meta.env.BASE_URL + 'blog/' + post.slug}>
<h1
class="title-font text-xl font-bold text-purple-600 hover:text-pink-600 dark:text-purple-300 dark:hover:text-pink-300 mt-2"
>
Expand All @@ -54,17 +53,19 @@ console.log(import.meta.env.BASE_URL, post.slug, Astro.url.origin)
class="text-gray-500 dark:text-gray-400 mr-3 inline-flex items-center leading-none text-xs pr-3 py-1 border-r-2 border-purple-200 dark:border-purple-600"
>
<Icon class="w-4 h-4 mr-1" pack="heroicons-outline" name="calendar" />
{post.data.publishDate?.toString().slice(0, 10)}
</span>
<span
class="text-gray-500 dark:text-gray-400 mr-3 inline-flex items-center leading-none text-xs pr-3 py-1 border-r-2 border-purple-200 dark:border-purple-600"
>
<Icon class="w-4 h-4 mr-1" pack="heroicons-outline" name="clock" />
{post.data.minutesRead}
{post.data.publishDate.toDateString()}
</span>
{post.data.minutesRead && (
<span
class="text-gray-500 dark:text-gray-400 mr-3 inline-flex items-center leading-none text-xs pr-3 py-1 border-r-2 border-purple-200 dark:border-purple-600"
>
<Icon class="w-4 h-4 mr-1" pack="heroicons-outline" name="clock" />
{post.data.minutesRead}
</span>
)}
{post.data.author && (
<span
class="text-gray-500 dark:text-gray-400 inline-flex items-center leading-none text-xs"
class="text-rosely1 dark:text-rosely7 inline-flex items-center leading-none text-xs"
>
<Icon
class="w-4 h-4 mr-1"
Expand Down
6 changes: 3 additions & 3 deletions src/components/bloghero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export interface Props {
const { frontmatter } = Astro.props
const image = frontmatter.coverImage || frontmatter.socialImage || categoryDetail(frontmatter.categories && frontmatter.categories[0]).socialImage
const svgimg = frontmatter.coverSVG || (frontmatter.coverImage ? null : categoryDetail(frontmatter.categories && frontmatter.categories[0]).coverSVG)
const image = frontmatter.coverImage || (frontmatter.images && frontmatter.images[0]) || frontmatter.socialImage || categoryDetail(frontmatter.categories && frontmatter.categories[0]).socialImage
const svgimg = frontmatter.coverSVG || ((frontmatter.coverImage || frontmatter.images) ? null : categoryDetail(frontmatter.categories && frontmatter.categories[0]).coverSVG)
---

<div class="my-4 md:mb-0 w-full max-w-screen-xl mx-auto relative h-96">
Expand Down Expand Up @@ -61,7 +61,7 @@ const svgimg = frontmatter.coverSVG || (frontmatter.coverImage ? null : category
<span class="flex items-center mr-6">
<Icon class="w-6 h-6 mr-1 text-purple-200" pack="heroicons-outline" name="calendar" />
<span class="font-semibold text-purple-200 ml-1">
{frontmatter.publishDate?.toString().slice(0, 10)}
{new Date(frontmatter.publishDate).toString()}
</span>
</span>
<span class="flex items-center">
Expand Down
88 changes: 88 additions & 0 deletions src/components/images.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
import { Image } from '@astrojs/image/components'
import exifr from 'exifr'
import 'photoswipe/style.css'
import 'photoswipe-dynamic-caption-plugin/photoswipe-dynamic-caption-plugin.css'
export interface Props {
images: string[]
}
const { images } = Astro.props
const imageFiles = import.meta.glob<ImageMetadata>('../images/**/*.{png,webp,jpg,jpeg}', { import: 'default', eager: true })
const folderFiles = Object.keys(imageFiles).filter(image => images.includes(image))
const imageSrc = images.map(image => imageFiles[image])
const imagetitles = folderFiles.map(image => image.slice(0, image.lastIndexOf('.')).slice(image.lastIndexOf('/') + 1))
// console.log(images)
const exifs = [] as Record<string, any>[]
for (let i in folderFiles) {
const exif = await exifr.parse(folderFiles[i].replace('../', './src/'))
exifs.push(exif)
}
// console.log(exifs)
---
<style>
.pswp--custom-icon-colors {
--pswp-icon-color: #eee;
--pswp-icon-color-secondary: #663399;
}

.pswp__dynamic-caption--aside {
max-width: 300px;
padding: 20px 15px 20px 20px;
margin-top: 70px;
}

.pswp__dynamic-caption--below {
max-width: 700px;
padding: 15px 0 0;
}

.pswp__dynamic-caption--mobile {
background: rgba(0, 0, 0, 0.5);
padding: 10px 15px;
}
</style>
<p class="text-sm text-gray-500 italic">Please click on any photo to view in a lightbox. Use arrow keys or swipe to navigate.</p>
<div id="gallery" class="w-full block not-prose" itemscope itemtype="http://schema.org/ImageGallery">
{imageSrc.map((image, i) => (
<figure itemscope itemtype="http://schema.org/ImageObject" class="inline-block text-gray-800 dark:text-gray-300 bg-gray-300 dark:bg-gray-800 text-sm text-center italic rounded">
<a href={image.src} itemprop="contentUrl" data-pswp-width={image.width} data-pswp-height={image.height}>
<Image src={image} alt={imagetitles[i]} format="webp" class="rounded" />
<span class="pswp-caption-content">
{imagetitles[i]}
{exifs[i] && exifs[i].Make && <span>{' (' + exifs[i].Make + ' ' + exifs[i].Model + ')'}</span>}
</span>
</a>
<figcaption itemprop="caption description" class="rounded">
{imagetitles[i]}
</figcaption>
</figure>

))}
</div>
<script>
import PhotoSwipeLightbox from 'photoswipe/lightbox'
import PhotoSwipeDynamicCaption from 'photoswipe-dynamic-caption-plugin'

const lightbox = new PhotoSwipeLightbox({
mainClass: 'pswp--custom-icon-colors',
gallerySelector: '#gallery',
childSelector: 'a',
pswpModule: () => import('photoswipe'),
paddingFn: (viewportSize) => {
return {
top: 0, bottom: 30, left: 0, right: 0
}
}
})

const captionPlugin = new PhotoSwipeDynamicCaption(lightbox, {
captionContent: '.pswp-caption-content',
type: 'below',
});

lightbox.init()
</script>
12 changes: 6 additions & 6 deletions src/components/latestarticles.astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const otherPosts = posts.slice(1, 5)
<div
class="mb-4 lg:mb-0 p-4 lg:p-0 relative rounded block xl:col-span-2"
>
<a href={new URL(import.meta.env.BASE_URL + '/blog/' + newestPost.slug, Astro.url)}>
<a href={import.meta.env.BASE_URL + 'blog/' + newestPost.slug}>
<span class="sr-only">{newestPost.data.title}</span>
{
newestPost.data.coverSVG ? (
Expand Down Expand Up @@ -76,21 +76,21 @@ const otherPosts = posts.slice(1, 5)
)
}
</div>
<a href={new URL(import.meta.env.BASE_URL + 'blog/' + newestPost.slug, Astro.url)}>
<a href={import.meta.env.BASE_URL + 'blog/' + newestPost.slug}>
<h1
class="text-purple-600 hover:text-pink-600 dark:text-purple-300 dark:hover:text-pink-300 text-4xl font-bold mt-2 leading-tight"
>
{newestPost.data.title}
</h1>
</a>
<p class="text-gray-600 dark:text-gray-400 mb-4">
{newestPost.data.publishDate?.toISOString().slice(0, 10)}
{newestPost.data.publishDate?.toDateString()}
</p>
<p class="text-gray-600 dark:text-gray-400 mb-4">
{newestPost.data.description}
</p>
<a
href={new URL(import.meta.env.BASE_URL + 'blog/' + newestPost.slug, Astro.url)}
href={import.meta.env.BASE_URL + 'blog/' + newestPost.slug}
class="inline-block px-6 py-3 mt-2 rounded-md bg-purple-600 hover:bg-pink-600 text-white dark:bg-purple-300 dark:hover:bg-pink-300 dark:text-black"
>
Read more
Expand Down Expand Up @@ -123,13 +123,13 @@ const otherPosts = posts.slice(1, 5)
{post.data.categories && (
<Categories categories={post.data.categories} />
)}
<a href={new URL(import.meta.env.BASE_URL + 'blog/' + post.slug, Astro.url)}>
<a href={import.meta.env.BASE_URL + 'blog/' + post.slug}>
<div class="md:mt-1 text-gray-800 dark:text-gray-100 font-semibold text-xl">
{post.data.title}
</div>
</a>
<p class="block text-sm text-gray-600 dark:text-gray-300">
{post.data.publishDate?.toISOString().slice(0, 10)}
{post.data.publishDate?.toDateString()}
</p>
<p class="block md:hidden text-sm text-gray-600 dark:text-gray-300">
{post.data.description}
Expand Down
50 changes: 50 additions & 0 deletions src/components/nextprev.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
import type { CollectionEntry } from 'astro:content'
export interface Props {
base: string
prev: CollectionEntry<'blog'>
next: CollectionEntry<'blog'>
}
const { base, prev, next } = Astro.props
---

<dl class="mt-12 flex border-t border-purple-300 pt-6 dark:border-purple-700" >
{
prev && (
<div class="mr-auto text-left">
<dt class="font-display text-sm font-medium text-gray-800 dark:text-gray-200">
Prev
</dt>
<dd class="mt-1">
<a
class="text-base font-semibold text-purple-600 hover:text-pink-600 hover:bg-purple-200 dark:text-purple-300"
href={base + prev.slug}
>
<span aria-hidden="true">←</span>
{prev.data.title}
</a>
</dd>
</div>
)
}
{
next && (
<div class="ml-auto text-right">
<dt class="font-display text-sm font-medium text-gray-800 dark:text-gray-200">
Next
</dt>
<dd class="mt-1">
<a
class="text-base font-semibold text-purple-600 hover:text-pink-600 hover:bg-purple-200 dark:text-purple-300"
href={base + next.slug}
>
{next.data.title}
<span aria-hidden="true">→</span>
</a>
</dd>
</div>
)
}
</dl>
6 changes: 4 additions & 2 deletions src/components/paginatecontrol.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import type { CollectionEntry } from 'astro:content'
import type { Page } from 'astro'
export interface Props {
base: string
page: Page<CollectionEntry<'blog'>>
}
// const { id } = Astro.params
const { page } = Astro.props
const { base, page } = Astro.props
---

<div class="mt-4 flex items-center">
Expand Down Expand Up @@ -56,7 +57,7 @@ const { page } = Astro.props
{Array.from({ length: page.lastPage }, (_, index) => index + 1).map(
i => (
<a
href={import.meta.env.BASE_URL + 'blog/' + (i > 1 ? i : '')}
href={base + '/' + (i > 1 ? i : '')}
aria-current="page"
class:list={[
i == page.currentPage
Expand Down Expand Up @@ -89,4 +90,5 @@ const { page } = Astro.props
</div>
)
}
<p class="italic text-white ml-4">Articles {page.start + 1}-{page.end + 1} (total {page.total})</p>
</div>
6 changes: 0 additions & 6 deletions src/components/svgimg.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ const { src, ...attrs } = Astro.props
// ugly hack to circumvent astro issue with dynamic import
// https://github.com/withastro/astro/issues/3373
const images = import.meta.glob<string>('../svg/**/*', { import: 'default' })
// console.log(images)
// for (const path in images) {
// images[path]().then((image) => {
// console.log(path, image)
// })
// }
const image = await images[src || DefaultSVG]()
---

Expand Down
3 changes: 1 addition & 2 deletions src/content/blog/2022-08-21-sample-gallery-post.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ categories:
tags:
- mdx
- sample
extra: ['gallery']
---
import Gallery from '../../components/gallery.astro'

Expand All @@ -25,4 +24,4 @@ Apollo 11 at Barangaroo pays tribute to the diverse and under-appreciated heroes

Sydney Festival has commissioned artworks and participatory experiences, free for the public to explore around Barangaroo, as part of a city-wide commemoration of Apollo 11, the 1969 space flight that first landed people on the moon.

<Gallery folder="gallery" />
<Gallery folder="apollo11" />
25 changes: 25 additions & 0 deletions src/content/blog/2022-08-22-sample-gallery-post-markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: ../../layouts/blog.astro
title: Sample Gallery post (Markdown!)
description: Test post with a photo gallery and lightbox (using PhotoSwipe)
author: Chris Tham
publishDate: 2022-08-22T00:00:00.000Z
coverSVG: ../svg/undraw/undraw_portfolio.svg
socialImage: ../images/undraw/undraw_portfolio.png
gallery: apollo11
categories:
- information
tags:
- mdx
- sample
---

## Gallery with Lightbox

The following is a gallery of photos taken from the event Apollo 11 at Barangaroo, displayed in conjunction with the Sydney Festival 2019.

The collective adventure that is space travel has many more heroes than the two men who walked on the moon in 1969.

Apollo 11 at Barangaroo pays tribute to the diverse and under-appreciated heroes of space travel, from astronauts to mathematicians and beyond.

Sydney Festival has commissioned artworks and participatory experiences, free for the public to explore around Barangaroo, as part of a city-wide commemoration of Apollo 11, the 1969 space flight that first landed people on the moon.
Loading

0 comments on commit 2094d1b

Please sign in to comment.