From dfc40849a1949099d8d83eadbfca4d1531b8e060 Mon Sep 17 00:00:00 2001 From: Amos Date: Mon, 28 Oct 2024 12:17:40 +0800 Subject: [PATCH] Fix: Build site for production (#1517) --- .github/workflows/build.yml | 2 +- .github/workflows/stage.yml | 2 +- src/_data/site.yml | 1 + src/_layouts/base.html | 10 +++++++--- tool/flutter_site/lib/src/commands/build.dart | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccd472367c..4e0617430f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,7 +145,7 @@ jobs: - name: Fetch Dart dependencies run: dart pub get - name: Build site - run: dart run flutter_site build + run: dart run flutter_site build --release - name: Translated (docs.flutter.cn) run: bash tool/translator/build.sh shell: bash diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 55b61a2601..bf1759b607 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -39,7 +39,7 @@ jobs: - name: Fetch Dart dependencies run: dart pub get - name: Build site - run: dart run flutter_site build + run: dart run flutter_site build --release - name: Translated (docs.flutter.cn) run: bash tool/translator/build.sh shell: bash diff --git a/src/_data/site.yml b/src/_data/site.yml index 01f3b855f9..9430fdf9e2 100644 --- a/src/_data/site.yml +++ b/src/_data/site.yml @@ -6,6 +6,7 @@ email: cfug-dev@googlegroups.com google_analytics_id: UA-122680122-1 # google_site_verification: HFqxhSbf9YA_0rBglNLzDiWnrHiK_w4cqDh2YD2GEY4 google_tag_manager_id: G-HPSFTRXK91 +baidu_analytics_id: c50919183c6e001b47301f55de682929 default_share_image: /assets/images/cn/flutter-cn-logo.png diff --git a/src/_layouts/base.html b/src/_layouts/base.html index d44b930e1a..79206a1ba4 100644 --- a/src/_layouts/base.html +++ b/src/_layouts/base.html @@ -15,9 +15,11 @@ {% endunless -%} + + {%- if isProduction == true -%} - + + {% endif -%} {% assign desc = description | default: site.description | strip_html | strip_newlines | truncate: 160 -%} {% unless desc and desc != '' or page.url contains '/posts' or page.url contains '/community' -%} @@ -81,13 +84,14 @@ - + {%- if isProduction == true -%} + {% endif -%}
diff --git a/tool/flutter_site/lib/src/commands/build.dart b/tool/flutter_site/lib/src/commands/build.dart index c229f7097a..c0e26f8bc3 100644 --- a/tool/flutter_site/lib/src/commands/build.dart +++ b/tool/flutter_site/lib/src/commands/build.dart @@ -37,7 +37,8 @@ final class BuildSiteCommand extends Command { const ['eleventy'], environment: { 'PRODUCTION': '$productionRelease', - 'OPTIMIZE': '$productionRelease', + // docs.flutter.cn 为了翻译工具 (tool/translator) 格式调整和解析,暂不需要优化(压缩 HTML 结构等) + 'OPTIMIZE': 'false', // '$productionRelease' }, );