add support for %NAME% and url_string (permalinks)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
* along with Itsy-Gitsy. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use crate::git::GitFile;
|
||||
use crate::util::{sanitize_path_component, urlify_path};
|
||||
use chrono::{naive::NaiveDateTime, offset::FixedOffset, DateTime};
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
@@ -116,6 +117,15 @@ impl Filter for MaskFilter {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UrlStringFilter;
|
||||
impl Filter for UrlStringFilter {
|
||||
fn filter(&self, value: &Value, _args: &HashMap<String, Value>) -> Result<Value, tera::Error> {
|
||||
let v: String = try_get_value!("url_string", "value", String, value);
|
||||
let sanitized = sanitize_path_component(&urlify_path(&v));
|
||||
Ok(to_value(sanitize_path_component(&sanitized)).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TsDateFn;
|
||||
impl Function for TsDateFn {
|
||||
fn call(&self, args: &HashMap<String, Value>) -> Result<Value, tera::Error> {
|
||||
|
||||
Reference in New Issue
Block a user