refactor: move plain md to content entry type

This commit is contained in:
bholmesdev 2023-02-09 12:13:38 -05:00
parent 3ba5253ff7
commit e4d38c3498
3 changed files with 4 additions and 9 deletions

View file

@ -1,4 +1,3 @@
export const defaultContentEntryExts = ['.md'] as const;
export const PROPAGATED_ASSET_FLAG = 'astroPropagatedAssets'; export const PROPAGATED_ASSET_FLAG = 'astroPropagatedAssets';
export const CONTENT_FLAG = 'astroContent'; export const CONTENT_FLAG = 'astroContent';
export const VIRTUAL_MODULE_ID = 'astro:content'; export const VIRTUAL_MODULE_ID = 'astro:content';

View file

@ -7,7 +7,7 @@ import { ErrorPayload as ViteErrorPayload, normalizePath, ViteDevServer } from '
import { z } from 'zod'; import { z } from 'zod';
import { AstroConfig, AstroSettings } from '../@types/astro.js'; import { AstroConfig, AstroSettings } from '../@types/astro.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { CONTENT_TYPES_FILE, defaultContentEntryExts } from './consts.js'; import { CONTENT_TYPES_FILE } from './consts.js';
export const collectionConfigParser = z.object({ export const collectionConfigParser = z.object({
schema: z.any().optional(), schema: z.any().optional(),
@ -119,11 +119,7 @@ export async function getEntryData(
} }
export function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>) { export function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>) {
return [ return settings.contentEntryTypes.map((t) => t.extensions).flat();
// TODO: roll defaults into settings
...defaultContentEntryExts,
...settings.contentEntryTypes.map((t) => t.extensions).flat(),
];
} }
export class NoCollectionError extends Error {} export class NoCollectionError extends Error {}

View file

@ -6,6 +6,7 @@ import jsxRenderer from '../../jsx/renderer.js';
import { createDefaultDevConfig } from './config.js'; import { createDefaultDevConfig } from './config.js';
import { AstroTimer } from './timer.js'; import { AstroTimer } from './timer.js';
import { loadTSConfig } from './tsconfig.js'; import { loadTSConfig } from './tsconfig.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
export function createBaseSettings(config: AstroConfig): AstroSettings { export function createBaseSettings(config: AstroConfig): AstroSettings {
return { return {
@ -16,8 +17,7 @@ export function createBaseSettings(config: AstroConfig): AstroSettings {
adapter: undefined, adapter: undefined,
injectedRoutes: [], injectedRoutes: [],
pageExtensions: ['.astro', '.html', ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS], pageExtensions: ['.astro', '.html', ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
/** TODO: default Markdown entry type */ contentEntryTypes: [markdownContentEntryType],
contentEntryTypes: [],
renderers: [jsxRenderer], renderers: [jsxRenderer],
scripts: [], scripts: [],
watchFiles: [], watchFiles: [],