metadata_gen

Function extract_and_prepare_metadata

Source
pub fn extract_and_prepare_metadata(content: &str) -> MetadataResult
Expand description

Extracts metadata from the content, generates keywords based on the metadata, and prepares meta tag groups.

This function performs three key tasks:

  1. It extracts metadata from the front matter of the content.
  2. It generates keywords based on this metadata.
  3. It generates various meta tags required for the page.

§Arguments

  • content - A string slice representing the content from which to extract metadata.

§Returns

Returns a Result containing a tuple with:

  • HashMap<String, String>: Extracted metadata
  • Vec<String>: A list of keywords
  • MetaTagGroups: A structure containing various meta tags

§Errors

This function will return a MetadataError if metadata extraction or processing fails.

§Example

use metadata_gen::extract_and_prepare_metadata;

let content = r#"---
title: My Page
description: A sample page
---
"#;

let result = extract_and_prepare_metadata(content);
assert!(result.is_ok());