How cubyverse/ig2hugo works
Project Components
• Command‑Line Interface (CLI): This is the entry point (main.go) that parses command‑line parameters (token, user, output directory) and orchestrates the workflow.
• Instagram API Client: A module or function responsible for constructing and sending requests to the Instagram Graph API with the provided Access Token, and retrieving the post data.
• Data Converter/Processor: The component that takes the raw Instagram post data and extracts the Instagram shortcode (from the permalink) along with necessary metadata (date, tags, etc.) to format the Markdown file.
• Markdown File Generator: A component that writes out the converted content as a Markdown file in a specific output directory, following Hugo’s expected format.
• CI/CD Pipeline (GitHub Actions): The .github/workflows/release.yml file indicates there’s an automated build/release process. This represents an external automation component of the system.
• External Dependencies:
◦ Instagram Graph API: An external service that provides data.
◦ Hugo Website: While not directly part of the conversion tool, the output is intended for integration with a Hugo-based website.
Relationships & Data Flow
• The CLI component accepts user parameters and passes them to the Instagram API Client.
• The API Client communicates with the Instagram Graph API, receiving data back.
• The converter takes the API data, processes and extracts the necessary shortcode and metadata.
• The Markdown Generator then writes out the structured Markdown files in the destination folder (default "content/instagram").
• Optionally, a user would integrate these Markdown files into their Hugo site.
• The CI/CD pipeline automates build and release processes, ensuring that the latest version of the tool is distributed.
Architectural Patterns and Design
• The project follows a modular design even though it’s contained within a single source file. Each “phase” (input parsing, API communication, conversion, and file output) can be viewed as discrete layers.
• The system emphasizes separation of concerns: the input (CLI) is decoupled from processing (converter) and output (file writing).
• Use of external environment configurations (API tokens and user IDs) makes it flexible and integrates with an external API, following best practices for external service integration.