From b9e3576eb671ac3d725710e247612e391ccd0cc9 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 14 Nov 2022 19:50:04 +0800 Subject: [PATCH] #190 package details page path should be /+full_name/ --- .github/build-package-pages.sh | 13 ++++++++++--- .gitignore | 4 +++- README.md | 5 +++-- src/content/packages/_sample.md | 15 --------------- src/layouts/partials/package-thumbnail.html | 4 ++-- 5 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 src/content/packages/_sample.md diff --git a/.github/build-package-pages.sh b/.github/build-package-pages.sh index 8be2bd4..8f94f8e 100755 --- a/.github/build-package-pages.sh +++ b/.github/build-package-pages.sh @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index a142cf4..79a2bcb 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ cdk.out # initially committed _sample.md only the rest will be ignored src/content/packages/* -src/static/Images/packages/* \ No newline at end of file +src/static/Images/packages/* + +src/content/+* \ No newline at end of file diff --git a/README.md b/README.md index 80eed6b..7d22d9d 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/src/content/packages/_sample.md b/src/content/packages/_sample.md deleted file mode 100644 index 4695330..0000000 --- a/src/content/packages/_sample.md +++ /dev/null @@ -1,15 +0,0 @@ - ---- -type: page -title: "mpdecimal" -Description: "mpdecimal" -layout: "package-detail" ---- - diff --git a/src/layouts/partials/package-thumbnail.html b/src/layouts/partials/package-thumbnail.html index 263f7bc..d40a6b3 100644 --- a/src/layouts/partials/package-thumbnail.html +++ b/src/layouts/partials/package-thumbnail.html @@ -19,12 +19,12 @@ >{{- .installs -}} installs -->

- + {{- partial "detail-btn.html" . -}}
- +