Skip to content

Commit 7563319

Browse files
authored
Update chip support pages (#376)
* feat: use json in chipstatus shortcode and update related content * feat: add question icon and document its purpose * feat: add logic to process generated_time key as ISO8601 time * feat: add chipstatus shortcode with generated_time * feat: change time format * chore: update json key names
1 parent 47fe66a commit 7563319

File tree

2 files changed

+53
-21
lines changed

2 files changed

+53
-21
lines changed

content/pages/chip-support-status/esp32c61/index.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ date: 2024-08-29T16:40:07+08:00
44
draft: false
55
---
66

7+
**Last updated:** {{< chipstatus contentPath="persist/chip-support-status/esp32c61.json" jsonKey="timestamp" >}}
8+
79
This page lists the projects in which the ESP32-C61 is supported.
810

9-
In the list below, the supported features are marked with a checkbox (:white_check_mark:), while unsupported features are marked with an hourglass (:hourglass_flowing_sand:). An internal issue reference (such as \"IDF-1234\") is listed at the end of the feature description to help us keep this list up to date:
11+
To show the status of features, the following icons are used:
1012

11-
- :hourglass_flowing_sand: Unsupported feature (IDF-1234)
1213
- :white_check_mark: Supported feature
14+
- :hourglass_flowing_sand: Unsupported feature (IDF-1234)
15+
- \"IDF-1234\" indicates an internal issue reference to help us keep this list up to date
16+
- :question: Support status unknown
17+
- Such status issues will be checked and fixed shortly
1318

1419
This page will be periodically updated to reflect the current support status for the ESP32-C61.
1520

@@ -27,4 +32,9 @@ According to the chip mass production plan, the planned support for ESP32-C61 in
2732

2833
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).
2934

30-
{{< chipstatus url="https://developer.espressif.com/persist/chip-support-status/esp32c61.md" >}}
35+
{{< chipstatus contentPath="persist/chip-support-status/esp32c61.json" jsonKey="idf" >}}
36+
37+
38+
## External projects
39+
40+
{{< chipstatus contentPath="persist/chip-support-status/esp32c61.json" jsonKey="other_proj" >}}

layouts/shortcodes/chipstatus.html

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
1-
<div id="content">Loading...</div>
1+
{{ $uniqueID := .Get "jsonKey" | urlize }} <!-- Generate a unique ID -->
2+
<span id="content-{{ $uniqueID }}">Loading...</span>
3+
4+
{{ $contentPath := .Get "contentPath" }}
5+
{{ $jsonKey := .Get "jsonKey" }}
6+
{{ $fullURL := printf "%s%s" .Site.BaseURL $contentPath }}
27

38
<script>
4-
const url = '{{ .Get "url" }}'; // Get the URL from the shortcode parameter
9+
document.addEventListener("DOMContentLoaded", function () {
10+
const url = '{{ $fullURL }}';
11+
const jsonKey = '{{ $jsonKey }}';
12+
const uniqueID = '{{ $uniqueID }}';
13+
14+
fetch(url) // Fetch the JSON file
15+
.then(response => {
16+
if (!response.ok) {
17+
throw new Error('Error fetching the JSON data');
18+
}
19+
return response.json();
20+
})
21+
.then(data => {
22+
if (!data[jsonKey]) {
23+
throw new Error(`Key "${jsonKey}" not found in the JSON data`);
24+
}
525

6-
fetch(url) // Fetch the markdown content
7-
.then(response => {
8-
if (!response.ok) {
9-
throw new Error('Error fetching the markdown data');
10-
}
11-
return response.text();
12-
})
13-
.then(markdown => {
14-
// Convert the markdown to HTML
15-
let htmlContent = marked.parse(markdown);
26+
let content;
27+
if (jsonKey === "timestamp") {
28+
// Convert ISO8601 time to desired local time format
29+
const isoTime = data[jsonKey];
30+
const options = { day: 'numeric', month: 'short', year: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true };
31+
content = new Intl.DateTimeFormat('en-GB', options).format(new Date(isoTime));
32+
} else {
33+
// Extract the value for the key and convert the markdown to HTML
34+
let markdown = data[jsonKey];
35+
content = marked.parse(markdown);
36+
}
1637

17-
// Inject the HTML into the content div
18-
document.getElementById('content').innerHTML = htmlContent;
19-
})
20-
.catch(error => {
21-
document.getElementById('content').textContent = 'Error loading markdown content: ' + error.message;
22-
});
38+
// Inject the content into the unique content span
39+
document.getElementById(`content-${uniqueID}`).innerHTML = content;
40+
})
41+
.catch(error => {
42+
document.getElementById(`content-${uniqueID}`).textContent = 'Error loading content: ' + error.message;
43+
});
44+
});
2345
</script>

0 commit comments

Comments
 (0)