Skip to content

Commit

Permalink
feat: make chipstatus url relative
Browse files Browse the repository at this point in the history
  • Loading branch information
f-hollow committed Jan 2, 2025
1 parent 400012a commit 27b5f8d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
7 changes: 6 additions & 1 deletion content/pages/chip-support-status/esp32c61/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ According to the chip mass production plan, the planned support for ESP32-C61 in

If you have an issue to report about any of the ESP32-C61 features, please create an issue in [ESP-IDF GitHub issue tracker](https://github.com/espressif/esp-idf/issues).

{{< chipstatus url="https://developer.espressif.com/persist/chip-support-status/esp32c61.md" >}}
{{< chipstatus contentPath="persist/chip-support-status/esp32c61.json" jsonKey="idf" >}}


## External projects

{{< chipstatus contentPath="persist/chip-support-status/esp32c61.json" jsonKey="ext_proj" >}}
24 changes: 17 additions & 7 deletions layouts/shortcodes/chipstatus.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
<div id="content">Loading...</div>

{{ $contentPath := .Get "contentPath" }}
{{ $jsonKey := .Get "jsonKey" }}
{{ $fullURL := printf "%s%s" .Site.BaseURL $contentPath }}

<script>
const url = '{{ .Get "url" }}'; // Get the URL from the shortcode parameter
const url = '{{ $fullURL }}';
const jsonKey = '{{ $jsonKey }}';

fetch(url) // Fetch the markdown content
fetch(url) // Fetch the JSON file
.then(response => {
if (!response.ok) {
throw new Error('Error fetching the markdown data');
throw new Error('Error fetching the JSON data');
}
return response.text();
return response.json();
})
.then(markdown => {
// Convert the markdown to HTML
.then(data => {
if (!data[jsonKey]) {
throw new Error(`Key "${jsonKey}" not found in the JSON data`);
}

// Extract the value for the key and convert the markdown to HTML
let markdown = data[jsonKey];
let htmlContent = marked.parse(markdown);

// Inject the HTML into the content div
document.getElementById('content').innerHTML = htmlContent;
})
.catch(error => {
document.getElementById('content').textContent = 'Error loading markdown content: ' + error.message;
document.getElementById('content').textContent = 'Error loading content: ' + error.message;
});
</script>

0 comments on commit 27b5f8d

Please sign in to comment.