Merge branch 'main' into tinyglobby

This commit is contained in:
Ben McCann 2025-05-26 09:06:52 -07:00
commit d98d5b95cc
4 changed files with 6 additions and 9 deletions

View file

@ -480,7 +480,7 @@ Available document ids are:
export function toDocNavigationLink(
doc: DocMetadataBase,
options?: {sidebarItemLabel?: string | undefined},
options?: {sidebarItemLabel?: string},
): PropNavigationLink {
const {
title,

View file

@ -86,7 +86,7 @@ export const bytesToSize = (bytes) => {
const detectWebpSupport = () => {
if (ssr) return false;
const elem = document.createElement('canvas');
if (elem.getContext && elem.getContext('2d')) {
if (elem.getContext?.('2d')) {
// was able or not to get WebP representation
return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
} else {
@ -97,8 +97,7 @@ const detectWebpSupport = () => {
export const supportsWebp = detectWebpSupport();
const isWebp = (x) =>
x.format === 'webp' || (x.src && x.src.match(/\.webp($|\?.*)/i));
const isWebp = (x) => x.format === 'webp' || x.src?.match(/\.webp($|\?.*)/i);
// eslint-disable-next-line no-shadow
export const selectSrc = ({srcSet, maxImageWidth, supportsWebp}) => {

View file

@ -15,7 +15,7 @@ export type DocsVersionPersistence = 'localStorage' | 'none';
// TODO improve types, use unions
export type NavbarItem = {
type?: string | undefined;
type?: string;
items?: NavbarItem[];
label?: string;
position?: 'left' | 'right';

View file

@ -91,13 +91,11 @@ async function createTestSite() {
const siteThemePathPosix = posixPath(siteThemePath);
expect(tree(siteThemePathPosix)).toMatchSnapshot('theme dir tree');
const files = (await Globby(siteThemePathPosix))
.map((file) => path.posix.relative(siteThemePathPosix, file))
.sort();
const files = await Globby('**/*', {cwd: siteThemePath});
for (const file of files) {
const fileContent = await fs.readFile(
path.posix.join(siteThemePath, file),
path.join(siteThemePath, file),
'utf-8',
);
expect(fileContent).toMatchSnapshot(file);