full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -37,6 +37,7 @@ const { fallback = 'animate' } = Astro.props;
import { init } from 'astro/virtual-modules/prefetch.js';
type Fallback = 'none' | 'animate' | 'swap';
let lastClickedElementLeavingWindow: EventTarget | null = null;
function getFallback(): Fallback {
const el = document.querySelector('[name="astro-view-transitions-fallback"]');
@@ -50,6 +51,13 @@ const { fallback = 'animate' } = Astro.props;
return el.dataset.astroReload !== undefined;
}
const leavesWindow = (ev: MouseEvent) =>
(ev.button && ev.button !== 0) || // left clicks only
ev.metaKey || // new tab (mac)
ev.ctrlKey || // new tab (windows)
ev.altKey || // download
ev.shiftKey; // new window
if (supportsViewTransitions || getFallback() !== 'none') {
if (import.meta.env.DEV && window.matchMedia('(prefers-reduced-motion)').matches) {
console.warn(
@@ -58,6 +66,9 @@ const { fallback = 'animate' } = Astro.props;
}
document.addEventListener('click', (ev) => {
let link = ev.target;
lastClickedElementLeavingWindow = leavesWindow(ev) ? link : null;
if (ev.composed) {
link = ev.composedPath()[0];
}
@@ -82,11 +93,7 @@ const { fallback = 'animate' } = Astro.props;
!link.href ||
(linkTarget && linkTarget !== '_self') ||
origin !== location.origin ||
ev.button !== 0 || // left clicks only
ev.metaKey || // new tab (mac)
ev.ctrlKey || // new tab (windows)
ev.altKey || // download
ev.shiftKey || // new window
lastClickedElementLeavingWindow ||
ev.defaultPrevented
) {
// No page transitions in these cases,
@@ -102,11 +109,15 @@ const { fallback = 'animate' } = Astro.props;
document.addEventListener('submit', (ev) => {
let el = ev.target as HTMLElement;
if (el.tagName !== 'FORM' || ev.defaultPrevented || isReloadEl(el)) {
const submitter = ev.submitter;
const clickedWithKeys = submitter && submitter === lastClickedElementLeavingWindow;
lastClickedElementLeavingWindow = null;
if (el.tagName !== 'FORM' || ev.defaultPrevented || isReloadEl(el) || clickedWithKeys) {
return;
}
const form = el as HTMLFormElement;
const submitter = ev.submitter;
const formData = new FormData(form, submitter);
// form.action and form.method can point to an <input name="action"> or <input name="method">
// in which case should fallback to the form attribute

View File

@@ -1,15 +1,9 @@
---
import type { ThemePresets } from '@astrojs/markdown-remark';
import type {
BuiltinLanguage,
LanguageRegistration,
ShikiTransformer,
SpecialLanguage,
ThemeRegistration,
ThemeRegistrationRaw,
} from 'shiki';
import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
import { bundledLanguages } from 'shiki/langs';
import { getCachedHighlighter } from '../dist/core/shiki.js';
import type { CodeLanguage } from '../dist/types/public';
import type { HTMLAttributes } from '../types';
interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
@@ -22,7 +16,7 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
*
* @default "plaintext"
*/
lang?: BuiltinLanguage | SpecialLanguage | LanguageRegistration;
lang?: CodeLanguage;
/**
* A metastring to pass to the highlighter.
* Allows passing information to transformers: https://shiki.style/guide/transformers#meta
@@ -111,13 +105,13 @@ const highlighter = await getCachedHighlighter({
],
theme,
themes,
defaultColor,
wrap,
transformers,
});
const html = await highlighter.highlight(code, typeof lang === 'string' ? lang : lang.name, {
const html = await highlighter.codeToHtml(code, typeof lang === 'string' ? lang : lang.name, {
defaultColor,
wrap,
inline,
transformers,
meta,
attributes: rest as any,
});

View File

@@ -21,8 +21,9 @@ const value = Astro.props[key];
font-size: 14px;
padding: 1rem 1.5rem;
background: white;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
'Open Sans', 'Helvetica Neue', sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
'Helvetica Neue', sans-serif;
}
.astro-debug-header,

34
node_modules/astro/components/Font.astro generated vendored Normal file
View File

@@ -0,0 +1,34 @@
---
import * as mod from 'virtual:astro:assets/fonts/internal';
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
// TODO: remove check when fonts are stabilized
const { fontsData } = mod;
if (!fontsData) {
throw new AstroError(AstroErrorData.ExperimentalFontsNotEnabled);
}
interface Props {
/** The `cssVariable` registered in your Astro configuration. */
cssVariable: import('astro:assets').FontFamily;
/** Whether it should output [preload links](https://web.dev/learn/performance/optimize-web-fonts#preload) or not. */
preload?: boolean;
}
const { cssVariable, preload = false } = Astro.props as Props;
const data = fontsData.get(cssVariable);
if (!data) {
throw new AstroError({
...AstroErrorData.FontFamilyNotFound,
message: AstroErrorData.FontFamilyNotFound.message(cssVariable),
});
}
---
{
preload &&
data.preloadData.map(({ url, type }) => (
<link rel="preload" href={url} as="font" type={`font/${type}`} crossorigin />
))
}
<style set:html={data.css}></style>

View File

@@ -1,5 +1,6 @@
---
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
import type { UnresolvedImageTransform } from '../dist/assets/types';
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
import type { HTMLAttributes } from '../types';
@@ -23,7 +24,16 @@ if (typeof props.height === 'string') {
props.height = parseInt(props.height);
}
const image = await getImage(props);
const layout = props.layout ?? imageConfig.layout ?? 'none';
if (layout !== 'none') {
// Apply defaults from imageConfig if not provided
props.layout ??= imageConfig.layout;
props.fit ??= imageConfig.objectFit ?? 'cover';
props.position ??= imageConfig.objectPosition ?? 'center';
}
const image = await getImage(props as UnresolvedImageTransform);
const additionalAttributes: HTMLAttributes<'img'> = {};
if (image.srcSet.values.length > 0) {
@@ -33,6 +43,9 @@ if (image.srcSet.values.length > 0) {
if (import.meta.env.DEV) {
additionalAttributes['data-image-component'] = 'true';
}
const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
---
<img src={image.src} {...additionalAttributes} {...image.attributes} />
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
<img src={image.src} {...attributes} class={className} />

View File

@@ -1,12 +1,16 @@
---
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
import * as mime from 'mrmime';
import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind';
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind.js';
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
import type {
GetImageResult,
ImageOutputFormat,
UnresolvedImageTransform,
} from '../dist/types/public/index.js';
import type { HTMLAttributes } from '../types';
type Props = (LocalImageProps | RemoteImageProps) & {
export type Props = (LocalImageProps | RemoteImageProps) & {
formats?: ImageOutputFormat[];
fallbackFormat?: ImageOutputFormat;
pictureAttributes?: HTMLAttributes<'picture'>;
@@ -37,8 +41,20 @@ if (scopedStyleClass) {
pictureAttributes.class = scopedStyleClass;
}
}
const layout = props.layout ?? imageConfig.layout ?? 'none';
const useResponsive = layout !== 'none';
if (useResponsive) {
// Apply defaults from imageConfig if not provided
props.layout ??= imageConfig.layout;
props.fit ??= imageConfig.objectFit ?? 'cover';
props.position ??= imageConfig.objectPosition ?? 'center';
}
for (const key in props) {
if (key.startsWith('data-astro-cid')) {
// @ts-expect-error This is for island props so they're not properly typed
pictureAttributes[key] = props[key];
}
}
@@ -53,7 +69,7 @@ const optimizedImages: GetImageResult[] = await Promise.all(
format: format,
widths: props.widths,
densities: props.densities,
}),
} as UnresolvedImageTransform),
),
);
@@ -71,7 +87,7 @@ const fallbackImage = await getImage({
format: resultFallbackFormat,
widths: props.widths,
densities: props.densities,
});
} as UnresolvedImageTransform);
const imgAdditionalAttributes: HTMLAttributes<'img'> = {};
const sourceAdditionalAttributes: HTMLAttributes<'source'> = {};
@@ -88,13 +104,18 @@ if (fallbackImage.srcSet.values.length > 0) {
if (import.meta.env.DEV) {
imgAdditionalAttributes['data-image-component'] = 'true';
}
const { class: className, ...attributes } = {
...imgAdditionalAttributes,
...fallbackImage.attributes,
};
---
<picture {...pictureAttributes}>
{
Object.entries(optimizedImages).map(([_, image]) => {
const srcsetAttribute =
props.densities || (!props.densities && !props.widths)
props.densities || (!props.densities && !props.widths && !useResponsive)
? `${image.src}${image.srcSet.values.length > 0 ? ', ' + image.srcSet.attribute : ''}`
: image.srcSet.attribute;
return (
@@ -106,5 +127,6 @@ if (import.meta.env.DEV) {
);
})
}
<img src={fallbackImage.src} {...imgAdditionalAttributes} {...fallbackImage.attributes} />
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
<img src={fallbackImage.src} {...attributes} class={className} />
</picture>

13
node_modules/astro/components/ResponsiveImage.astro generated vendored Normal file
View File

@@ -0,0 +1,13 @@
---
import type { LocalImageProps, RemoteImageProps } from 'astro:assets';
import Image from './Image.astro';
type Props = LocalImageProps | RemoteImageProps;
const { class: className, ...props } = Astro.props;
import './image.css';
---
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
<Image {...props} class={className} />

12
node_modules/astro/components/ResponsivePicture.astro generated vendored Normal file
View File

@@ -0,0 +1,12 @@
---
import { default as Picture, type Props as PictureProps } from './Picture.astro';
type Props = PictureProps;
const { class: className, ...props } = Astro.props;
import './image.css';
---
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
<Picture {...props} class={className} />

2
node_modules/astro/components/env.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/// <reference path="../client.d.ts" />
/// <reference path="../dev-only.d.ts" />

11
node_modules/astro/components/image.css generated vendored Normal file
View File

@@ -0,0 +1,11 @@
:where([data-astro-image]) {
object-fit: var(--fit);
object-position: var(--pos);
height: auto;
}
:where([data-astro-image='full-width']) {
width: 100%;
}
:where([data-astro-image='constrained']) {
max-width: 100%;
}

View File

@@ -1,5 +1,5 @@
// The `ts-ignore` comments here are necessary because we're importing this file inside the `astro:components`
// virtual module's types, which means that `tsc` will try to resolve these imports. Don't mind the editor errors.
// virtual module's types, which means that `tsc` will try to resolve these imports.
// @ts-ignore
export { default as Code } from './Code.astro';
// @ts-ignore