Skip to content

Commit e1e2cae

Browse files
authored
Feat/render description md (#40)
* feat: added support for rendering markdown text for description (YAML -> UI) * feat: added support for highlighting links/email. * feat: update README to clarify markdown support in description field * docs: update the README for editing YAML file
1 parent aa78459 commit e1e2cae

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

_layouts/minimal_search.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>{{ page.title }}</title>
8+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
89
<style>
910
:root {
1011
/* Maximum number of cards to display per row on wider screens */
@@ -411,6 +412,16 @@
411412
max-height: none;
412413
}
413414

415+
.guides-description a {
416+
color: #0066cc;
417+
text-decoration: underline;
418+
}
419+
420+
.guides-description a:hover {
421+
color: #004499;
422+
text-decoration: underline;
423+
}
424+
414425
.read-more-btn {
415426
background: none;
416427
border: none;
@@ -1205,11 +1216,12 @@ <h3>No guides found</h3>
12051216

12061217
// Safely handle description
12071218
const description = guide.description && guide.description !== 'undefined' && guide.description !== 'null' ? guide.description : '';
1219+
const descriptionHtml = description ? marked.parse(description) : '';
12081220

12091221
return `
12101222
<div class="guides-card">
12111223
<h3><a href="${guide.url}" target="_blank">${guide.title}</a></h3>
1212-
<p class="guides-description" id="${uniqueId}" data-full-text="${description.replace(/"/g, '&quot;')}">${description}</p>
1224+
<div class="guides-description" id="${uniqueId}" data-full-text="${description.replace(/"/g, '&quot;')}">${descriptionHtml}</div>
12131225
<button class="read-more-btn" id="btn-${uniqueId}" onclick="toggleDescription('${uniqueId}', this)" style="display: none;">Read more</button>
12141226
<div class="guides-tags">
12151227
${techniques.map(cat => `<span class="tag technique${activeFilters.technique.has(cat) ? ' active' : ''}" data-facet="technique" data-value="${cat}">${cat}</span>`).join('')}

docs/update-data/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Each tutorial entry can have the following fields:
66
|----------------|------------|----------------------------------------------------------------------------------------------------------------|-----------------------------|
77
| `id` | No | A unique identifier for the tutorial. | String |
88
| `title` | Yes | The title of the tutorial. | String |
9-
| `description` | No | A brief description of the tutorial. | String |
9+
| `description` | No | A brief description of the tutorial. <br><br>**Note**: Markdown is supported when rendering this field in the web interface. | String |
1010
| `url` | Yes | The URL of the tutorial. | String (URL) |
1111
| `technique` | No | The technique(s) covered in the tutorial. | String or Array of Strings |
1212
| `tool` | No | The tool(s) used in the tutorial. | String or Array of Strings |

0 commit comments

Comments
 (0)