larablog 0.1.0

Markdown blogs for Laravel Rust in several languages, where every language has its own URL.
Documentation
//! Markdown blogs for Laravel Rust in several languages, where **every language has its own URL**.
//!
//! One folder per post, one file per language. Each file declares its own slug, so the English post
//! lives at `/blog/chat-moderation-games` and the Spanish one at
//! `/es/blog/moderacion-chat-videojuegos`, and each page knows the other: hreflang, a language
//! switcher, the sitemap and a link shared in the wrong language all just work.
//!
//! ```ignore
//! Application::configure().with_providers(|providers| {
//!     providers.add(LarablogServiceProvider::new().routes("blog"));
//! })
//! ```
//!
//! It is the port of the PHP package [`edulazaro/larablog`](https://github.com/edulazaro/larablog)
//! to Laravel Rust 0.1 (beta), and its API follows the framework's changes until 1.0.

pub mod author;
pub mod blog;
#[cfg(feature = "cards")]
pub mod cards;
pub mod category;
pub mod conditionals;
pub mod config;
pub mod console;
pub mod error;
pub mod feed;
pub mod http;
pub mod index;
pub mod larablog;
pub mod markdown;
pub mod post;
pub mod provider;
pub mod routes;
pub mod support;
pub mod views;
pub mod yaml;

use laravel::container::Inject;

pub use author::Author;
pub use blog::{Blog, Pagination, SitemapEntry, Tag, flush, scoped};
pub use category::Category;
pub use conditionals::Condition;
pub use config::{
    CacheSettings, CardSettings, CollectionConfig, FeedSettings, HtmlInput, LarablogConfig, Localized,
    MarkdownSettings, Segments, Views,
};
pub use error::Error;
pub use feed::Feed;
pub use http::UseLocale;
pub use index::IndexError;
pub use larablog::Larablog;
pub use markdown::{Heading, Markdown};
pub use post::Post;
pub use provider::LarablogServiceProvider;

/// A collection by its name: PHP's `Larablog::collection('blog')`.
///
/// # Errors
///
/// Fails when the [`LarablogServiceProvider`] is not registered, or the configuration has no such
/// collection.
///
/// # Panics
///
/// Panics outside the application, as the other synchronous helpers of Laravel Rust do.
pub fn collection(name: &str) -> Result<Blog, Error> {
    laravel::config()
        .get::<larablog::Runtime>()
        .ok_or(Error::NotRegistered)?
        .0
        .get(name)
}

/// Every collection of the configuration: PHP's `Larablog::collections()`.
///
/// # Panics
///
/// Panics outside the application.
pub fn collections() -> Vec<(String, Blog)> {
    laravel::config()
        .get::<larablog::Runtime>()
        .map_or_else(Vec::new, |runtime| runtime.0.collections())
}

/// The manager of the running application.
///
/// # Errors
///
/// Fails when the [`LarablogServiceProvider`] is not registered.
pub async fn manager() -> laravel::Result<Inject<Larablog>> {
    laravel::resolve::<Larablog>().await
}