Compare commits
6 Commits
3.11.0
...
93a53cab3d
| Author | SHA1 | Date | |
|---|---|---|---|
| 93a53cab3d | |||
| a6c889f76a | |||
| 9319228ef6 | |||
| 148fe8eeff | |||
| 8d1d47dc4f | |||
| 7b8fb380d4 |
17
.pre-commit-config.yaml
Normal file
17
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: check-merge-conflict
|
||||
- id: check-json
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v4.0.0-alpha.11
|
||||
hooks:
|
||||
- id: prettier
|
||||
types_or: [javascript, typescript, css, scss, html, json, yaml, markdown]
|
||||
additional_dependencies:
|
||||
- prettier
|
||||
- prettier-plugin-astro
|
||||
- prettier-plugin-tailwindcss
|
||||
3
bun.lock
3
bun.lock
@@ -49,6 +49,7 @@
|
||||
"@tailwindcss/forms": "^0.5.11",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@types/photoswipe": "^5.2.5",
|
||||
"eslint": "^10.0.3",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-astro": "^1.6.0",
|
||||
@@ -849,6 +850,8 @@
|
||||
|
||||
"@types/parse-json": ["@types/parse-json@4.0.2", "", {}, "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw=="],
|
||||
|
||||
"@types/photoswipe": ["@types/photoswipe@5.2.5", "", { "dependencies": { "photoswipe": "*" } }, "sha512-1x8LpPy/a9cMdy8AgSQZOgVN4b1BEAGGLFjkg20RAUbv2vzovH8U2iSZmjlM6Gd6oY/BI+Thdph0kOlxEZHskQ=="],
|
||||
|
||||
"@types/react": ["@types/react@19.2.14", "", { "dependencies": { "csstype": "3.2.3" } }, "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w=="],
|
||||
|
||||
"@types/react-dom": ["@types/react-dom@19.1.7", "", { "peerDependencies": { "@types/react": "19.2.14" } }, "sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw=="],
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"@tailwindcss/forms": "^0.5.11",
|
||||
"@tailwindcss/typography": "^0.5.19",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@types/photoswipe": "^5.2.5",
|
||||
"eslint": "^10.0.3",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-astro": "^1.6.0",
|
||||
|
||||
@@ -43,13 +43,12 @@
|
||||
</button>
|
||||
|
||||
<script is:inline>
|
||||
const applyTheme = () => {
|
||||
(() => {
|
||||
const isDark =
|
||||
localStorage.theme === 'dark' ||
|
||||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
document.documentElement.classList.toggle('dark', isDark);
|
||||
};
|
||||
applyTheme();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -82,7 +82,7 @@ const images = await Promise.all(imagesData.map(async (img) => ({
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.addEventListener('astro:page-load', () => {
|
||||
function initHeroImage() {
|
||||
const container = document.getElementById('hero-image-container');
|
||||
if (container) {
|
||||
const images = container.querySelectorAll('.hero-image');
|
||||
@@ -96,5 +96,13 @@ const images = await Promise.all(imagesData.map(async (img) => ({
|
||||
images[randomIndex].classList.add('flex');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initHeroImage);
|
||||
} else {
|
||||
initHeroImage();
|
||||
}
|
||||
if ((window as any).swup) {
|
||||
(window as any).swup.hooks.on('page:view', initHeroImage);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -120,6 +120,48 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import PhotoSwipeLightbox from 'photoswipe/lightbox';
|
||||
import PhotoSwipe from "photoswipe";
|
||||
|
||||
let lightbox: PhotoSwipeLightbox | null = null;
|
||||
|
||||
function initPhotoSwipe() {
|
||||
const links = document.querySelectorAll<HTMLAnchorElement>('a.pswp-link');
|
||||
|
||||
links.forEach((link) => {
|
||||
const img = link.querySelector('img');
|
||||
if (img) {
|
||||
const applyDimensions = () => {
|
||||
link.dataset.pswpWidth = (img.naturalWidth || 1920).toString();
|
||||
link.dataset.pswpHeight = (img.naturalHeight || 1080).toString();
|
||||
};
|
||||
if (img.complete) {
|
||||
applyDimensions();
|
||||
} else {
|
||||
img.addEventListener('load', applyDimensions);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (lightbox) {
|
||||
lightbox.destroy();
|
||||
}
|
||||
|
||||
lightbox = new PhotoSwipeLightbox({
|
||||
gallery: '.prose',
|
||||
children: 'a.pswp-link',
|
||||
pswpModule: PhotoSwipe,
|
||||
allowPanToNext: true,
|
||||
});
|
||||
|
||||
lightbox.init();
|
||||
}
|
||||
|
||||
initPhotoSwipe();
|
||||
document.addEventListener('swup:page:view', initPhotoSwipe);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const animateContent = () => {
|
||||
const smoothReveal = document.querySelectorAll('.smooth-reveal');
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
---
|
||||
|
||||
import { Image } from 'astro:assets';
|
||||
import { marked } from 'marked';
|
||||
import markedShiki from 'marked-shiki';
|
||||
import { createHighlighter } from 'shiki';
|
||||
import { readItems, readSingleton } from '@directus/sdk';
|
||||
import 'photoswipe/style.css';
|
||||
import "photoswipe/style.css";
|
||||
|
||||
import type { Post } from '@/lib/directusTypes'
|
||||
|
||||
import SocialShareButton from '@components/buttons/SocialShareButton.astro';
|
||||
import PostMetadataSnippet from '@/components/snippets/PostMetadataSnippet.astro';
|
||||
@@ -13,39 +14,51 @@ import BaseLayout from '@layouts/BaseLayout.astro';
|
||||
import directus from '@lib/directus';
|
||||
import { getDirectusImageURL } from '@/support/url';
|
||||
|
||||
const post = Astro.props;
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await directus.request(readItems('posts', {
|
||||
fields: ['*', { category: ['*'] }],
|
||||
}));
|
||||
return posts.map((post) => ({
|
||||
const globalData = await directus.request(readSingleton('site_global'));
|
||||
const highlighter = await createHighlighter({
|
||||
themes: ['github-light', 'github-dark'],
|
||||
langs: ['typescript', 'python', 'css', 'html', 'yaml', 'bash', 'json'],
|
||||
});
|
||||
const renderer = {
|
||||
image({ href, title, text }: { href: string; title: string | null; text: string }) {
|
||||
return `
|
||||
<a
|
||||
href="${href}"
|
||||
class="pswp-link"
|
||||
data-pswp-src="${href}"
|
||||
target="_blank"
|
||||
>
|
||||
<img src="${href}" alt="${text}" title="${title || ''}" loading="lazy" />
|
||||
</a>
|
||||
`;
|
||||
},
|
||||
};
|
||||
marked.use({ renderer });
|
||||
marked.use(markedShiki({
|
||||
highlight(code, lang) {
|
||||
return highlighter.codeToHtml(code, {
|
||||
lang: lang || 'plaintext',
|
||||
themes: { light: 'github-light', dark: 'github-dark' },
|
||||
defaultColor: false,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
return posts.map((post: Post) => ({
|
||||
params: { slug: post.slug },
|
||||
props: post,
|
||||
props: {
|
||||
post,
|
||||
global: globalData,
|
||||
content: marked.parse(post.content || ''),
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
const global = await directus.request(readSingleton('site_global'));
|
||||
|
||||
const highlighter = await createHighlighter({
|
||||
themes: ['github-light', 'github-dark'],
|
||||
langs: ['typescript', 'python', 'css', 'html', 'yaml', 'bash', 'json'],
|
||||
});
|
||||
|
||||
marked.use(markedShiki({
|
||||
highlight(code, lang) {
|
||||
return highlighter.codeToHtml(code, {
|
||||
lang: lang || 'plaintext',
|
||||
themes: {
|
||||
light: 'github-light',
|
||||
dark: 'github-dark',
|
||||
},
|
||||
defaultColor: false,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
const content = marked.parse(post.content || '');
|
||||
const { post, global, content } = Astro.props;
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
@@ -65,7 +78,7 @@ const content = marked.parse(post.content || '');
|
||||
name: global.name,
|
||||
description: global.about,
|
||||
},
|
||||
image: [],
|
||||
image: [getDirectusImageURL(post.image)],
|
||||
headline: post.title,
|
||||
datePublished: post.published_date,
|
||||
dateModified: post.updated_date,
|
||||
@@ -85,7 +98,7 @@ const content = marked.parse(post.content || '');
|
||||
<Image
|
||||
class="rounded-2xl sm:rounded-b-none w-full max-h-150 object-cover"
|
||||
src={getDirectusImageURL(post.image)}
|
||||
alt={post.image_alt}
|
||||
alt={post.image_alt || post.title}
|
||||
draggable="false"
|
||||
format="webp"
|
||||
loading="lazy"
|
||||
@@ -110,13 +123,15 @@ const content = marked.parse(post.content || '');
|
||||
</article>
|
||||
|
||||
<div class="grid sm:flex sm:items-center sm:justify-between gap-y-5 sm:gap-y-0 max-w-5xl mx-auto mt-10 md:mt-14">
|
||||
<div class="flex flex-wrap sm:flex-nowrap sm:items-center gap-x-2 gap-y-1 sm:gap-y-0">
|
||||
{post.tags.map((tag: string) => (
|
||||
<span class="inline-flex items-center button-base bg-cobalt dark:bg-turquoise text-neutral-100 text-xs font-bold rounded-lg gap-x-1.5 px-3 py-1.5">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
{post.tags && post.tags.length > 0 && (
|
||||
<div class="flex flex-wrap sm:flex-nowrap sm:items-center gap-x-2 gap-y-1 sm:gap-y-0">
|
||||
{post.tags.map((tag: string) => (
|
||||
<span class="inline-flex items-center button-base bg-cobalt dark:bg-turquoise text-neutral-100 text-xs font-bold rounded-lg gap-x-1.5 px-3 py-1.5">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<SocialShareButton pageTitle={post.title}/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,39 +154,3 @@ const content = marked.parse(post.content || '');
|
||||
</style>
|
||||
|
||||
</BaseLayout>
|
||||
|
||||
<script>
|
||||
import PhotoSwipeLightbox from 'photoswipe/lightbox';
|
||||
const prose = document.querySelector('.prose');
|
||||
if (prose) {
|
||||
const images = prose.querySelectorAll('img');
|
||||
images.forEach((img) => {
|
||||
if (img.closest('a')) return;
|
||||
const link = document.createElement('a');
|
||||
link.href = img.src;
|
||||
link.dataset.pswpSrc = img.src;
|
||||
link.dataset.pswpWidth = img.naturalWidth.toString();
|
||||
link.dataset.pswpHeight = img.naturalHeight.toString();
|
||||
link.target = '_blank';
|
||||
link.classList.add('pswp-link');
|
||||
|
||||
img.parentNode?.insertBefore(link, img);
|
||||
link.appendChild(img);
|
||||
|
||||
if (!img.complete) {
|
||||
img.onload = () => {
|
||||
link.dataset.pswpWidth = img.naturalWidth.toString();
|
||||
link.dataset.pswpHeight = img.naturalHeight.toString();
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const lightbox = new PhotoSwipeLightbox({
|
||||
gallery: prose,
|
||||
children: 'a.pswp-link',
|
||||
pswpModule: () => import('photoswipe'),
|
||||
});
|
||||
|
||||
lightbox.init();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -11,10 +11,6 @@ import GiteaSection from '@components/sections/GiteaSection.astro';
|
||||
import BaseLayout from '@layouts/BaseLayout.astro';
|
||||
import directus from '@lib/directus';
|
||||
|
||||
// Weather section server island does not seem to load under Astro 6, setting the whole page for server
|
||||
// side rendering for now.
|
||||
export const prerender = false
|
||||
|
||||
const global = await directus.request(readSingleton('site_global'));
|
||||
const weather = await directus.request(readSingleton('site_weather'));
|
||||
const posts = await directus.request(
|
||||
|
||||
@@ -4,20 +4,21 @@
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "src",
|
||||
"baseUrl": ".",
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "react",
|
||||
"types": ["astro/client"],
|
||||
"paths": {
|
||||
"@/*": ["*"],
|
||||
"@/*": ["src/*"],
|
||||
"@src/*": ["src/*"],
|
||||
"@lib/*": ["lib/*"],
|
||||
"@components/*": ["components/*"],
|
||||
"@content/*": ["content/*"],
|
||||
"@layouts/*": ["layouts/*"],
|
||||
"@styles/*": ["styles/*"],
|
||||
"@pages/*": ["pages/*"],
|
||||
"@support/*": ["support/*"],
|
||||
"@images/*": ["images/*"]
|
||||
"@lib/*": ["src/lib/*"],
|
||||
"@components/*": ["src/components/*"],
|
||||
"@content/*": ["src/content/*"],
|
||||
"@layouts/*": ["src/layouts/*"],
|
||||
"@styles/*": ["src/styles/*"],
|
||||
"@pages/*": ["src/pages/*"],
|
||||
"@support/*": ["src/support/*"],
|
||||
"@images/*": ["src/images/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user