• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

38
Views
How to insert current date shortcode for hugo website

So far I have successfully put an iframe shortcode on my site.

What I want to do is put today's date into the iframe url where I have the date, like this where I have an old static date:

{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date=2022-03-31&type=Daily_CPU" >}}

Here is my "charts" shortcode definition for the iframe:

<iframe src="{{.Get 0}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>

Here is my "date" shortcode with some javascript to get today's date:

<script>
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();

today = yyyy + '-' + mm + '-' + dd;
document.write(today);
</script>

I have been trying a hand full of things and nothing seems to work right, so far.

I thought this would have worked in the iframe shortcode definition, but it does not:

<iframe src="{{.Get 0}}{{< date >}}"&type=Daily_CPU width="1080" height="800" frameborder="0"></iframe>

Clearly I'm doing something wrong here. Can you help me? Is there an easier way that I'm not thinking of?

about 2 months ago ·

Juan Pablo Isaza

1 answers
Answer question

0

Untested but should lead you in the right direction...

{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date=2022-03-31&type=Daily_CPU" >}}

Becomes:

{{< charts "https://unnamed.website/dontguess/performance_chart_viewer.aspx?environment=DEV&date={{now.Format | "YOUR NEEDED FORMAT HERE"}}&type=Daily_CPU" >}}

about 2 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.