Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: upload to COS #588

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
96e6bea
test: upload to COS
shhdgit Feb 7, 2025
2158daa
test: build & upload
shhdgit Feb 7, 2025
e554d31
test
shhdgit Feb 7, 2025
62747dc
test
shhdgit Feb 7, 2025
46bc1b2
test
shhdgit Feb 7, 2025
4afb41e
test
shhdgit Feb 7, 2025
fb7b2a0
test
shhdgit Feb 7, 2025
caf32a1
test
shhdgit Feb 7, 2025
4826a12
test
shhdgit Feb 7, 2025
3d52518
test
shhdgit Feb 7, 2025
aac688b
test
shhdgit Feb 7, 2025
1526783
test
shhdgit Feb 7, 2025
ec29559
test
shhdgit Feb 8, 2025
3042d88
test
shhdgit Feb 8, 2025
b2a57e3
test
shhdgit Feb 8, 2025
0eabde2
test
shhdgit Feb 8, 2025
c675f22
test
shhdgit Feb 8, 2025
c7b0073
test
shhdgit Feb 8, 2025
d8e343f
test
shhdgit Feb 8, 2025
c89aef1
test
shhdgit Feb 8, 2025
8f99881
test
shhdgit Feb 8, 2025
e7288b7
test
shhdgit Feb 8, 2025
f553866
test
shhdgit Feb 8, 2025
76b05b0
test
shhdgit Feb 8, 2025
04b3afd
test
shhdgit Feb 8, 2025
30d0542
test
shhdgit Feb 8, 2025
9c63ec9
test
shhdgit Feb 8, 2025
73d4f3d
test
shhdgit Feb 8, 2025
6d7e8a7
test
shhdgit Feb 8, 2025
156cacf
test
shhdgit Feb 8, 2025
917825e
update: archive
shhdgit Feb 8, 2025
2b2bdbb
tweak: gatsby link for trailing slash
shhdgit Feb 10, 2025
36ba9f2
tweak: purge cdn cache
shhdgit Feb 10, 2025
e0e27db
test
shhdgit Feb 10, 2025
c35ea3b
test
shhdgit Feb 10, 2025
ae4fe24
test
shhdgit Feb 10, 2025
b4fbd37
Merge branch 'master' into test/deploy-arch
shhdgit Feb 11, 2025
d23a83a
tweak: cos sync
shhdgit Feb 11, 2025
95ef101
test
shhdgit Feb 11, 2025
33300b6
test
shhdgit Feb 11, 2025
7941e71
test
shhdgit Feb 11, 2025
bc9a469
fix: gatsby-link patch
shhdgit Feb 11, 2025
41b220f
test
shhdgit Feb 11, 2025
b772eee
test
shhdgit Feb 12, 2025
89948af
update: nocache
shhdgit Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,50 @@ jobs:
GATSBY_DOC_BUILD_SUBMODULE_SHA: ${{ steps.submodule.outputs.submodule_status }}
WEBSITE_BUILD_TYPE: archive
run: |
yarn build --verbose
yarn build

- name: Check output
id: check-output
run: |
sudo apt install tree
tree public

- name: Set known_hosts
id: known-hosts
- name: Install coscli
run: |
echo "BJ1=$(ssh-keyscan -H ${{ secrets.BJ_1_HOST }})" >> $GITHUB_OUTPUT
echo "BJ2=$(ssh-keyscan -H ${{ secrets.BJ_2_HOST }})" >> $GITHUB_OUTPUT
echo "LA1=$(ssh-keyscan -H ${{ secrets.LA_1_HOST }})" >> $GITHUB_OUTPUT
echo "LA2=$(ssh-keyscan -H ${{ secrets.LA_2_HOST }})" >> $GITHUB_OUTPUT
wget https://cosbrowser.cloud.tencent.com/software/coscli/coscli-linux-amd64
mv coscli-linux-amd64 coscli
chmod 755 coscli

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: |
${{ steps.known-hosts.outputs.BJ1 }}
${{ steps.known-hosts.outputs.BJ2 }}
${{ steps.known-hosts.outputs.LA1 }}
${{ steps.known-hosts.outputs.LA2 }}

- name: Deploy to BJ1
- name: Deploy to COS
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.BJ_1_HOST }}:${{ secrets.DEPLOY_PATH_ARCHIVE }}"
./coscli sync public/ cos://${{ secrets.TENCENTCLOUD_ARCHIVE_BUCKET_ID }} \
--init-skip \
--recursive \
--routines 16 \
--secret-id ${{ secrets.TENCENTCLOUD_SECRET_ID }} \
--secret-key ${{ secrets.TENCENTCLOUD_SECRET_KEY }} \
--endpoint cos.na-ashburn.myqcloud.com

- name: Deploy to BJ2
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.BJ_2_HOST }}:${{ secrets.DEPLOY_PATH_ARCHIVE }}"
cdn-refresh:
needs: build
runs-on: ubuntu-latest
name: Refresh CDN Cache
env:
TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Deploy to LA1
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.LA_1_HOST }}:${{ secrets.DEPLOY_PATH_ARCHIVE }}"
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'

- name: Install Tencent Cloud CLI
run: pipx install tccli

- name: Purge production CDN cache
run: tccli cdn PurgePathCache --Paths '["https://docs-archive.pingcap.com/"]' --FlushType delete

- name: Deploy to LA2
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.LA_2_HOST }}:${{ secrets.DEPLOY_PATH_ARCHIVE }}"
75 changes: 45 additions & 30 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
type: boolean
default: false
required: false
nocache:
description: "Build without cache"
type: boolean
default: false
required: false

concurrency: ci-prod

Expand All @@ -33,7 +38,7 @@ jobs:

- uses: actions/checkout@v3
with:
ref: "master"
ref: "test/deploy-arch"
- uses: actions/setup-node@v3
with:
node-version: 16
Expand All @@ -45,7 +50,7 @@ jobs:
git submodule init
git submodule update --remote
cd docs
git checkout main
git checkout new-deploy-arch
cd ..
echo "submodule_sha=$(git submodule status | awk '{print $1}' | sed -r 's/[+-]+//g')" >> $GITHUB_OUTPUT
echo "submodule_status=$(git submodule status)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -81,6 +86,11 @@ jobs:
sudo rm -rf /tmp/*
sudo rm -rf /home/runner/work/_temp/*

- name: Clean cache
if: ${{ inputs.nocache }}
run: |
yarn clean

- name: Build website
if: ${{ !inputs.fallback || (steps.gatsby-cache.outputs.cache-hit != 'true') }}
env:
Expand All @@ -92,44 +102,49 @@ jobs:
GATSBY_DOC_BUILD_SUBMODULE_SHA: ${{ steps.submodule.outputs.submodule_status }}
GATSBY_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
yarn build --verbose
yarn build

- name: Check output
id: check-output
run: |
sudo apt install tree
tree public

- name: Set known_hosts
id: known-hosts
- name: Install coscli
run: |
echo "BJ1=$(ssh-keyscan -H ${{ secrets.BJ_1_HOST }})" >> $GITHUB_OUTPUT
echo "BJ2=$(ssh-keyscan -H ${{ secrets.BJ_2_HOST }})" >> $GITHUB_OUTPUT
echo "LA1=$(ssh-keyscan -H ${{ secrets.LA_1_HOST }})" >> $GITHUB_OUTPUT
echo "LA2=$(ssh-keyscan -H ${{ secrets.LA_2_HOST }})" >> $GITHUB_OUTPUT
wget https://cosbrowser.cloud.tencent.com/software/coscli/coscli-linux-amd64
mv coscli-linux-amd64 coscli
chmod 755 coscli

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: |
${{ steps.known-hosts.outputs.BJ1 }}
${{ steps.known-hosts.outputs.BJ2 }}
${{ steps.known-hosts.outputs.LA1 }}
${{ steps.known-hosts.outputs.LA2 }}

- name: Deploy to BJ1
- name: Deploy to COS
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.BJ_1_HOST }}:${{ secrets.DEPLOY_PATH }}"
./coscli sync public/ cos://${{ secrets.TENCENTCLOUD_BUCKET_ID }} \
--init-skip \
--recursive \
--routines 16 \
--secret-id ${{ secrets.TENCENTCLOUD_SECRET_ID }} \
--secret-key ${{ secrets.TENCENTCLOUD_SECRET_KEY }} \
--endpoint cos.na-ashburn.myqcloud.com

cdn-refresh:
needs: build
runs-on: ubuntu-latest
name: Refresh CDN Cache
env:
TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Deploy to BJ2
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.BJ_2_HOST }}:${{ secrets.DEPLOY_PATH }}"
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'

- name: Deploy to LA1
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.LA_1_HOST }}:${{ secrets.DEPLOY_PATH }}"
- name: Install Tencent Cloud CLI
run: pipx install tccli

- name: Deploy to LA2
run: |
rsync -avz --delete public/ "${{ secrets.SSH_USER }}@${{ secrets.LA_2_HOST }}:${{ secrets.DEPLOY_PATH }}"
- name: Purge production CDN cache
run: tccli cdn PurgePathCache --Paths '["https://docs-preview.pingcap.com/"]' --FlushType delete
26 changes: 12 additions & 14 deletions .github/workflows/upload-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: Build website
name: Upload to COS
steps:
- uses: actions/checkout@v3
with:
ref: "master"

- name: Set known_hosts
id: known-hosts
- name: Install coscli
run: |
echo "BJ1=$(ssh-keyscan -H ${{ secrets.BJ_1_HOST }})" >> $GITHUB_OUTPUT
wget https://cosbrowser.cloud.tencent.com/software/coscli/coscli-linux-amd64
mv coscli-linux-amd64 coscli
chmod 755 coscli

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: |
${{ steps.known-hosts.outputs.BJ1 }}

- name: Deploy to BJ1
- name: Upload test file
run: |
rsync -avz --delete README.md "${{ secrets.SSH_USER }}@${{ secrets.BJ_1_HOST }}:${{ secrets.DEPLOY_PATH }}"

./coscli cp README.md cos://${{ secrets.TENCENTCLOUD_BUCKET_ID }}/README.md \
--init-skip \
--recursive \
--secret-id ${{ secrets.TENCENTCLOUD_SECRET_ID }} \
--secret-key ${{ secrets.TENCENTCLOUD_SECRET_KEY }} \
--endpoint cos.na-ashburn.myqcloud.com
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require("ts-node").register({ transpileOnly: true });
const docs = require("./docs/docs.json");

module.exports = {
trailingSlash: "always",
siteMetadata: {
title:
process.env.WEBSITE_BUILD_TYPE === "archive"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"axios": "^0.24.0",
"clsx": "^1.1.1",
"copy-to-clipboard": "^3.3.1",
"gatsby": "^4.4.0",
"gatsby": "^4.13.0",
"gatsby-plugin-google-analytics": "^4.12.1",
"gatsby-plugin-google-tagmanager": "^4.12.1",
"gatsby-plugin-material-ui": "^4.0.2",
Expand Down Expand Up @@ -86,6 +86,7 @@
"husky": "^7.0.4",
"is-ci": "^3.0.1",
"lint-staged": "^12.1.2",
"patch-package": "^8.0.0",
"pegjs": "^0.10.0",
"prettier": "2.5.1",
"sass": "^1.45.0",
Expand All @@ -97,6 +98,7 @@
],
"license": "MIT",
"scripts": {
"postinstall": "patch-package",
"start": "gatsby develop",
"start:0.0.0.0": "gatsby develop -H 0.0.0.0",
"build": "gatsby build",
Expand Down
9 changes: 9 additions & 0 deletions patches/gatsby-link+4.25.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/node_modules/gatsby-link/dist/index.modern.mjs b/node_modules/gatsby-link/dist/index.modern.mjs
index d6061b8..056e3f5 100644
--- a/node_modules/gatsby-link/dist/index.modern.mjs
+++ b/node_modules/gatsby-link/dist/index.modern.mjs
@@ -1,3 +1,3 @@
"client export"
-import t from"prop-types";import e from"react";import{resolve as n,Location as r,Link as o}from"@gatsbyjs/reach-router";import{applyTrailingSlashOption as s}from"gatsby-page-utils/apply-trailing-slash-option";function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function a(t){let e=t||"/",n="",r="";const o=e.indexOf("#");-1!==o&&(r=e.slice(o),e=e.slice(0,o));const s=e.indexOf("?");return-1!==s&&(n=e.slice(s),e=e.slice(0,s)),{pathname:e,search:"?"===n?"":n,hash:"#"===r?"":r}}const c=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=t=>{if("string"==typeof t)return!(t=>c.test(t))(t)},p=()=>"production"!==process.env.NODE_ENV?"undefined"!=typeof __PATH_PREFIX__?__PATH_PREFIX__:void 0:__PATH_PREFIX__;function h(t,e=(()=>"production"!==process.env.NODE_ENV?"undefined"!=typeof __BASE_PATH__?__BASE_PATH__:void 0:__BASE_PATH__)()){var n;if(!l(t))return t;if(t.startsWith("./")||t.startsWith("../"))return t;const r=null!=(n=null!=e?e:p())?n:"/";return`${null!=r&&r.endsWith("/")?r.slice(0,-1):r}${t.startsWith("/")?t:`/${t}`}`}const f=t=>null==t?void 0:t.startsWith("/"),u=()=>"undefined"!=typeof __TRAILING_SLASH__?__TRAILING_SLASH__:void 0,_=(t,e)=>"number"==typeof t?t:l(t)?f(t)?function(t){const e=h(t),n=u();if("always"===n||"never"===n){const{pathname:t,search:r,hash:o}=a(e);return`${s(t,n)}${r}${o}`}return e}(t):function(t,e){if(f(t))return t;const r=u(),o=n(t,e);return"always"===r||"never"===r?s(o,r):o}(t,e):t,d=["to","getProps","onClick","onMouseEnter","activeClassName","activeStyle","innerRef","partiallyActive","state","replace","_location"];function m(t){return h(t,p())}const y={activeClassName:t.string,activeStyle:t.object,partiallyActive:t.bool};function v(t){/*#__PURE__*/return e.createElement(r,null,({location:n})=>/*#__PURE__*/e.createElement(b,i({},t,{_location:n})))}class b extends e.Component{constructor(t){super(t),this.defaultGetProps=({isPartiallyCurrent:t,isCurrent:e})=>(this.props.partiallyActive?t:e)?{className:[this.props.className,this.props.activeClassName].filter(Boolean).join(" "),style:i({},this.props.style,this.props.activeStyle)}:null;let e=!1;"undefined"!=typeof window&&window.IntersectionObserver&&(e=!0),this.state={IOSupported:e},this.abortPrefetch=null,this.handleRef=this.handleRef.bind(this)}_prefetch(){let t=window.location.pathname+window.location.search;this.props._location&&this.props._location.pathname&&(t=this.props._location.pathname+this.props._location.search);const e=a(_(this.props.to,t)),n=e.pathname+e.search;if(t!==n)return ___loader.enqueue(n)}componentWillUnmount(){if(!this.io)return;const{instance:t,el:e}=this.io;this.abortPrefetch&&this.abortPrefetch.abort(),t.unobserve(e),t.disconnect()}handleRef(t){this.props.innerRef&&Object.prototype.hasOwnProperty.call(this.props.innerRef,"current")?this.props.innerRef.current=t:this.props.innerRef&&this.props.innerRef(t),this.state.IOSupported&&t&&(this.io=((t,e)=>{const n=new window.IntersectionObserver(n=>{n.forEach(n=>{t===n.target&&e(n.isIntersecting||n.intersectionRatio>0)})});return n.observe(t),{instance:n,el:t}})(t,t=>{t?this.abortPrefetch=this._prefetch():this.abortPrefetch&&this.abortPrefetch.abort()}))}render(){const t=this.props,{to:n,getProps:r=this.defaultGetProps,onClick:s,onMouseEnter:c,state:p,replace:h,_location:f}=t,u=function(t,e){if(null==t)return{};var n,r,o={},s=Object.keys(t);for(r=0;r<s.length;r++)e.indexOf(n=s[r])>=0||(o[n]=t[n]);return o}(t,d);"production"===process.env.NODE_ENV||l(n)||console.warn(`External link ${n} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`);const m=_(n,f.pathname);return l(m)?/*#__PURE__*/e.createElement(o,i({to:m,state:p,getProps:r,innerRef:this.handleRef,onMouseEnter:t=>{c&&c(t);const e=a(m);___loader.hovering(e.pathname+e.search)},onClick:t=>{if(s&&s(t),!(0!==t.button||this.props.target||t.defaultPrevented||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)){t.preventDefault();let e=h;const n=encodeURI(m)===f.pathname;"boolean"!=typeof h&&n&&(e=!0),window.___navigate(m,{state:p,replace:e})}return!0}},u)):/*#__PURE__*/e.createElement("a",i({href:m},u))}}b.propTypes=i({},y,{onClick:t.func,to:t.string.isRequired,replace:t.bool,state:t.object});var w=e.forwardRef((t,n)=>/*#__PURE__*/e.createElement(v,i({innerRef:n},t)));const P=(t,e)=>{window.___navigate(_(t,window.location.pathname),e)};export{w as default,P as navigate,a as parsePath,m as withAssetPrefix,h as withPrefix};
+import t from"prop-types";import e from"react";import{resolve as n,Location as r,Link as o}from"@gatsbyjs/reach-router";import{applyTrailingSlashOption as s}from"gatsby-page-utils/apply-trailing-slash-option";function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function a(t){let e=t||"/",n="",r="";const o=e.indexOf("#");-1!==o&&(r=e.slice(o),e=e.slice(0,o));const s=e.indexOf("?");return-1!==s&&(n=e.slice(s),e=e.slice(0,s)),{pathname:e,search:"?"===n?"":n,hash:"#"===r?"":r}}const c=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=t=>{if("string"==typeof t)return!(t=>c.test(t))(t)},p=()=>"production"!==process.env.NODE_ENV?"undefined"!=typeof __PATH_PREFIX__?__PATH_PREFIX__:void 0:__PATH_PREFIX__;function h(t,e=(()=>"production"!==process.env.NODE_ENV?"undefined"!=typeof __BASE_PATH__?__BASE_PATH__:void 0:__BASE_PATH__)()){var n;if(!l(t))return t;if(t.startsWith("./")||t.startsWith("../"))return t;const r=null!=(n=null!=e?e:p())?n:"/";return`${null!=r&&r.endsWith("/")?r.slice(0,-1):r}${t.startsWith("/")?t:`/${t}`}`}const f=t=>null==t?void 0:t.startsWith("/"),u=()=>"undefined"!=typeof __TRAILING_SLASH__?__TRAILING_SLASH__:void 0,_=(t,e)=>"number"==typeof t?t:l(t)?f(t)?function(t){const e=h(t),n=u();if("always"===n||"never"===n){const{pathname:t,search:r,hash:o}=a(e);return`${s(t,n)}${r}${o}`}return e}(t):function(t,e){if(f(t))return t;const r=u(),o=n(t,e);const {pathname,search,hash}=a(o);return"always"===r||"never"===r?`${s(pathname,r)}${search}${hash}`:o}(t,e):t,d=["to","getProps","onClick","onMouseEnter","activeClassName","activeStyle","innerRef","partiallyActive","state","replace","_location"];function m(t){return h(t,p())}const y={activeClassName:t.string,activeStyle:t.object,partiallyActive:t.bool};function v(t){/*#__PURE__*/return e.createElement(r,null,({location:n})=>/*#__PURE__*/e.createElement(b,i({},t,{_location:n})))}class b extends e.Component{constructor(t){super(t),this.defaultGetProps=({isPartiallyCurrent:t,isCurrent:e})=>(this.props.partiallyActive?t:e)?{className:[this.props.className,this.props.activeClassName].filter(Boolean).join(" "),style:i({},this.props.style,this.props.activeStyle)}:null;let e=!1;"undefined"!=typeof window&&window.IntersectionObserver&&(e=!0),this.state={IOSupported:e},this.abortPrefetch=null,this.handleRef=this.handleRef.bind(this)}_prefetch(){let t=window.location.pathname+window.location.search;this.props._location&&this.props._location.pathname&&(t=this.props._location.pathname+this.props._location.search);const e=a(_(this.props.to,t)),n=e.pathname+e.search;if(t!==n)return ___loader.enqueue(n)}componentWillUnmount(){if(!this.io)return;const{instance:t,el:e}=this.io;this.abortPrefetch&&this.abortPrefetch.abort(),t.unobserve(e),t.disconnect()}handleRef(t){this.props.innerRef&&Object.prototype.hasOwnProperty.call(this.props.innerRef,"current")?this.props.innerRef.current=t:this.props.innerRef&&this.props.innerRef(t),this.state.IOSupported&&t&&(this.io=((t,e)=>{const n=new window.IntersectionObserver(n=>{n.forEach(n=>{t===n.target&&e(n.isIntersecting||n.intersectionRatio>0)})});return n.observe(t),{instance:n,el:t}})(t,t=>{t?this.abortPrefetch=this._prefetch():this.abortPrefetch&&this.abortPrefetch.abort()}))}render(){const t=this.props,{to:n,getProps:r=this.defaultGetProps,onClick:s,onMouseEnter:c,state:p,replace:h,_location:f}=t,u=function(t,e){if(null==t)return{};var n,r,o={},s=Object.keys(t);for(r=0;r<s.length;r++)e.indexOf(n=s[r])>=0||(o[n]=t[n]);return o}(t,d);"production"===process.env.NODE_ENV||l(n)||console.warn(`External link ${n} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`);const m=_(n,f.pathname);return l(m)?/*#__PURE__*/e.createElement(o,i({to:m,state:p,getProps:r,innerRef:this.handleRef,onMouseEnter:t=>{c&&c(t);const e=a(m);___loader.hovering(e.pathname+e.search)},onClick:t=>{if(s&&s(t),!(0!==t.button||this.props.target||t.defaultPrevented||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)){t.preventDefault();let e=h;const n=encodeURI(m)===f.pathname;"boolean"!=typeof h&&n&&(e=!0),window.___navigate(m,{state:p,replace:e})}return!0}},u)):/*#__PURE__*/e.createElement("a",i({href:m},u))}}b.propTypes=i({},y,{onClick:t.func,to:t.string.isRequired,replace:t.bool,state:t.object});var w=e.forwardRef((t,n)=>/*#__PURE__*/e.createElement(v,i({innerRef:n},t)));const P=(t,e)=>{window.___navigate(_(t,window.location.pathname),e)};export{w as default,P as navigate,a as parsePath,m as withAssetPrefix,h as withPrefix};
//# sourceMappingURL=index.modern.mjs.map
Loading