Skip to content

Commit 95c8c81

Browse files
authored
Merge pull request #379 from SAHU-01/master
[UI] Dynamically adding front-matter to documentation pages
2 parents 7462f99 + 3a0bf65 commit 95c8c81

File tree

4 files changed

+132
-16
lines changed

4 files changed

+132
-16
lines changed

.github/workflows/feature-list.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Feature List Update
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run every night at midnight UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
12+
jobs:
13+
check-and-update-features:
14+
runs-on: ubuntu-latest
15+
env:
16+
FEATURES_FILE: 'data/features.json'
17+
18+
steps:
19+
- name: Checkout current repository
20+
uses: actions/checkout@v4
21+
22+
- name: Check for updates in source repository
23+
id: check-updates
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const { data: sourceFile } = await github.rest.repos.getContent({
28+
owner: 'layer5labs',
29+
repo: 'meshery-extensions-packages',
30+
path: 'feature-data.json',
31+
ref: 'master'
32+
});
33+
34+
// Store the latest commit SHA
35+
const latestSHA = sourceFile.sha;
36+
37+
// Try to get the previously stored SHA from cache
38+
const cache = await github.rest.actions.getActionsCacheList({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
});
42+
43+
let hasUpdates = true;
44+
if (cache.data.actions_caches.length > 0) {
45+
const lastSHA = cache.data.actions_caches[0].key.split('-').pop();
46+
hasUpdates = lastSHA !== latestSHA;
47+
}
48+
49+
if (hasUpdates) {
50+
// Update the cache with new SHA
51+
await github.rest.actions.createActionsCacheEntry({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
key: `feature-data-sha-${latestSHA}`,
55+
ref: context.ref,
56+
cache_data: latestSHA
57+
});
58+
59+
// Decode and save the content
60+
const content = Buffer.from(sourceFile.content, 'base64').toString('utf-8');
61+
const fs = require('fs');
62+
63+
// Create data directory if it doesn't exist
64+
fs.mkdirSync('data', { recursive: true });
65+
66+
// Write the new content
67+
fs.writeFileSync('${{ env.FEATURES_FILE }}', content);
68+
69+
core.setOutput('has-updates', 'true');
70+
} else {
71+
core.setOutput('has-updates', 'false');
72+
}
73+
74+
- name: Commit changes
75+
if: steps.check-updates.outputs.has-updates == 'true'
76+
uses: stefanzweifel/git-auto-commit-action@v5
77+
with:
78+
commit_message: "Updated feature data from source repository"
79+
file_pattern: ${{ env.FEATURES_FILE }}
80+
branch: master
81+
commit_options: "--signoff"
82+
commit_user_name: l5io
83+
commit_user_email: [email protected]
84+
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>

assets/scss/_styles_project.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ a:not([href]):not([class]):hover {
372372
.matterinfo {
373373
font-weight: $font-weight-medium;
374374
background: $black;
375-
font-family: "Open Sans";
375+
font-family: "Qanelas Soft";
376376
border-style: solid;
377377
margin: 2rem auto;
378378
padding: 1rem;

layouts/partials/feature-info.html

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,56 @@
22
{{ $features := .Site.Data.features }}
33

44
{{ if not $features }}
5-
{{ $features = getJSON "features.json" }}
5+
{{ $features = getJSON "features.json" }}
66
{{ end }}
77

88
{{ if $features }}
9+
{{ $groupedFeatures := dict }}
910
{{ range $features }}
10-
{{ $docUrl := .documentation | default "" }}
11-
{{ $cleanDocUrl := (index (split $docUrl "#") 0) }} <!-- Remove the # fragment if it exists -->
12-
{{ if eq $cleanDocUrl $currentPage }}
13-
<div class="matterinfo">
14-
<h4 class="matterheader">Who can use this feature</h4>
15-
{{ $subscription_tier := index .entire_row "Subscription Tier" }}
16-
<div class="plan-support all-plans {{ lower $subscription_tier }}-plan">
17-
<img src="/images/subscription.svg" alt="Icon" class="support-icon adaptive-icon">
18-
Supported on <span class="tier">{{ $subscription_tier }}</span> Plan
19-
</div>
20-
</div>
21-
{{ break }}
22-
{{ end }}
11+
{{ $docUrl := .documentation | default "" }}
12+
{{ $cleanDocUrl := (index (split $docUrl "#") 0) }}
13+
{{ if eq $cleanDocUrl $currentPage }}
14+
{{ $tier := index .entire_row "Subscription Tier" }}
15+
{{ $feature := index .entire_row "Feature" }}
16+
{{ $currentFeatures := index $groupedFeatures $tier | default "" }}
17+
{{ $groupedFeatures = merge $groupedFeatures (dict $tier (printf "%s%s%s" $currentFeatures (cond (eq $currentFeatures
18+
"") "" ", ") $feature)) }}
19+
{{ end }}
20+
{{ end }}
21+
22+
{{ if ne (len $groupedFeatures) 0 }}
23+
{{ $maxTier := "" }}
24+
{{ $maxLength := 0 }}
25+
{{ range $tier, $features := $groupedFeatures }}
26+
{{ $length := len (split $features ", ") }}
27+
{{ if gt $length $maxLength }}
28+
{{ $maxTier = $tier }}
29+
{{ $maxLength = $length }}
2330
{{ end }}
2431
{{ end }}
2532

33+
<div class="matterinfo">
34+
<h4 class="matterheader">Who can use this feature</h4>
35+
<div class="plan-support all-plans {{ lower $maxTier }}-plan">
36+
<img src="/images/subscription.svg" alt="Icon" class="support-icon adaptive-icon">
37+
Supported on <a href="https://layer5.io/pricing" class="tier-link" target="_blank"><span class="tier">{{ $maxTier
38+
}}</span> </a>Plan
39+
</div>
40+
41+
{{ if gt (len $groupedFeatures) 1 }}
42+
<div class="add-ons">
43+
<strong>Add-ons:</strong>
44+
{{ $first := true }}
45+
{{ range $tier, $features := $groupedFeatures }}
46+
{{ if ne $tier $maxTier }}
47+
{{ if not $first }}, {{ end }}
48+
{{ $first = false }}
49+
{{ $features }} [<a href="https://layer5.io/pricing" class="tier-link" target="_blank"><span class="tier">{{ $tier
50+
}}</span></a>]
51+
{{ end }}
52+
{{ end }}
53+
</div>
54+
{{ end }}
55+
</div>
56+
{{ end }}
57+
{{ end }}

static/images/subscription.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)