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?
Juan Pablo Isaza
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" >}}