You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by bz...@apache.org on 2022/07/26 06:55:18 UTC
[apisix-website] branch master updated: fix: htaccess, deploy.yml, scripts, LazyLoadImage (#1237)
This is an automated email from the ASF dual-hosted git repository.
bzp2010 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 72f69e22094 fix: htaccess, deploy.yml, scripts, LazyLoadImage (#1237)
72f69e22094 is described below
commit 72f69e220947f4f8d8724e3191d799a062393727
Author: Young <is...@outlook.com>
AuthorDate: Tue Jul 26 14:55:13 2022 +0800
fix: htaccess, deploy.yml, scripts, LazyLoadImage (#1237)
---
.github/workflows/deploy.yml | 9 ++-
.htaccess | 4 +-
doc/src/theme/DocPage/index.tsx | 174 ++++++++++++++++++++++------------------
package.json | 3 +-
4 files changed, 104 insertions(+), 86 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 0f2e6fb741e..ac493853e75 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -50,7 +50,11 @@ jobs:
- name: Cache install
uses: actions/cache@v3
with:
- path: ./node_modules
+ path: |
+ ./node_modules
+ ./doc/node_modules
+ ./website/node_modules
+ ./blog/node_modules
key: ${{ runner.os }}-dep-${{ steps.node-version.outputs.ver }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
@@ -86,11 +90,8 @@ jobs:
path: |
./website/.docusaurus
./website/build
- ./website/node_modules
./doc/.docusaurus
./doc/build
- ./doc/node_modules
- ./blog/node_modules
./blog/en/.docusaurus
./blog/en/build
./blog/zh/.docusaurus
diff --git a/.htaccess b/.htaccess
index 2aada8315bf..28584c99e96 100644
--- a/.htaccess
+++ b/.htaccess
@@ -43,7 +43,7 @@ Redirect 301 "/blog/2021/08/14/contributors-the-golden-metric-of-openSource-proj
Redirect 301 "/blog/2022/02/10/apisix-splunk-integration/" "/blog/2022/02/10/splunk-apisix-integration/"
Redirect 301 "/blog/2021/08/31/Apache%20APISIX%20×%20KubeSphere-a-better-gateway-and-K8S-Ingress-Controller/" "/blog/2021/08/31/apache-apisix-kubeSphere-a-better-gateway-and-k8s-ingress-controller/"
Redirect 301 "/blog/2021/11/30/use-apisix-ingress-in-kubesphere/httpbin.org/" "/blog/2021/11/30/use-apisix-ingress-in-kubesphere/"
-Redirect 301 "/blog/2021/08/18/auth-with-casbin-in-apache-apisix/" "/blog/2021/08/25/Auth-with-Casbin-in-Apache-APISIX/"
+Redirect 301 "/blog/2021/08/25/Auth-with-Casbin-in-Apache-APISIX/" "/blog/2021/08/18/auth-with-casbin-in-apache-apisix/"
Redirect 301 "/zh/docs/apisix/install" "/zh/docs/apisix/how-to-build/"
Redirect 301 "/zh/docs/apisix/architecture-design/plugin/" "/zh/docs/apisix/architecture-design/plugin-config/"
@@ -54,4 +54,4 @@ Redirect 301 "/zh/blog/2021/08/14/contributors-the-golden-metric-of-openSource-p
Redirect 301 "/zh/blog/2022/02/10/apisix-splunk-integration/" "/zh/blog/2022/02/10/splunk-apisix-integration/"
Redirect 301 "/zh/blog/2021/08/31/Apache%20APISIX%20×%20KubeSphere-a-better-gateway-and-K8S-Ingress-Controller/" "/zh/blog/2021/08/31/apache-apisix-kubeSphere-a-better-gateway-and-k8s-ingress-controller/"
Redirect 301 "/zh/blog/2021/11/30/use-apisix-ingress-in-kubesphere/httpbin.org/" "/zh/blog/2021/11/30/use-apisix-ingress-in-kubesphere/"
-Redirect 301 "/zh/blog/2021/08/18/auth-with-casbin-in-apache-apisix/" "/zh/blog/2021/08/25/Auth-with-Casbin-in-Apache-APISIX"
+Redirect 301 "/zh/blog/2021/08/25/Auth-with-Casbin-in-Apache-APISIX/" "/zh/blog/2021/08/18/auth-with-casbin-in-apache-apisix/"
diff --git a/doc/src/theme/DocPage/index.tsx b/doc/src/theme/DocPage/index.tsx
index f9150af4e83..a21d9ce464f 100644
--- a/doc/src/theme/DocPage/index.tsx
+++ b/doc/src/theme/DocPage/index.tsx
@@ -1,3 +1,5 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
@@ -29,12 +31,13 @@ import { LazyLoadImage } from 'react-lazy-load-image-component';
import NotFound from '../NotFound';
import styles from './styles.module.css';
+import 'react-lazy-load-image-component/src/effects/blur.css';
- type DocPageContentProps = {
- readonly currentDocRoute: DocumentRoute;
- readonly versionMetadata: PropVersionMetadata;
- readonly children: ReactNode;
- };
+type DocPageContentProps = {
+ readonly currentDocRoute: DocumentRoute;
+ readonly versionMetadata: PropVersionMetadata;
+ readonly children: ReactNode;
+};
const navbarLinkMap = {
general: 'General',
@@ -52,7 +55,27 @@ const navbarLinkKeys = Object.keys(navbarLinkMap);
const components = {
...MDXComponents,
- img: (props: ImageProps) => <LazyLoadImage {...props as any} />,
+ img: (props: ImageProps) => (
+ <LazyLoadImage
+ effect="blur"
+ placeholder={(
+ <div>
+ <noscript>
+ <img alt="placeholder" {...(props as any)} />
+ </noscript>
+ <div
+ style={{
+ width: 500,
+ height: 300,
+ borderRadius: '1rem',
+ backgroundColor: '#d2d2d7',
+ }}
+ />
+ </div>
+ )}
+ {...(props as any)}
+ />
+ ),
};
const DocPageContent = ({
@@ -62,20 +85,23 @@ const DocPageContent = ({
}: DocPageContentProps): JSX.Element => {
const { pluginId, version } = versionMetadata;
const sidebarName = currentDocRoute.sidebar;
- const sidebar = sidebarName
- ? versionMetadata.docsSidebars[sidebarName]
- : undefined;
+ const sidebar = sidebarName ? versionMetadata.docsSidebars[sidebarName] : undefined;
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
const [hiddenSidebar, setHiddenSidebar] = useState(false);
useEffect(() => {
const childrenCount = document.querySelector('.navbar__items--right').childElementCount;
- const el = document.querySelector('.navbar__items--right').childNodes[childrenCount - 2] as HTMLDivElement;
+ const el = document.querySelector('.navbar__items--right').childNodes[
+ childrenCount - 2
+ ] as HTMLDivElement;
el.style.display = window.innerWidth > 745 ? 'block' : 'none';
const pathArr = currentDocRoute.path.split('/').slice(2, 4);
- const currentPage = pathArr.reduce((res, cur) => (navbarLinkKeys.includes(cur) ? cur : res), '');
+ const currentPage = pathArr.reduce(
+ (res, cur) => (navbarLinkKeys.includes(cur) ? cur : res),
+ '',
+ );
const navbarLink = document.querySelectorAll('.navbar__link')[0] as HTMLAnchorElement;
navbarLink.innerText = navbarLinkMap[currentPage];
@@ -94,8 +120,8 @@ const DocPageContent = ({
return (
<Layout
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
wrapperClassName={ThemeClassNames.wrapper.docsPages}
pageClassName={ThemeClassNames.page.docsDocPage}
searchMetadatas={{
@@ -107,76 +133,69 @@ const DocPageContent = ({
<BackToTopButton />
{sidebar && (
- <aside
- className={clsx(styles.docSidebarContainer, {
- [styles.docSidebarContainerHidden]: hiddenSidebarContainer,
- })}
- onTransitionEnd={(e) => {
- if (
- !e.currentTarget.classList.contains(styles.docSidebarContainer)
- ) {
- return;
- }
-
- if (hiddenSidebarContainer) {
- setHiddenSidebar(true);
- }
- }}
- >
- <DocSidebar
- key={
- // Reset sidebar state on sidebar changes
- // See https://github.com/facebook/docusaurus/issues/3414
- sidebarName
- }
- sidebar={sidebar}
- path={currentDocRoute.path}
- onCollapse={toggleSidebar}
- isHidden={hiddenSidebar}
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- docsPluginId={pluginId}
- />
-
- {hiddenSidebar && (
- <div
- className={styles.collapsedDocSidebar}
- title={translate({
- id: 'theme.docs.sidebar.expandButtonTitle',
- message: 'Expand sidebar',
- description:
- 'The ARIA label and title attribute for expand button of doc sidebar',
+ <aside
+ className={clsx(styles.docSidebarContainer, {
+ [styles.docSidebarContainerHidden]: hiddenSidebarContainer,
})}
- aria-label={translate({
- id: 'theme.docs.sidebar.expandButtonAriaLabel',
- message: 'Expand sidebar',
- description:
- 'The ARIA label and title attribute for expand button of doc sidebar',
- })}
- tabIndex={0}
- role="button"
- onKeyDown={toggleSidebar}
- onClick={toggleSidebar}
+ onTransitionEnd={(e) => {
+ if (!e.currentTarget.classList.contains(styles.docSidebarContainer)) {
+ return;
+ }
+
+ if (hiddenSidebarContainer) {
+ setHiddenSidebar(true);
+ }
+ }}
>
- <IconArrow className={styles.expandSidebarButtonIcon} />
- </div>
- )}
- </aside>
+ <DocSidebar
+ key={
+ // Reset sidebar state on sidebar changes
+ // See https://github.com/facebook/docusaurus/issues/3414
+ sidebarName
+ }
+ sidebar={sidebar}
+ path={currentDocRoute.path}
+ onCollapse={toggleSidebar}
+ isHidden={hiddenSidebar}
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ docsPluginId={pluginId}
+ />
+
+ {hiddenSidebar && (
+ <div
+ className={styles.collapsedDocSidebar}
+ title={translate({
+ id: 'theme.docs.sidebar.expandButtonTitle',
+ message: 'Expand sidebar',
+ description:
+ 'The ARIA label and title attribute for expand button of doc sidebar',
+ })}
+ aria-label={translate({
+ id: 'theme.docs.sidebar.expandButtonAriaLabel',
+ message: 'Expand sidebar',
+ description:
+ 'The ARIA label and title attribute for expand button of doc sidebar',
+ })}
+ tabIndex={0}
+ role="button"
+ onKeyDown={toggleSidebar}
+ onClick={toggleSidebar}
+ >
+ <IconArrow className={styles.expandSidebarButtonIcon} />
+ </div>
+ )}
+ </aside>
)}
<main
className={clsx(styles.docMainContainer, {
- [styles.docMainContainerEnhanced]:
- hiddenSidebarContainer || !sidebar,
+ [styles.docMainContainerEnhanced]: hiddenSidebarContainer || !sidebar,
})}
>
<div
- className={clsx(
- 'container padding-top--md padding-bottom--lg',
- styles.docItemWrapper,
- {
- [styles.docItemWrapperEnhanced]: hiddenSidebarContainer,
- },
- )}
+ className={clsx('container padding-top--md padding-bottom--lg', styles.docItemWrapper, {
+ [styles.docItemWrapperEnhanced]: hiddenSidebarContainer,
+ })}
>
<MDXProvider components={components}>{children}</MDXProvider>
</div>
@@ -205,10 +224,7 @@ const DocPage = (props: Props): JSX.Element => {
{/* eslint-disable-next-line jsx-a11y/html-has-lang */}
<html className={versionMetadata.className} />
</Head>
- <DocPageContent
- currentDocRoute={currentDocRoute}
- versionMetadata={versionMetadata}
- >
+ <DocPageContent currentDocRoute={currentDocRoute} versionMetadata={versionMetadata}>
{renderRoutes(docRoutes, { versionMetadata })}
</DocPageContent>
</>
diff --git a/package.json b/package.json
index 90f61fd6ea2..baea5f850d0 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,8 @@
"sync-doc": "yarn workspace scripts sync",
"generate-repos-info": "yarn workspace scripts generate-repos-info",
"update-sitemap": "yarn workspace scripts update-sitemap",
- "start:docs": "yarn workspace website start",
+ "start:doc": "yarn workspace doc start",
+ "start:website": "yarn workspace website start",
"start:blog:zh": "yarn workspace blog start:zh",
"start:blog:en": "yarn workspace blog start:en",
"build": "yarn workspace scripts generate-website",