From 9329ddeac575081cebf813d0308ef19dee0ff022 Mon Sep 17 00:00:00 2001 From: Carson Yang Date: Fri, 5 Jan 2024 22:31:17 +0800 Subject: [PATCH] docs: update cdn link (#698) Signed-off-by: Carson Yang --- .github/sync_imgs.yml | 4 ++ .github/workflows/deploy-docs.yml | 4 ++ .github/workflows/deploy-preview.yml | 4 ++ .github/workflows/sync_imgs.yml | 35 ++++++++++++++++++ .../{sealos_price.png => sealos_price.jpg} | Bin docSite/content/docs/commercial/intro.md | 2 +- docSite/content/docs/course/websync.md | 6 +-- .../layouts/docs/_markup/render-image.html | 32 ++++++++++++++++ .../partials/docs/footer/footer-scripts.html | 2 +- docSite/layouts/partials/docs/head.html | 2 +- docSite/static/js/jsdelivr-auto-fallback.js | 8 ++-- 11 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 .github/sync_imgs.yml create mode 100644 .github/workflows/sync_imgs.yml rename docSite/assets/imgs/{sealos_price.png => sealos_price.jpg} (100%) create mode 100644 docSite/layouts/docs/_markup/render-image.html diff --git a/.github/sync_imgs.yml b/.github/sync_imgs.yml new file mode 100644 index 000000000..e1655d4f1 --- /dev/null +++ b/.github/sync_imgs.yml @@ -0,0 +1,4 @@ +yangchuansheng/fastgpt-imgs: + - source: docSite/assets/imgs/ + dest: imgs/ + deleteOrphaned: true \ No newline at end of file diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 5451642b3..b306ef570 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -45,6 +45,10 @@ jobs: - 'docSite/content/docs/**' base: main + - name: Add cdn for images + run: | + sed -i "s#\](/imgs/#\](https://cdn.jsdelivr.us/gh/yangchuansheng/fastgpt-imgs@main/imgs/#g" $(grep -rl "\](/imgs/" docSite/content/docs) + # Step 3 - Install Hugo (specific version) - name: Install Hugo uses: peaceiris/actions-hugo@v2 diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index b22f7ae27..08929fa0a 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -45,6 +45,10 @@ jobs: - 'docSite/content/docs/**' base: main + - name: Add cdn for images + run: | + sed -i "s#\](/imgs/#\](https://cdn.jsdelivr.us/gh/yangchuansheng/fastgpt-imgs@main/imgs/#g" $(grep -rl "\](/imgs/" docSite/content/docs) + # Step 3 - Install Hugo (specific version) - name: Install Hugo uses: peaceiris/actions-hugo@v2 diff --git a/.github/workflows/sync_imgs.yml b/.github/workflows/sync_imgs.yml new file mode 100644 index 000000000..19dc28ab2 --- /dev/null +++ b/.github/workflows/sync_imgs.yml @@ -0,0 +1,35 @@ +name: Sync images +on: + pull_request_target: + branches: + - main + paths: + - docSite/assets/imgs/** + push: + branches: + - main + paths: + - docSite/assets/imgs/** + workflow_dispatch: +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + if: ${{ (github.event_name == 'pull_request_target') }} + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + - name: Checkout + uses: actions/checkout@v3 + + - name: Run GitHub File Sync + uses: BetaHuhn/repo-file-sync-action@v1.21.0 + with: + GH_PAT: ${{ secrets.IMG_GH_PAT }} + CONFIG_PATH: .github/sync_imgs.yml + ORIGINAL_MESSAGE: true + SKIP_PR: true + COMMIT_EACH_FILE: false \ No newline at end of file diff --git a/docSite/assets/imgs/sealos_price.png b/docSite/assets/imgs/sealos_price.jpg similarity index 100% rename from docSite/assets/imgs/sealos_price.png rename to docSite/assets/imgs/sealos_price.jpg diff --git a/docSite/content/docs/commercial/intro.md b/docSite/content/docs/commercial/intro.md index 353c89452..53fc2ed21 100644 --- a/docSite/content/docs/commercial/intro.md +++ b/docSite/content/docs/commercial/intro.md @@ -93,4 +93,4 @@ FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。 Sealos 云服务属于按量计费,下面是它的价格表: -![](/imgs/sealos_price.png) +![](/imgs/sealos_price.jpg) diff --git a/docSite/content/docs/course/websync.md b/docSite/content/docs/course/websync.md index 9278ace82..3ecc033b3 100644 --- a/docSite/content/docs/course/websync.md +++ b/docSite/content/docs/course/websync.md @@ -25,13 +25,13 @@ curl https://doc.fastgpt.in/docs/intro/ ### 1. 新建知识库,选择 Web 站点同步 -![](/imgs/webSync2.jpg) +![](/imgs/webSync2.png) -![](/imgs/webSync3.jpg) +![](/imgs/webSync3.png) ### 2. 点击配置站点信息 -![](/imgs/webSync4.jpg) +![](/imgs/webSync4.png) ### 3. 填写网址和选择器 diff --git a/docSite/layouts/docs/_markup/render-image.html b/docSite/layouts/docs/_markup/render-image.html new file mode 100644 index 000000000..e78ae5a00 --- /dev/null +++ b/docSite/layouts/docs/_markup/render-image.html @@ -0,0 +1,32 @@ +{{ $dest := .Destination }} +{{ $text := .PlainText }} +{{ $url := urls.Parse $dest }} + +{{ if .Title }} +
+ {{ if eq $url.Scheme "" }} + {{ with $image := resources.Get $dest }} + {{ if eq $image.MediaType.SubType "svg" }} + {{ $image.Content | safeHTML }} + {{ else }} + {{ $text }} + {{ end }} + {{ end }} + {{ else }} + {{ $text }} + {{ end }} +
{{ .Title | markdownify }}
+
+{{ else }} + {{ if eq $url.Scheme "" }} + {{ with $image := resources.Get $dest }} + {{ if eq $image.MediaType.SubType "svg" }} + {{ $image.Content | safeHTML }} + {{ else }} + {{ $text }} + {{ end }} + {{ end }} + {{ else }} + {{ $text }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/docSite/layouts/partials/docs/footer/footer-scripts.html b/docSite/layouts/partials/docs/footer/footer-scripts.html index d3041cac4..aadf813fb 100644 --- a/docSite/layouts/partials/docs/footer/footer-scripts.html +++ b/docSite/layouts/partials/docs/footer/footer-scripts.html @@ -58,7 +58,7 @@ diff --git a/docSite/layouts/partials/docs/head.html b/docSite/layouts/partials/docs/head.html index db7ba21fa..296ad897e 100644 --- a/docSite/layouts/partials/docs/head.html +++ b/docSite/layouts/partials/docs/head.html @@ -106,5 +106,5 @@ {{- end -}} - + \ No newline at end of file diff --git a/docSite/static/js/jsdelivr-auto-fallback.js b/docSite/static/js/jsdelivr-auto-fallback.js index 9d5ac3e80..f3d6c7311 100644 --- a/docSite/static/js/jsdelivr-auto-fallback.js +++ b/docSite/static/js/jsdelivr-auto-fallback.js @@ -4,17 +4,17 @@ let failed; let isRunning; const DEST_LIST = [ - 'cdn.jsdelivr.net', - 'jsd.cdn.zzko.cn', 'cdn.jsdelivr.us', + 'jsd.cdn.zzko.cn', 'jsd.onmicrosoft.cn', 'fastly.jsdelivr.net', - 'gcore.jsdelivr.net' + 'gcore.jsdelivr.net', + 'cdn.jsdelivr.net', ]; const PREFIX = '//'; const SOURCE = DEST_LIST[0]; const starTime = Date.now(); - const TIMEOUT = 2000; + const TIMEOUT = 1000; const STORE_KEY = 'jsdelivr-auto-fallback'; const TEST_PATH = '/gh/PipecraftNet/jsdelivr-auto-fallback@main/empty.css?'; const shouldReplace = (text) => text && text.includes(PREFIX + SOURCE);