You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2023/03/31 10:07:48 UTC

[comdev-events-site] 01/01: Add pagefind

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch pagefind
in repository https://gitbox.apache.org/repos/asf/comdev-events-site.git

commit a4fea4cffe9024f0065200df3e4c604a6924d5a3
Author: Sebb <se...@apache.org>
AuthorDate: Fri Mar 31 11:07:38 2023 +0100

    Add pagefind
    
    The search box can be moved / copied elsewhere
---
 Jenkinsfile      | 13 +++++++++++++
 source/_index.md |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index d5c151a..8208e20 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,6 +25,8 @@ pipeline {
     environment {
         HUGO_VERSION = '0.63.2'
         DEPLOY_BRANCH = 'asf-site'
+        PAGEFIND_VERSION = '0.12.0'
+        PAGEFIND_HASH = '3e450176562b65359f855c04894ec2c07ffd30a8d08ef4d5812f8d3469d7a58f'
     }
 
     stages {
@@ -44,6 +46,16 @@ pipeline {
                         mv hugo ${env.HUGO_DIR}/bin/
                     """
 
+                    // Download Pagefind
+                    env.PAGEFIND_DIR = sh(script:'mktemp -d', returnStdout: true).trim()
+                    sh "mkdir -p ${env.PAGEFIND_DIR}/bin"
+                    sh "wget --no-verbose -O ${env.PAGEFIND_DIR}/pagefind.tar.gz https://github.com/CloudCannon/pagefind/releases/download/v${PAGEFIND_VERSION}/pagefind-v${PAGEFIND_VERSION}-x86_64-unknown-linux-musl.tar.gz"
+                    // Verify the checksum
+                    def pagefind_hash = sha256 file: "${env.PAGEFIND_DIR}/pagefind.tar.gz"
+                    assert pagefind_hash == "${PAGEFIND_HASH}"
+                    // Unpack Pagefind
+                    sh "tar -C ${env.PAGEFIND_DIR}/bin -xkf ${env.PAGEFIND_DIR}/pagefind.tar.gz"
+
                     // Setup directory structure for generated content
                     env.TMP_DIR = sh(script:'mktemp -d', returnStdout: true).trim()
                     env.OUT_DIR = "${env.TMP_DIR}/content"
@@ -58,6 +70,7 @@ pipeline {
                     withEnv(["PATH+HUGO=${env.HUGO_DIR}/bin"]) {
                         sh "hugo --destination ${env.OUT_DIR}"
                     }
+                    sh "${env.PAGEFIND_DIR}/bin/pagefind --source ${env.OUT_DIR}"
                 }
             }
         }
diff --git a/source/_index.md b/source/_index.md
index 74d47df..5b48dc5 100644
--- a/source/_index.md
+++ b/source/_index.md
@@ -2,6 +2,15 @@
 title: Apache Software Foundation Events
 ---
 
+<link href="/_pagefind/pagefind-ui.css" rel="stylesheet">
+<script src="/_pagefind/pagefind-ui.js" type="text/javascript"></script>
+<div id="search"></div>
+<script>
+    window.addEventListener('DOMContentLoaded', (event) => {
+        new PagefindUI({ element: "#search" });
+    });
+</script>
+
 Welcome to the Apache Software Foundation (ASF) events homepage!
 
 The ASF runs and participates in a number