[ci] format
This commit is contained in:
parent
2511d58d58
commit
c464bf258f
6 changed files with 14 additions and 12 deletions
|
@ -10,13 +10,13 @@ import { info, warn, type LogOptions } from '../core/logger/core.js';
|
||||||
import { isRelativePath } from '../core/path.js';
|
import { isRelativePath } from '../core/path.js';
|
||||||
import { CONTENT_TYPES_FILE } from './consts.js';
|
import { CONTENT_TYPES_FILE } from './consts.js';
|
||||||
import {
|
import {
|
||||||
NoCollectionError,
|
|
||||||
getContentEntryExts,
|
getContentEntryExts,
|
||||||
getContentPaths,
|
getContentPaths,
|
||||||
getEntryInfo,
|
getEntryInfo,
|
||||||
getEntrySlug,
|
getEntrySlug,
|
||||||
getEntryType,
|
getEntryType,
|
||||||
loadContentConfig,
|
loadContentConfig,
|
||||||
|
NoCollectionError,
|
||||||
parseFrontmatter,
|
parseFrontmatter,
|
||||||
type ContentConfig,
|
type ContentConfig,
|
||||||
type ContentObservable,
|
type ContentObservable,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import fsMod from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import type { PluginContext } from 'rollup';
|
import type { PluginContext } from 'rollup';
|
||||||
import { normalizePath, type ViteDevServer, type ErrorPayload as ViteErrorPayload } from 'vite';
|
import { normalizePath, type ErrorPayload as ViteErrorPayload, type ViteDevServer } from 'vite';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import type { AstroConfig, AstroSettings, ImageInputFormat } from '../@types/astro.js';
|
import type { AstroConfig, AstroSettings, ImageInputFormat } from '../@types/astro.js';
|
||||||
import { VALID_INPUT_FORMATS } from '../assets/consts.js';
|
import { VALID_INPUT_FORMATS } from '../assets/consts.js';
|
||||||
|
|
|
@ -10,7 +10,6 @@ import { AstroError } from '../core/errors/errors.js';
|
||||||
import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js';
|
import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js';
|
||||||
import { CONTENT_FLAG } from './consts.js';
|
import { CONTENT_FLAG } from './consts.js';
|
||||||
import {
|
import {
|
||||||
NoCollectionError,
|
|
||||||
getContentEntryExts,
|
getContentEntryExts,
|
||||||
getContentPaths,
|
getContentPaths,
|
||||||
getEntryData,
|
getEntryData,
|
||||||
|
@ -18,6 +17,7 @@ import {
|
||||||
getEntrySlug,
|
getEntrySlug,
|
||||||
getEntryType,
|
getEntryType,
|
||||||
globalContentConfigObserver,
|
globalContentConfigObserver,
|
||||||
|
NoCollectionError,
|
||||||
type ContentConfig,
|
type ContentConfig,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,9 @@ export async function getRemarkPlugins(
|
||||||
mdxOptions: MdxOptions,
|
mdxOptions: MdxOptions,
|
||||||
config: AstroConfig
|
config: AstroConfig
|
||||||
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
): Promise<MdxRollupPluginOptions['remarkPlugins']> {
|
||||||
let remarkPlugins: PluggableList = [...(config.experimental.assets ? [remarkCollectImages, remarkImageToComponent] : [])];
|
let remarkPlugins: PluggableList = [
|
||||||
|
...(config.experimental.assets ? [remarkCollectImages, remarkImageToComponent] : []),
|
||||||
|
];
|
||||||
|
|
||||||
if (!isPerformanceBenchmark) {
|
if (!isPerformanceBenchmark) {
|
||||||
if (mdxOptions.gfm) {
|
if (mdxOptions.gfm) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { MarkdownVFile } from '@astrojs/markdown-remark';
|
import type { MarkdownVFile } from '@astrojs/markdown-remark';
|
||||||
import { type Image, type Parent } from 'mdast';
|
import { type Image, type Parent } from 'mdast';
|
||||||
import type { MdxJsxFlowElement, MdxjsEsm } from 'mdast-util-mdx';
|
import type { MdxjsEsm, MdxJsxFlowElement } from 'mdast-util-mdx';
|
||||||
import { visit } from 'unist-util-visit';
|
import { visit } from 'unist-util-visit';
|
||||||
import { jsToTreeNode } from './utils.js';
|
import { jsToTreeNode } from './utils.js';
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,15 @@ import type { MarkdownVFile } from './types';
|
||||||
|
|
||||||
export function remarkCollectImages() {
|
export function remarkCollectImages() {
|
||||||
return function (tree: any, vfile: MarkdownVFile) {
|
return function (tree: any, vfile: MarkdownVFile) {
|
||||||
if (typeof vfile?.path !== 'string') return;
|
if (typeof vfile?.path !== 'string') return;
|
||||||
|
|
||||||
const imagePaths = new Set<string>();
|
const imagePaths = new Set<string>();
|
||||||
visit(tree, 'image', (node: Image) => {
|
visit(tree, 'image', (node: Image) => {
|
||||||
if (shouldOptimizeImage(node.url)) imagePaths.add(node.url);
|
if (shouldOptimizeImage(node.url)) imagePaths.add(node.url);
|
||||||
});
|
});
|
||||||
|
|
||||||
vfile.data.imagePaths = imagePaths;
|
vfile.data.imagePaths = imagePaths;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldOptimizeImage(src: string) {
|
function shouldOptimizeImage(src: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue