Skip to content

Commit

Permalink
Fix: Build site for production (#1517)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmosHuKe authored Oct 28, 2024
1 parent 8a47cc4 commit dfc4084
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/_data/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 7 additions & 3 deletions src/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
<link rel="preconnect" href="https://fonts.googleapis.cn">
<link rel="preconnect" href="https://fonts.gstatic.cn" crossorigin>
{% endunless -%}

{%- if isProduction == true -%}
<!-- Starting the Analysis Code -->
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-HPSFTRXK91"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_tag_manager_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Expand All @@ -28,12 +30,13 @@
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?c50919183c6e001b47301f55de682929";
hm.src = "https://hm.baidu.com/hm.js?{{ site.baidu_analytics_id }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- Ending the Analysis Code -->
{% 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' -%}
Expand Down Expand Up @@ -81,13 +84,14 @@

<!-- {% render cookie-notice.html %}-->


{%- if isProduction == true -%}
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id={{ site.google_tag_manager_id }}"
height="0" width="0" style="display:none;visibility:hidden">
</iframe>
</noscript>
{% endif -%}


<div id="overlay-under-drawer"></div>
Expand Down
3 changes: 2 additions & 1 deletion tool/flutter_site/lib/src/commands/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ final class BuildSiteCommand extends Command<int> {
const ['eleventy'],
environment: {
'PRODUCTION': '$productionRelease',
'OPTIMIZE': '$productionRelease',
// docs.flutter.cn 为了翻译工具 (tool/translator) 格式调整和解析,暂不需要优化(压缩 HTML 结构等)
'OPTIMIZE': 'false', // '$productionRelease'
},
);

Expand Down

0 comments on commit dfc4084

Please sign in to comment.