Skip to content

Astro integration warns when default contentDir does not exist #74

Description

@rubenmarcus

Summary

The Astro integration logs a warning during build when the configured/default contentDir does not exist. For Astro projects that use CMS-backed content or page-derived output only, src/content may legitimately be absent, so this should probably be treated as an empty content set rather than a warning.

Repro

In an Astro project using aeo.js@0.0.14:

// astro.config.mjs
import { aeoAstroIntegration } from 'aeo.js/astro';

export default defineConfig({
  output: 'static',
  integrations: [
    aeoAstroIntegration({
      title: 'Quantum',
      description: '...',
      url: 'https://quantum.systems',
      generators: {
        llmsTxt: false,
        robotsTxt: false,
        sitemap: false,
      },
    }),
  ],
});

With no src/content directory, run:

npm run build

Actual

The build succeeds, but aeo.js logs:

Warning: Could not read directory src/content: Error: ENOENT: no such file or directory, scandir 'src/content'

Expected

If contentDir is missing, the Astro integration should silently treat it as empty content, consistent with other generator paths that already guard with existsSync(config.contentDir).

Likely Cause

In the built Astro integration, several paths already guard the directory scan:

const markdownFiles = existsSync(config.contentDir) ? collectMarkdownFiles(config.contentDir) : [];
const sections = existsSync(config.contentDir) ? collectAndConcatenateMarkdown(config.contentDir) : [];

But copyMarkdownFiles(config) calls copyRecursive(config.contentDir) unconditionally. The internal copyRecursive catches the missing directory and logs a warning.

A small guard in copyMarkdownFiles should avoid noisy warnings for valid Astro projects without src/content:

function copyMarkdownFiles(config) {
  const copiedFiles = [];
  if (!config.contentDir || !existsSync(config.contentDir)) return copiedFiles;
  // existing copyRecursive flow...
}

Environment

  • aeo.js: 0.0.14
  • Astro: 5.17.1
  • Output mode: static
  • Content source: Sanity/CMS, no local src/content directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions