build method

  1. @override
Future<Component> build(
  1. BuildContext context
)

Implementation

@override
Future<Component> build(BuildContext context) async {
  final file = File(routeInfo.filePath);
  if (!file.existsSync()) {
    return _buildErrorPage('Content file not found: ${routeInfo.filePath}');
  }

  final content = await file.readAsString();
  final effectiveConfig = config ?? const DuxtPageConfig();

  // Create a single-page loader for this content
  final loader = _SinglePageLoader(
    filePath: routeInfo.filePath,
    url: routeInfo.path,
    content: content,
    config: PageConfig(
      parsers: [MarkdownParser()],
      extensions: [
        HeadingAnchorsExtension(),
        TableOfContentsExtension(),
        ...effectiveConfig.extensions,
      ],
      components: effectiveConfig.components,
      layouts: effectiveConfig.layouts,
      theme: effectiveConfig.theme,
    ),
  );

  // Create and build the page manually (render() requires ContentApp context)
  final page = loader.createPage();
  page.parseFrontmatter();
  await page.loadData();
  return await page.build();
}