Compare commits
4 Commits
4ccbc9d9a8
...
525422105c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
525422105c | ||
|
|
a0473094cf | ||
|
|
36004bddb0 | ||
|
|
89bbbf5595 |
@@ -7,7 +7,9 @@ import graphql from '@rollup/plugin-graphql';
|
|||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [preact()],
|
integrations: [preact()],
|
||||||
|
image: {
|
||||||
|
domains: ['development.directus.itsfinniii.com']
|
||||||
|
},
|
||||||
vite: {
|
vite: {
|
||||||
plugins: [tailwindcss(), graphql()]
|
plugins: [tailwindcss(), graphql()]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { getAllPaginatedBlogs } from '@/content/blogs/blogs';
|
import { getAllPaginatedBlogs } from '@/content/blogs/blogs';
|
||||||
import { getSettings } from '@/content/settings/settings';
|
import { getSettings } from '@/content/settings/settings';
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { markdownToHtml } from '@/lib/markdown';
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
import { getBlogRoute } from '@/lib/routing';
|
import { getBlogRoute } from '@/lib/routing';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
@@ -30,14 +30,17 @@ const blogs = await getAllPaginatedBlogs(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div class="grid grid-cols-2 gap-6">
|
||||||
{ blogs.map((blog) => (
|
{ blogs.map((blog) => {
|
||||||
|
const imageSize = getImageSize(blog.searchEngine.thumbnail.width, blog.searchEngine.thumbnail.height, 0.5);
|
||||||
|
|
||||||
|
return (
|
||||||
<a href={getBlogRoute(settings.blog, blog)} class={`flex flex-col gap-2`}>
|
<a href={getBlogRoute(settings.blog, blog)} class={`flex flex-col gap-2`}>
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
||||||
alt={blog.title}
|
alt={blog.title}
|
||||||
class="flex rounded-2xl shadow-md w-full"
|
class="flex rounded-2xl shadow-md w-full"
|
||||||
width={600}
|
width={imageSize.width}
|
||||||
height={315}
|
height={imageSize.height}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<h4 class="font-semibold text-[28px]">{blog.title}</h4>
|
<h4 class="font-semibold text-[28px]">{blog.title}</h4>
|
||||||
@@ -47,6 +50,8 @@ const blogs = await getAllPaginatedBlogs(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
)) }
|
)
|
||||||
|
|
||||||
|
}) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { markdownToHtml } from '@/lib/markdown';
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
import { getTypographyClasses } from '@/styles/markdownClasses';
|
import { getTypographyClasses } from '@/styles/markdownClasses';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
@@ -10,6 +10,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { blog } = Astro.props;
|
const { blog } = Astro.props;
|
||||||
|
|
||||||
|
const imageSize = getImageSize(blog.searchEngine.thumbnail.width, blog.searchEngine.thumbnail.height, 1);
|
||||||
---
|
---
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -29,8 +31,8 @@ const { blog } = Astro.props;
|
|||||||
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
||||||
width="1200"
|
width={imageSize.width}
|
||||||
height="630"
|
height={imageSize.height}
|
||||||
alt={blog.title}
|
alt={blog.title}
|
||||||
class="rounded-2xl"
|
class="rounded-2xl"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { markdownToHtml } from '@/lib/markdown';
|
|||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
import { getProjectRoute } from '@/lib/routing';
|
import { getProjectRoute } from '@/lib/routing';
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
|
import { promise } from 'astro:schema';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
page: ProjectIndex;
|
page: ProjectIndex;
|
||||||
@@ -30,14 +31,17 @@ const projects = await getAllPaginatedProjects(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div class="grid grid-cols-2 gap-6">
|
||||||
{ projects.map((project) => (
|
{ projects.map((project) => {
|
||||||
|
const imageSize = getImageSize(project.searchEngine.thumbnail.width, project.searchEngine.thumbnail.height, 0.5);
|
||||||
|
|
||||||
|
return (
|
||||||
<a href={getProjectRoute(settings.project, project)} class={`flex flex-col gap-2`}>
|
<a href={getProjectRoute(settings.project, project)} class={`flex flex-col gap-2`}>
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(project.searchEngine.thumbnail.url)}
|
src={getImageUrl(project.searchEngine.thumbnail.url)}
|
||||||
alt={project.title}
|
alt={project.title}
|
||||||
class="flex rounded-2xl shadow-md w-full"
|
class="flex rounded-2xl shadow-md w-full"
|
||||||
width={600}
|
width={imageSize.width}
|
||||||
height={315}
|
height={imageSize.height}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<h4 class="font-semibold text-[28px]">{project.title}</h4>
|
<h4 class="font-semibold text-[28px]">{project.title}</h4>
|
||||||
@@ -47,6 +51,7 @@ const projects = await getAllPaginatedProjects(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
)) }
|
)
|
||||||
|
}) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { markdownToHtml } from '@/lib/markdown';
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
import { getTypographyClasses } from '@/styles/markdownClasses';
|
import { getTypographyClasses } from '@/styles/markdownClasses';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
@@ -10,6 +10,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { project } = Astro.props;
|
const { project } = Astro.props;
|
||||||
|
|
||||||
|
const imageSize = getImageSize(project.searchEngine.thumbnail.width, project.searchEngine.thumbnail.height, 1);
|
||||||
---
|
---
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -29,8 +31,8 @@ const { project } = Astro.props;
|
|||||||
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(project.searchEngine.thumbnail.url)}
|
src={getImageUrl(project.searchEngine.thumbnail.url)}
|
||||||
width="1200"
|
width={imageSize.width}
|
||||||
height="630"
|
height={imageSize.height}
|
||||||
alt={project.title}
|
alt={project.title}
|
||||||
class="rounded-2xl"
|
class="rounded-2xl"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export function getImageSize(width: number, height: number, targetMegapixels: nu
|
|||||||
const originalPixels = width * height;
|
const originalPixels = width * height;
|
||||||
const targetPixels = targetMegapixels * 1000 * 1000;
|
const targetPixels = targetMegapixels * 1000 * 1000;
|
||||||
|
|
||||||
if (originalPixels >= targetPixels) {
|
if (originalPixels <= targetPixels) {
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
|
|||||||
Reference in New Issue
Block a user