From b9e3576eb671ac3d725710e247612e391ccd0cc9 Mon Sep 17 00:00:00 2001
From: neil
Date: Mon, 14 Nov 2022 19:50:04 +0800
Subject: [PATCH 1/3] #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" . -}}
From 9f2f479eb7935fd65ed70b98065bf2427034c474 Mon Sep 17 00:00:00 2001
From: neil
Date: Mon, 14 Nov 2022 19:55:33 +0800
Subject: [PATCH 2/3] #190 apply correct dir to create pages
---
.github/workflows/cd.yml | 2 +-
.github/workflows/staging.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index 9f74149..700ceff 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -37,7 +37,7 @@ jobs:
uses: getneil/jq-action@v1
id: version
with:
- cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
+ cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
- name: Download package thumbnails from Airtable
uses: getneil/jq-action@v1
diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml
index 1da2b30..01cc9f5 100644
--- a/.github/workflows/staging.yml
+++ b/.github/workflows/staging.yml
@@ -45,7 +45,7 @@ jobs:
- name: Create Package Detail Pages from packages.json
uses: getneil/jq-action@v1
with:
- cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
+ cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
- name: Download package thumbnails from Airtable
uses: getneil/jq-action@v1
From 1dedd671d7e5e9a3504572bcfa9f5f2d46ef961d Mon Sep 17 00:00:00 2001
From: neil
Date: Tue, 15 Nov 2022 10:23:07 +0800
Subject: [PATCH 3/3] #190 add a package list page at '/+/'
---
src/content/+.md | 5 ++++
src/layouts/page/packages.html | 33 ++++++++++++++++++++++++++
src/layouts/partials/package-grid.html | 11 +++++++--
3 files changed, 47 insertions(+), 2 deletions(-)
create mode 100644 src/content/+.md
create mode 100644 src/layouts/page/packages.html
diff --git a/src/content/+.md b/src/content/+.md
new file mode 100644
index 0000000..4403dec
--- /dev/null
+++ b/src/content/+.md
@@ -0,0 +1,5 @@
+---
+type: page
+title: "packages"
+layout: "packages"
+---
diff --git a/src/layouts/page/packages.html b/src/layouts/page/packages.html
new file mode 100644
index 0000000..83a0da0
--- /dev/null
+++ b/src/layouts/page/packages.html
@@ -0,0 +1,33 @@
+{{ define "main" }}
+
+
+
+
+
+
+
+
+ {{- partial "package-grid.html" . -}}
+
+
+
+
+
+ {{- partial "swiper.html" . -}}
+
+
+
+
+
+
+{{ end }}
diff --git a/src/layouts/partials/package-grid.html b/src/layouts/partials/package-grid.html
index 7c1cab6..913f6ff 100644
--- a/src/layouts/partials/package-grid.html
+++ b/src/layouts/partials/package-grid.html
@@ -39,7 +39,7 @@
}
.package-grid {
display: grid;
- grid-template-columns: auto auto;
+ grid-template-columns: auto;
}
#loadMorePackagesBtn {
cursor: pointer;
@@ -98,6 +98,8 @@
popularity: 'popularity',
last_modified: 'last_modified',
}
+ const showAllPackages = window.location.pathname.includes("/+/");
+
let sortBy = sortOptions.popularity; // last_modified
let sortDirection = 'desc'; // asc
let limit = 16;
@@ -186,7 +188,7 @@
const packages = getPackageThumbs();
let i = 0;
for(const sp of packages) {
- if (i >= limit) {
+ if (i >= limit && !showAllPackages) {
sp.classList.add('hidden');
} else {
sp.classList.remove('hidden');
@@ -204,6 +206,11 @@
}
const loadMoreButton = document.getElementById('loadMorePackagesBtn');
+ if (showAllPackages) {
+ loadMoreSection.classList.add('hidden');
+ } else {
+ loadMoreSection.classList.remove('hidden');
+ }
loadMoreButton.addEventListener('click',() => {
limit += 16;
refreshDisplayedPackages();