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

juzhiyuan pushed a commit to branch feat-jsDelivr
in repository https://gitbox.apache.org/repos/asf/apisix-website.git

commit 6dfc28c5b69004d937226ad684ffbdc5a970dc91
Author: juzhiyuan <[email protected]>
AuthorDate: Sat Oct 23 12:42:31 2021 +0800

    feat: support using jsDelivr in ssrTemplate
---
 website/config/ssrTemplate.js | 35 +++++++++++++++++++++++++++++++++++
 website/docusaurus.config.js  |  9 ++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/website/config/ssrTemplate.js b/website/config/ssrTemplate.js
new file mode 100644
index 0000000..43f5ea7
--- /dev/null
+++ b/website/config/ssrTemplate.js
@@ -0,0 +1,35 @@
+const CDN_URL = 'https://cdn.jsdelivr.net/gh/apache/apisix-website@asf-site'
+
+module.exports = {
+  ssrTemplate: `<!DOCTYPE html>
+  <html <%~ it.htmlAttributes %>>
+    <head>
+      <meta charset="UTF-8">
+      <meta name="viewport" content="width=device-width, initial-scale=1.0">
+      <meta name="generator" content="Docusaurus v<%= it.version %>">
+      <% if (it.noIndex) { %>
+        <meta name="robots" content="noindex, nofollow" />
+      <% } %>
+      <%~ it.headTags %>
+      <% it.metaAttributes.forEach((metaAttribute) => { %>
+        <%~ metaAttribute %>
+      <% }); %>
+      <% it.stylesheets.forEach((stylesheet) => { %>
+        <link rel="stylesheet" href="${CDN_URL}<%= it.baseUrl %><%= stylesheet 
%>" />
+      <% }); %>
+      <% it.scripts.forEach((script) => { %>
+        <link rel="preload" href="${CDN_URL}<%= it.baseUrl %><%= script %>" 
as="script">
+      <% }); %>
+    </head>
+    <body <%~ it.bodyAttributes %>>
+      <%~ it.preBodyTags %>
+      <div id="__docusaurus">
+        <%~ it.appHtml %>
+      </div>
+      <% it.scripts.forEach((script) => { %>
+        <script src="<%= it.baseUrl %><%= script %>"></script>
+      <% }); %>
+      <%~ it.postBodyTags %>
+    </body>
+  </html>`
+}
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index d1aade9..081a032 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -1,8 +1,10 @@
+const { ssrTemplate } = require('./config/ssrTemplate');
+
 module.exports = {
   title: "Apache APISIX® --  Cloud-Native API Gateway",
   tagline:
     "Apache APISIX is a dynamic, real-time, high-performance Cloud-Native API 
gateway, based on the Nginx library and etcd.",
-  url: "https://apisix.apache.org/";,
+  url: "https://apisix.apache.org";,
   baseUrl: "/",
   organizationName: "Apache",
   projectName: "apisix-website",
@@ -640,4 +642,9 @@ module.exports = {
   stylesheets: [
     
"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap";,
   ],
+  /**
+   * We need to check if we build site for preview env, or preview site will 
load static assets from the asf-site branch.
+   * See ssrTemplate -> jsDelivr
+  */
+   ssrTemplate
 };

Reply via email to