From 91dd9eeed0f00d781ecfdd0879455782134bfb3c Mon Sep 17 00:00:00 2001 From: Zachatoo Date: Mon, 8 Jan 2024 20:10:59 -0700 Subject: [PATCH] docs: add momentjs examples --- docs/documentation.toml | 12 ++++++++++++ .../internal-modules/date-module.md | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/docs/documentation.toml b/docs/documentation.toml index e130b318..adf08b83 100644 --- a/docs/documentation.toml +++ b/docs/documentation.toml @@ -156,6 +156,18 @@ example = """<% tp.date.weekday("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD") %> name = "File's title previous Monday" example = """<% tp.date.weekday("YYYY-MM-DD", -7, tp.file.title, "YYYY-MM-DD") %>""" +[[tp.date.momentjs.examples]] +name = "Date now" +example = """<% moment(tp.file.title, "YYYY-MM-DD").format("YYYY-MM-DD") %>""" + +[[tp.date.momentjs.examples]] +name = "Get start of month from note title" +example = """<% moment(tp.file.title, "YYYY-MM-DD").startOf("month").format("YYYY-MM-DD") %>""" + +[[tp.date.momentjs.examples]] +name = "Get end of month from note title" +example = """<% moment(tp.file.title, "YYYY-MM-DD").endOf("month").format("YYYY-MM-DD") %>""" + [tp.file] name = "file" diff --git a/docs/src/internal-functions/internal-modules/date-module.md b/docs/src/internal-functions/internal-modules/date-module.md index 72ad5a98..66853686 100644 --- a/docs/src/internal-functions/internal-modules/date-module.md +++ b/docs/src/internal-functions/internal-modules/date-module.md @@ -39,6 +39,17 @@ Templater gives you access to the `moment` object, with all of its functionaliti More information on moment.js [here](https://momentjs.com/docs/#/displaying/). +{% if tp.date.momentjs.examples %} +##### Examples + +```javascript +{% for example in tp.date.momentjs.examples -%} +// {{ example.name}} +{{ example.example }} +{% endfor -%} +``` +{% endif %} + ## Examples ```javascript