- render dynamic content on package details page ie: /packages/cmake

- automatically create /packages/[packageName].md on /src/content/packages/*
This commit is contained in:
neil 2022-10-14 09:46:45 +08:00
parent 0c65ed2170
commit 26cea2aedd
12 changed files with 65 additions and 13 deletions

17
.github/build-package-pages.sh vendored Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# cmd: $ ./build-package-pages.sh srcJson targetPath
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/packages'
for row in $(cat $1 | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
touch $2/$(_jq '.name').md
content="---
type: page
title: \"$(_jq '.name')\"
Description: \"$(_jq '.desc')\"
layout: \"package-detail\"
---"
echo "$content" > $2/$(_jq '.name').md
done

View file

@ -28,6 +28,12 @@ jobs:
# TODO: # TODO:
# add action here to download updates packages.json into src/data/packages.json # add action here to download updates packages.json into src/data/packages.json
- name: Create Package Detail Pages from packages.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }} - run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- uses: teaxyz/setup@v0 - uses: teaxyz/setup@v0
with: with:

View file

@ -36,6 +36,11 @@ jobs:
# TODO: # TODO:
# add action here to download updates packages.json into src/data/packages.json # add action here to download updates packages.json into src/data/packages.json
- name: Create Package Detail Pages from packages.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }} - run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- uses: teaxyz/setup@v0 - uses: teaxyz/setup@v0
with: with:

3
.gitignore vendored
View file

@ -24,3 +24,6 @@ node_modules
cdk.out cdk.out
.ideas .ideas
# initially committed _sample.md only the rest will be ignored
src/content/packages/*

View file

@ -16,6 +16,11 @@ The tea logo and wordmark are registered trademarks of tea.inc.
* Repeated components are in [`./src/layouts/partials/`]. * Repeated components are in [`./src/layouts/partials/`].
## Getting Started ## Getting Started
Just once assuming there are no updates in `/src/data/packages.json`. This will create the package detail pages.
```sh
.github/build-package-pages.sh src/data/packages.json src/content/packages
```
hugo can render your edits while you work: hugo can render your edits while you work:
@ -37,6 +42,7 @@ Install hugo yourself or use tea: `sh <(curl tea.xyz) hugo`.
Builds a static, deployable version of the website. Builds a static, deployable version of the website.
```sh ```sh
.github/build-package-pages.sh src/data/packages.json src/content/packages
hugo --source src --destination ../public --minify hugo --source src --destination ../public --minify
``` ```

View file

@ -16,4 +16,4 @@ title = 'Equitable Open-Source for Web3'
name = 'Blog' name = 'Blog'
title = 'blog' title = 'blog'
url = 'https://medium.com/teaxyz' url = 'https://medium.com/teaxyz'
weight = 5 weight = 5

View file

@ -1,5 +0,0 @@
---
title: "Package Details"
Description: "package.details"
layout: "package-detail"
---

View file

@ -0,0 +1,15 @@
<!--
this page will be automatically duplicated/populated
by .github/build-package-pages.sh
before build & deploy probably in Github Actions
values to be replaced are title and Description
WARN: anything else added to this folder will be git ignored
-->
---
type: page
title: "mpdecimal"
Description: "mpdecimal"
layout: "package-detail"
---

View file

@ -208,7 +208,7 @@
<h2>sta'tea'stics</h2> <h2>sta'tea'stics</h2>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><br> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><br>
{{- partial "detail-btn-large.html" . -}} {{- partial "detail-btn-large.html" "#" -}}
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View file

@ -9,10 +9,13 @@
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<h3>Package Title</h3> <h3>{{- .Title -}}</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> {{ range where $.Site.Data.packages "name" .Title }}
{{- partial "detail-btn-large.html" -}} <p>{{- .desc -}}</p>
{{ if not (eq .homepage "") }}
{{- partial "detail-btn-large.html" .homepage -}}
{{end}}
{{ end }}
</div> </div>
</div> </div>
</div> </div>

View file

@ -1 +1,3 @@
<button href="#" class="detail-btn-large"><i class="icon-enter-arrow"></i>VIEW ALL DETAILS</button> <a target="_blank" href="{{- . -}}">
<button class="detail-btn-large"><i class="icon-enter-arrow"></i>VIEW ALL DETAILS</button>
</a>

View file

@ -1,6 +1,6 @@
<nav class="navbar bg-dark navbar-expand-lg navbar-dark sticky-top my-auto main-nav"> <nav class="navbar bg-dark navbar-expand-lg navbar-dark sticky-top my-auto main-nav">
<div class="container-fluid top-nav"> <div class="container-fluid top-nav">
<a class="navbar-brand" href="#"><img class="nav-logo" src="/Images/tea-logo-2.svg"></a> <a class="navbar-brand" href="/"><img class="nav-logo" src="/Images/tea-logo-2.svg"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight"
aria-controls="offcanvasRight" aria-expanded="false" aria-label="Toggle navigation"> aria-controls="offcanvasRight" aria-expanded="false" aria-label="Toggle navigation">
MENU MENU