This document describes the structure and purpose of the metainfo.toml
file used in the Article Management System. This file provides metadata for each article, enabling efficient indexing, retrieval, and content management within the application.
The metainfo.toml
file serves as a metadata descriptor for each article, facilitating the following:
- Identification of the article with a unique ID.
- Description of the article using fields like
title
,description
,tags
, andkeywords
. - Specification of the location of the article's Markdown content file.
- Provision of publication date and categorization details.
The application processes these files to index articles, load content dynamically, and deliver metadata and summaries via the API.
The metainfo.toml
file adheres to the TOML standard and includes the following key sections:
The [article]
section contains all metadata for the article. All fields are mandatory, and their types must conform to the specifications below.
Field | Type | Description | Example Value |
---|---|---|---|
id |
Integer | A unique identifier for the article. This must match the name of the directory containing the article. | 1 |
title |
String | The title of the article. | "Sample Article" |
description |
String | A brief description of the article. | "This is a sample description." |
markdown_path |
String (file path) | The relative path to the Markdown file containing the article's content, within the article directory. | "content.md" |
date |
Integer (YYYYMMDD) | The publication date of the article, formatted as an integer. | 20231201 |
tags |
Array of Strings | A list of tags associated with the article. | ["sample", "example"] |
keywords |
Array of Strings | A list of keywords related to the article, used for additional categorization or search optimization. | ["example", "documentation"] |
Below is an example of a valid metainfo.toml
file:
[article]
id = 1
title = "Sample Article"
description = "This article demonstrates the structure of metainfo.toml."
markdown_path = "content.md"
date = 20231201
tags = ["sample", "example", "documentation"]
keywords = ["tutorial", "metadata", "example"]
id
: Identifies the article as1
. This must match the directory name containing thismetainfo.toml
file.title
: Specifies the title as"Sample Article"
.description
: Provides a brief description of the article's purpose.markdown_path
: Indicates that the content is stored in a Markdown file namedcontent.md
within the directory.date
: Specifies the publication date as2023-12-01
(YYYYMMDD format).tags
: Associates the article with tags"sample"
,"example"
, and"documentation"
.keywords
: Adds additional keywords"tutorial"
,"metadata"
, and"example"
for enhanced searchability.
The application utilizes the metainfo.toml
file for the following purposes:
- During initialization, the application scans the
articles
directory formetainfo.toml
files to build an index. - The
id
field ensures uniqueness for each article.
- Fields like
title
,description
,date
,tags
, andkeywords
are used to generate summaries or lists of articles (e.g., for API endpoints).
- The
markdown_path
specifies the location of the article's Markdown file, which is then read and converted to HTML.
- The application validates each
metainfo.toml
file. Articles with invalid or missing metadata are excluded from the index.
The application enforces strict validation rules for the metainfo.toml
file:
- All fields (
id
,title
,description
,markdown_path
,date
,tags
, andkeywords
) are mandatory. - Missing fields result in warnings, and the article is excluded from the index.
- Each field must adhere to its specified type:
id
: Integertitle
,description
,markdown_path
: Stringsdate
: Integer inYYYYMMDD
formattags
,keywords
: Arrays of strings
- Type mismatches result in warnings, and the article is excluded.
- The
id
field must match the directory name. Mismatched IDs result in warnings and exclusion from the index.
- The file specified in
markdown_path
must exist. Missing files result in warnings and exclusion from the index.
- Log Message:
Metainfo file missing for article ID {id} in path {path}
- Cause: The directory lacks a
metainfo.toml
file. - Solution: Add a valid
metainfo.toml
file to the article directory.
- Log Message:
Missing or invalid '{field}' in metainfo.toml
- Cause: Required fields are missing or have incorrect types.
- Solution: Ensure all required fields are present and correctly formatted.
- Log Message:
ID mismatch in metainfo for article ID {id}: metainfo ID is {metainfo_id}
- Cause: The
id
field does not match the directory name. - Solution: Update the
id
field in themetainfo.toml
file to match the directory name.
- Log Message:
Markdown file missing for article ID {id}: {path}
- Cause: The Markdown file specified in
markdown_path
is missing. - Solution: Ensure the file exists in the specified location.
-
Unique Identifiers
- Use unique directory names and
id
values to prevent indexing conflicts.
- Use unique directory names and
-
Consistent Date Format
- Always use the
YYYYMMDD
format for thedate
field.
- Always use the
-
Comprehensive Keywords
- Include relevant and descriptive keywords to enhance searchability.
-
Validation Tools
- Use automated validation scripts or tools to verify the integrity of
metainfo.toml
files before deployment.
- Use automated validation scripts or tools to verify the integrity of
-
Structured Directories
- Maintain a clean and organized directory structure with one
metainfo.toml
and one content file per article.
- Maintain a clean and organized directory structure with one