This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git
The following commit(s) were added to refs/heads/master by this push:
new a866f92141b chore: add .htaccess (#1067)
a866f92141b is described below
commit a866f92141b3ba17a603d470d1ed27f5fc9204f8
Author: Young <[email protected]>
AuthorDate: Fri May 6 10:38:37 2022 +0800
chore: add .htaccess (#1067)
---
.github/workflows/deploy.yml | 2 +-
.htaccess | 29 +++++++++++++++++++++++++++++
scripts/sync-docs.js | 17 ++++++++++-------
3 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index ad66e7a825f..fe170cd2f99 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -77,7 +77,7 @@ jobs:
- name: Build
run: |
- yarn build && cp ./.asf.yaml ./website/build
+ yarn build && cp ./.asf.yaml ./.htaccess ./website/build/
- name: Update sitemap.xml
run: |
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 00000000000..0418b600dfc
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,29 @@
+AddDefaultCharset UTF-8
+
+RedirectMatch 404 /\.git
+RedirectMatch 404 /\.gitignore
+RedirectMatch 404 /\.htaccess
+RedirectMatch 404 /\.github
+RedirectMatch 404 /\.asf\.yaml
+
+ErrorDocument 404 /404.html
+
+<IfModule mod_headers.c>
+ Header set Access-Control-Allow-Origin: https://apisix.apache.org
+ Header set Access-Control-Allow-Methods "*"
+ Header set Access-Control-Allow-Headers "*"
+</IfModule>
+
+
+<IfModule mod_expires.c>
+ ExpiresActive on
+
+ ExpiresByType text/html "access plus 1 hour"
+ ExpiresByType image/png "access plus 1 hour"
+ ExpiresByType image/jpg "access plus 1 hour"
+ ExpiresByType image/jpeg "access plus 1 hour"
+ ExpiresByType text/css "access plus 1 hour"
+ ExpiresByType application/javascript "access plus 1 hour"
+ ExpiresByType application/json "access plus 1 hour"
+ ExpiresDefault "access plus 10 days"
+</IfModule>
\ No newline at end of file
diff --git a/scripts/sync-docs.js b/scripts/sync-docs.js
index 40710e2b291..0cdc09aabff 100644
--- a/scripts/sync-docs.js
+++ b/scripts/sync-docs.js
@@ -106,7 +106,7 @@ const tasks = new Listr([
const versions =
`${websitePath}/docs-${projectName}_versions.json`;
const i18nDocs =
`${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}`;
- await Promise.all([
+ await Promise.allSettled([
removeFolder(docs),
removeFolder(sidebar),
removeFolder(i18nDocs),
@@ -215,14 +215,17 @@ async function copyFolder(srcDir, tarDir) {
fs.mkdir(tarDir, { recursive: true }),
]);
- return Promise.all(files.map(async (file) => {
+ return Promise.allSettled(files.map(async (file) => {
const srcPath = path.join(srcDir, file);
const tarPath = path.join(tarDir, file);
- const stats = await fs.stat(srcPath);
- return stats.isDirectory()
- ? copyFolder(srcPath, tarPath)
- : fs.copyFile(srcPath, tarPath);
+ if (await isDirExisted(srcPath)) {
+ return copyFolder(srcPath, tarPath);
+ }
+ if (await isFileExisted(srcPath)) {
+ return fs.copyFile(srcPath, tarPath);
+ }
+ return Promise.resolve();
}));
}
@@ -348,7 +351,7 @@ function extractDocsVersionTasks(project, version) {
const enTargetDocs =
`${websitePath}/docs-${projectName}_versioned_docs/version-${version}`;
const zhTargetDocs =
`${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}/version-${version}`;
- await Promise.all([
+ await Promise.allSettled([
copyDocs(enSrcDocs, enTargetDocs)
.then(() => replaceMDElements(projectName, [enTargetDocs],
branchName))
.then(() => handleConfig2Sidebar(enTargetDocs, enTargetDocs,
version, `${websitePath}/docs-${project.name}_versioned_sidebars`)),