pub struct Builder { /* private fields */ }
Expand description
A site builder to use build one site
§Examples
use polysite::{
compiler::{markdown::MarkdownCompiler, template::TemplateEngine},
*,
};
#[tokio::main]
async fn main() {
let template_engine = TemplateEngine::new("templates/**").unwrap().get();
Builder::new(Config::default())
.insert_metadata("site_title", "Hello, polysite!")
.await
.unwrap()
.add_step([
Rule::new("posts")
.set_globs(["posts/**/*.md"])
.set_compiler(
MarkdownCompiler::new(template_engine.clone(), "index.html", None).get(),
),
Rule::new("markdown").set_globs(["**/*.md"]).set_compiler(
MarkdownCompiler::new(template_engine.clone(), "index.html", None).get(),
),
])
.build()
.await
.unwrap();
}
Implementations§
source§impl Builder
impl Builder
sourcepub async fn insert_metadata(
self,
name: impl ToString,
data: impl Serialize
) -> Result<Self>
pub async fn insert_metadata( self, name: impl ToString, data: impl Serialize ) -> Result<Self>
Insert global metadata
You can pass anything which can be serialized and deserialized to
serde_json::Value
.
sourcepub fn add_step(self, step: impl IntoIterator<Item = Rule>) -> Self
pub fn add_step(self, step: impl IntoIterator<Item = Rule>) -> Self
Add build step
This method receives rules as a parameter and push as build step Rules registered in a same step will be built concurrently
Auto Trait Implementations§
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more