From 723e49919251cc7836bd3c55c9ca265dfcfa0342 Mon Sep 17 00:00:00 2001 From: "tan.nguyen" Date: Fri, 15 Nov 2024 11:33:40 +0700 Subject: [PATCH] Update gennerate static site command. --- .ddev/commands/web/generate-static-site | 7 +- .ddev/nginx_full/fs-web-static-site.conf | 88 +++++++++++++++++++ ...=> block.block.fstheme_mainnavigation.yml} | 12 +-- ....entity_view_display.node.page.default.yml | 32 +++++-- 4 files changed, 124 insertions(+), 15 deletions(-) create mode 100644 .ddev/nginx_full/fs-web-static-site.conf rename config/sync/{block.block.fstheme_mainnav.yml => block.block.fstheme_mainnavigation.yml} (72%) diff --git a/.ddev/commands/web/generate-static-site b/.ddev/commands/web/generate-static-site index 66808a3..cb54796 100755 --- a/.ddev/commands/web/generate-static-site +++ b/.ddev/commands/web/generate-static-site @@ -2,8 +2,13 @@ rm -rf /var/www/html/static-site -GENERATE_STATIC_SITE=1 drush tome:static -vv --uri=https://frees.au +if [ "$1" == "--production" ]; then + GENERATE_STATIC_SITE=1 drush tome:static -vv --uri=https://frees.au +else + GENERATE_STATIC_SITE=1 drush tome:static -vv --uri=fs-web-static-site.ddev.site:8080 +fi # Need this one to make search api lunr works. # Make sure Drupal site is fully index first. cp -R "/var/www/html/web/sites/default/files/search-api-js" "/var/www/html/static-site/sites/default/files" +cp -R "/var/www/html/web/themes/custom/fstheme/stockart" "/var/www/html/static-site/themes/custom/fstheme" diff --git a/.ddev/nginx_full/fs-web-static-site.conf b/.ddev/nginx_full/fs-web-static-site.conf new file mode 100644 index 0000000..5c81327 --- /dev/null +++ b/.ddev/nginx_full/fs-web-static-site.conf @@ -0,0 +1,88 @@ +# Example configuration for a second docroot + +#ddev-generated +# If you want to take over this file and customize it, rename it to .conf, +# and remove the ddev-generated line above + +server { + # Set the docroot to where it belongs in the codebase + root /var/www/html/static-site; + # Set the server_name so this config can be selected + # You'll need additional_hostnames["seconddocroot"] in config.yaml for this to work + server_name fs-web-static-site.ddev.site; + + listen 80; + listen 443 ssl; + + ssl_certificate /etc/ssl/certs/master.crt; + ssl_certificate_key /etc/ssl/certs/master.key; + + include /etc/nginx/monitoring.conf; + + index index.php index.htm index.html; + + # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html + sendfile off; + error_log /dev/stdout info; + access_log /var/log/nginx/access.log; + + location / { + absolute_redirect off; + try_files $uri $uri/ /index.php?$query_string; + } + + location @rewrite { + # For D7 and above: + # Clean URLs are handled in drupal_environment_initialize(). + rewrite ^ /index.php; + } + + # pass the PHP scripts to FastCGI server listening on socket + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/run/php-fpm.sock; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_intercept_errors off; + # fastcgi_read_timeout should match max_execution_time in php.ini + fastcgi_read_timeout 10m; + fastcgi_param SERVER_NAME $host; + fastcgi_param HTTPS $fcgi_https; + # Pass the X-Accel-* headers to facilitate testing. + fastcgi_pass_header "X-Accel-Buffering"; + fastcgi_pass_header "X-Accel-Charset"; + fastcgi_pass_header "X-Accel-Expires"; + fastcgi_pass_header "X-Accel-Limit-Rate"; + fastcgi_pass_header "X-Accel-Redirect"; + } + + # Expire rules for static content + # Media: images, icons, video, audio, HTC + location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|webp|htc)$ { + expires 1M; + access_log off; + add_header Cache-Control "public"; + } + + # Prevent clients from accessing hidden files (starting with a dot) + # This is particularly important if you store .htpasswd files in the site hierarchy + # Access to `/.well-known/` is allowed. + # https://www.mnot.net/blog/2010/04/07/well-known + # https://tools.ietf.org/html/rfc5785 + location ~* /\.(?!well-known\/) { + deny all; + } + + # Prevent clients from accessing to backup/config/source files + location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ { + deny all; + } + + include /etc/nginx/common.d/*.conf; + include /mnt/ddev_config/nginx/*.conf; +} diff --git a/config/sync/block.block.fstheme_mainnav.yml b/config/sync/block.block.fstheme_mainnavigation.yml similarity index 72% rename from config/sync/block.block.fstheme_mainnav.yml rename to config/sync/block.block.fstheme_mainnavigation.yml index 4d6bc8b..bc02194 100644 --- a/config/sync/block.block.fstheme_mainnav.yml +++ b/config/sync/block.block.fstheme_mainnavigation.yml @@ -1,6 +1,6 @@ -uuid: 6d33843f-9f10-45f5-8891-d3b1fb50484e +uuid: 40baf552-7482-4b4d-9d2e-9242beaf4dba langcode: en -status: false +status: true dependencies: config: - system.menu.main @@ -8,10 +8,10 @@ dependencies: - system theme: - fstheme -id: fstheme_mainnav +id: fstheme_mainnavigation theme: fstheme -region: sidebar -weight: -2 +region: primary_menu +weight: 0 provider: null plugin: 'system_menu_block:main' settings: @@ -20,6 +20,6 @@ settings: label_display: '0' provider: system level: 1 - depth: 0 + depth: 1 expand_all_items: false visibility: { } diff --git a/config/sync/core.entity_view_display.node.page.default.yml b/config/sync/core.entity_view_display.node.page.default.yml index d425a3a..ac94c19 100644 --- a/config/sync/core.entity_view_display.node.page.default.yml +++ b/config/sync/core.entity_view_display.node.page.default.yml @@ -10,47 +10,63 @@ dependencies: - node.type.page module: - layout_builder - - layout_discovery - text - user + theme: + - fstheme third_party_settings: layout_builder: enabled: true allow_custom: true sections: - - layout_id: layout_onecol + layout_id: onecol_container_content layout_settings: label: '' + context_mapping: { } components: - 5f6607c6-f329-4e65-b23c-79b0ff8f8237: - uuid: 5f6607c6-f329-4e65-b23c-79b0ff8f8237 + 0626c0ae-afcc-4e75-9f95-dbdc61a483d5: + uuid: 0626c0ae-afcc-4e75-9f95-dbdc61a483d5 region: content configuration: id: 'field_block:node:page:lead' + label: 'Lead or summary' label_display: '0' + provider: layout_builder context_mapping: entity: layout_builder.entity + view_mode: view_mode formatter: type: text_default label: hidden settings: { } - third_party_settings: { } + third_party_settings: + field_label: + label_class: '' + label_value: '' + label_tag: '' weight: 0 additional: { } - 707a2ebc-4a32-400a-87a3-d45390b2b88a: - uuid: 707a2ebc-4a32-400a-87a3-d45390b2b88a + c0834258-bd3f-437b-b7f1-9f894fe52556: + uuid: c0834258-bd3f-437b-b7f1-9f894fe52556 region: content configuration: id: 'field_block:node:page:markup' + label: Content label_display: '0' + provider: layout_builder context_mapping: entity: layout_builder.entity + view_mode: view_mode formatter: type: text_default label: hidden settings: { } - third_party_settings: { } + third_party_settings: + field_label: + label_class: '' + label_value: '' + label_tag: '' weight: 1 additional: { } third_party_settings: { }