#190 package details page path should be /+full_name/

This commit is contained in:
neil 2022-11-14 19:50:04 +08:00
parent e7ae5f5ed5
commit b9e3576eb6
5 changed files with 18 additions and 23 deletions

View file

@ -1,12 +1,19 @@
#!/bin/bash
# cmd: $ ./build-package-pages.sh srcJson targetPath
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/packages'
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/'
for row in $(jq -r '.[] | @base64' < "$1"); do
_jq() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
touch "$2"/"$(_jq '.slug')".md
full_name=$(_jq '.full_name')
if [[ "$full_name" == *\/* ]] || [[ "$full_name" == *\\* ]]
then
mkdir -p "$2/+$full_name"
rm -rf "$2/+$full_name"
fi
touch "$2"/"+$(_jq '.full_name')".md
content="---
type: page
title: \"$(_jq '.name')\"
@ -14,5 +21,5 @@ maintainer: \"$(_jq '.maintainer')\"
Description: \"$(_jq '.desc' | tr '\"' "'")\"
layout: \"package-detail\"
---"
echo "$content" > "$2"/"$(_jq '.slug')".md
echo "$content" > "$2"/"+$(_jq '.full_name')".md
done

4
.gitignore vendored
View file

@ -27,4 +27,6 @@ cdk.out
# initially committed _sample.md only the rest will be ignored
src/content/packages/*
src/static/Images/packages/*
src/static/Images/packages/*
src/content/+*

View file

@ -29,10 +29,11 @@ The detail pages of each package are not committed to the repository for the
simple reason of that would be too much repeating data.
Execute the following command just once per version of
`/src/data/packages.json`. This will create the package detail pages in
`/src/content/packages/[package_slug].md`.
`/src/content/+[package.full_name].md`.
Which resembles the installation tag in tea cli
```sh
.github/build-package-pages.sh src/data/packages.json src/content/packages
.github/build-package-pages.sh src/data/packages.json src/content
```

View file

@ -1,15 +0,0 @@
<!--
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

@ -19,12 +19,12 @@
<span class="package-install-no">>{{- .installs -}}&nbsp;installs</span> -->
</p>
</div>
<a href="/packages/{{- .slug -}}/">
<a href="/+{{- .full_name -}}/">
{{- partial "detail-btn.html" . -}}
</a>
</div>
<div class="card-body thumbnail-body-mobile">
<a href="/packages/{{- .slug -}}/">
<a href="/+{{- .full_name -}}/">
<button class="detail-btn-mobile"><i class="icon-enter-arrow"></i>details</button>
</a>
</div>