Skip to content

Commit

Permalink
Gennerate static site (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 authored Sep 12, 2024
1 parent 1833511 commit 7d91764
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .ddev/commands/web/generate-static-site
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

rm -rf /var/www/html/static-site

GENERATE_STATIC_SITE=1 drush tome:static --uri=https://frees.au

# 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"
3 changes: 2 additions & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ docroot: web
php_version: "8.3"
webserver_type: nginx-fpm
xdebug_enabled: false
additional_hostnames: []
additional_hostnames:
- fs-web-static-site
additional_fqdns: []
database:
type: mariadb
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"require-dev": {
"drupal/coder": "^8.3",
"drupal/core-dev": "^10.1",
"drupal/tome": "^1.12",
"mglaman/phpstan-drupal": "^1.2",
"palantirnet/drupal-rector": "^0.20.1",
"phpstan/extension-installer": "^1.3",
Expand Down
183 changes: 182 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ module:
taxonomy: 0
text: 0
token: 0
tome_base: 0
tome_static: 0
toolbar: 0
twig_remove_html_comments: 0
update: 0
Expand Down
4 changes: 4 additions & 0 deletions web/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
if (file_exists($app_root . '/' . $site_path . '/local.settings.php')) {
include_once $app_root . '/' . $site_path . '/local.settings.php';
}

if (getenv('GENERATE_STATIC_SITE')) {
include_once $app_root . '/' . $site_path . '/tome.settings.php';
}
6 changes: 6 additions & 0 deletions web/sites/default/tome.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
http.response.debug_cacheability_headers: false
twig.config:
debug: false
auto_reload: false
cache: true
15 changes: 15 additions & 0 deletions web/sites/default/tome.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/**
* @file
* Tome configuration.
*/

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/tome.services.yml';

$config['system.performance']['css']['preprocess'] = TRUE;
$config['system.performance']['js']['preprocess'] = TRUE;

$config['system.logging']['error_level'] = 'hide';

$settings['tome_static_directory'] = '../static-site';

0 comments on commit 7d91764

Please sign in to comment.