Enhancing Content Platform Support in Devlog-ist/landing
Introduction
The devlog-ist/landing project is evolving to support multi-platform content. This post details the addition of a platform discriminator, allowing content to be tailored for different platforms like portfolio sites, LinkedIn, and Dev.to. This enhancement ensures that examples and prompts are appropriately styled and presented for their intended audience.
Content Platform Enumeration
A new ContentPlatform enum has been introduced to differentiate content examples and prompts by platform. This enum includes values for portfolio, linkedin, and devto. All existing records default to the portfolio platform to maintain backward compatibility.
Platform-Specific Styling
To accommodate the unique styling requirements of each platform, LinkedIn-specific style selectors have been added to the PostGenerator, bulk actions, and generation jobs. This ensures that content generated for LinkedIn adheres to its formatting guidelines.
Random Style Resolution
The RandomStyleResolver has been updated to support both portfolio and linkedin platforms. This allows the system to randomly select appropriate styles based on the target platform.
// Example of ContentPlatform enum
enum ContentPlatform
{
case PORTFOLIO;
case LINKEDIN;
case DEVTO;
}
// Usage example
$platform = ContentPlatform::LINKEDIN;
switch ($platform) {
case ContentPlatform::LINKEDIN:
// Apply LinkedIn-specific styling
break;
case ContentPlatform::PORTFOLIO:
// Apply portfolio styling
break;
case ContentPlatform::DEVTO:
// Apply Dev.to styling
break;
}
This code snippet illustrates how the ContentPlatform enum can be used to apply platform-specific styling to content. The switch statement allows for different styling logic based on the selected platform.
Seeder Migration and Translations
A seeder migration has been included with three LinkedIn example posts to populate the database with platform-specific content. Badge colors in Filament resources have also been updated to reflect the different platforms. Translations have been added across all four locales to ensure consistency and clarity.
Conclusion
The addition of platform support enhances the flexibility and adaptability of the devlog-ist/landing project. By discriminating content by platform, the system can ensure that examples and prompts are appropriately styled and presented for their intended audience. Developers can now leverage the ContentPlatform enum to create tailored content experiences for different platforms.