-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ssr-for-posts-and-authors * fmt * refactor * fix super * correct * refactoring
- Loading branch information
Showing
23 changed files
with
214 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pub const SPLIT_SYMBOL: char = '^'; | ||
|
||
pub fn clean(slug: &String) -> String { | ||
slug.rsplit_once(SPLIT_SYMBOL) | ||
.map(|r| r.0.to_owned()) | ||
.unwrap_or(slug.clone()) | ||
} | ||
|
||
pub fn extend(slug: &String, suffix: &String) -> String { | ||
format!("{slug}{SPLIT_SYMBOL}{suffix}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
pub mod author_slug_utils; | ||
pub mod entities; | ||
pub mod events; | ||
mod page_processor; | ||
|
||
const AUTHOR_SLUG_SPLIT_SYMBOL: char = '^'; | ||
|
||
pub fn clean_author_slug(slug: &String) -> String { | ||
slug.rsplit_once(AUTHOR_SLUG_SPLIT_SYMBOL) | ||
.map(|r| r.0.to_owned()) | ||
.unwrap_or(slug.clone()) | ||
} | ||
|
||
pub fn extend_author_slug(slug: &String, suffix: &String) -> String { | ||
format!("{slug}{AUTHOR_SLUG_SPLIT_SYMBOL}{suffix}") | ||
} | ||
pub use page_processor::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pub trait PageProcessor { | ||
fn create_for_page(page: &u64) -> Self; | ||
fn limit(&self) -> u64; | ||
fn offset(&self) -> u64; | ||
} | ||
|
||
pub struct DefaultPageProcessor<const LIMIT: u64 = 10> { | ||
page: u64, | ||
} | ||
|
||
impl<const LIMIT: u64> PageProcessor for DefaultPageProcessor<LIMIT> { | ||
fn create_for_page(page: &u64) -> Self { | ||
Self { page: *page } | ||
} | ||
fn limit(&self) -> u64 { | ||
LIMIT | ||
} | ||
fn offset(&self) -> u64 { | ||
let Some(real_page) = self.page.checked_sub(1) else { | ||
return 0; | ||
}; | ||
let offset = real_page * LIMIT; | ||
offset | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.