Daily focus content (depending on weekday) on index page

Hi to all of you!

I wonder if it would be possibile to display content dynamically
depending on the day of week on my index page without templater.

Why without templater? I do not create a new note (like for a daily note for instance)
in order to fire up the logic from an existing template. I rather have a “static”
index page with all of my MOCS and so on.

My goal is to show my “focus” for the evening (free time) of the current day.
Here is an example of what I am trying to accomplish:

Week with an odd weeknumber, for instance 1,3,5,…

Monday: Read a book
Tuesday: Go running
Wednesday: Meditate
Thursday: Play boardgames
Friday: Hang out with some friends

Week with an even weeknumber, for instance 2,4,6,…

Monday: Meditate
Tuesday: Have a walk
Wednesday: Read a book
Thursday: Learn a new thing
Friday: Play darts with some dudes

On my index page there should be a “widget” or space for the focus of today :wink:

So let’s say we are in week number 1 of the year and we are on a Wednesday.

Today’s Focus:
Medidate

Projects

Areas

Any ideas are much appreciated!

Many thanks and have a great day!
montharon

The Natural Language Dates community plugin enables dynamic dates, but I don’t know if there’s a way to use them in an embed. I know you can make a link, but it’s a Markdown link with a special URL.

You might be able to use the DataView community plugin somehow.

Many thanks for your reply @CawlinTeffid!
I finally managed it with some custom Javascript for my own custom “widget” :wink:

Here is the code if anybody is interested in it…

let weekDays = [
	"Sunday",
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday"
];
let currentDate = new Date();
let weekDay = weekDays[currentDate.getDay()];
let weeklyPlan = dv.page("Tools/WeeklyPlan.md");
let postdata = await dv.io.load(weeklyPlan .file.path);

let startDate = new Date(currentDate.getFullYear(), 0, 1);
let days = Math.floor((currentDate - startDate) / (24 * 60 * 60 * 1000));
let weekNumber = Math.ceil(days / 7);
let weekDayIndex = weekNumber % 4 == 0 ? 4 : weekNumber % 4;

let regexPattern = weekDay + " " + weekDayIndex + "\\n(?<content>[^#]+)";
let regex = new RegExp(regexPattern, "g");
let match = regex.exec(postdata)

dv.span(match.groups["content"]);

And here is an example of a weekly plan:
I have planned 4 weeks in total → the index of the current week is calculated in the
following snippet

let weekNumber = Math.ceil(days / 7);
let weekDayIndex = weekNumber % 4 == 0 ? 4 : weekNumber % 4;
## 📅 Week 1
### Monday 1
- 17:15 - 18:15 Task1
- 19:00 - 20:30 Task2
- 20:30 - 21:45 Task3
- 21:45 - 22:15 Task4
### Tuesday 1
- 20:30 - 22:00 Task1
### Wednesday 1
- 19:00 - 20:30 Task1
- 20:30 - 21:30 Task2
- 21:45 - 22:15 Task3
....

## 📅 Week 2
### Monday 2
- 19:00 - 20:30 Task1
- 20:30 - 21:45 Task2
- 21:45 - 22:15 Task3
### Tueday 2
- 20:30 - 22:00 Task1
....

## 📅 Week 3
### Monday 3
- 19:00 - 20:30 Task1
....

## 📅 Week 4
### Monday 4
- 19:00 - 20:30 Task1

And this is how it looks like on my index page:

🪬 Today's focus
* 19:00 - 20:30 Task1
* 20:30 - 22:00 Task2

Many greetings!
montharon

1 Like