diff options
| -rw-r--r-- | .github/workflows/build-and-deploy-prod.yml | 2 | ||||
| -rw-r--r-- | config/config.go | 5 | ||||
| -rw-r--r-- | config/config.prod.yaml | 2 | ||||
| -rw-r--r-- | deploy/playbook.yml | 1 | ||||
| -rw-r--r-- | internal/router/handlers/root.go | 8 | ||||
| -rw-r--r-- | internal/router/router.go | 3 | ||||
| -rw-r--r-- | views/layouts/general-page.html | 2 |
7 files changed, 19 insertions, 4 deletions
diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index 413f402..24b6e0e 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -75,4 +75,4 @@ jobs: ANSIBLE_HOST_KEY_CHECKING: False working-directory: ./deploy run: | - ansible-playbook -i inventory.yml -l prod playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_b2_key_id="${{ secrets.B2_KEY_ID }}" -e saya_today_web_b2_application_key="${{ secrets.B2_APPLICATION_KEY }}" -e saya_today_web_environment=prod -e saya_today_web_tag=${{ github.ref_name }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" + ansible-playbook -i inventory.yml -l prod playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_b2_key_id="${{ secrets.B2_KEY_ID }}" -e saya_today_web_b2_application_key="${{ secrets.B2_APPLICATION_KEY }}" -e saya_today_web_environment=prod -e saya_today_web_tag=${{ github.ref_name }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" -e saya_today_google_site_verification="${{ secrets.GOOGLE_SITE_VERIFICATION }}" diff --git a/config/config.go b/config/config.go index fd8c480..eb4a91d 100644 --- a/config/config.go +++ b/config/config.go @@ -17,6 +17,7 @@ type Config struct { Auth AuthConfig `json:"Auth" yaml:"auth" validate:"required"` Mail MailConfig `json:"Mail" yaml:"mail" validate:"required"` CanonicalEndpoint string `json:"CanonicalEndpoint" yaml:"canonicalEndpoint" validate:"required"` + Meta MetaConfig `json:"Meta" yaml:"meta"` } type BlogPagesConfig struct { @@ -77,6 +78,10 @@ type TriggerConfig struct { OnNewPost string `json:"OnNewPost" yaml:"onNewPost" validate:"cron,required"` } +type MetaConfig struct { + GoogleSiteVerification string `json:"GoogleSiteVerification" yaml:"googleSiteVerification"` +} + func LoadConfig(path string, config *Config) error { fileBytes, err := os.ReadFile(path) if err != nil { diff --git a/config/config.prod.yaml b/config/config.prod.yaml index 4de853c..b40ba57 100644 --- a/config/config.prod.yaml +++ b/config/config.prod.yaml @@ -45,3 +45,5 @@ mail: trigger: onNewPost: "0/5 * * * *" canonicalEndpoint: 'https://${FQDN}' +meta: + googleSiteVerification: '${GOOGLE_SITE_VERIFICATION}' diff --git a/deploy/playbook.yml b/deploy/playbook.yml index 2516f4e..b0202bd 100644 --- a/deploy/playbook.yml +++ b/deploy/playbook.yml @@ -24,6 +24,7 @@ MAIL_PASSWORD: "{{ saya_today_web_mail_password }}" MAIL_SALT: "{{ saya_today_web_mail_salt }}" FQDN: "{{ saya_today_web_listen_address }}" + GOOGLE_SITE_VERIFICATION: "{{ saya_today_google_site_verification | default('') }}" network_mode: caddy networks: - name: caddy diff --git a/internal/router/handlers/root.go b/internal/router/handlers/root.go index cd01fcd..a8890fa 100644 --- a/internal/router/handlers/root.go +++ b/internal/router/handlers/root.go @@ -41,12 +41,16 @@ func (r *RootHandler) SitemapInfo(_ *router.Supplements) []router.SitemapInfo { } func (r *RootHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) { - return []router.MetaField{ + meta = []router.MetaField{ {Property: "og:title", Content: "Saya Blog"}, {Property: "og:description", Content: "The blog of a 25 years old, travelling God knows where, proud to be not mainstream // Личный блог 25-летки, странствующего по ебеням, зато не мейнстрим"}, {Property: "og:url", Content: fmt.Sprint(templateMap["CanonicalEndpoint"]) + "/"}, {Property: "og:type", Content: "website"}, - }, nil + } + if supplements.Meta.GoogleSiteVerification != "" { + meta = append(meta, router.MetaField{Name: "google-site-verification", Content: supplements.Meta.GoogleSiteVerification}) + } + return meta, nil } func (r *RootHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements, _ string, templateMap fiber.Map) (statusCode int, err error) { diff --git a/internal/router/router.go b/internal/router/router.go index 0d0ce8c..3242759 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -100,6 +100,7 @@ type Supplements struct { BlogTrigger *blogtrigger.BlogTriggerScheduler TemplateManager *templatemanager.TemplateManager MarkdownRenderer goldmark.Markdown + Meta config.MetaConfig } type Router struct { @@ -215,6 +216,8 @@ func NewRouter(cfg *config.Config) (*Router, error) { return nil, fmt.Errorf("fail to initialize template manager: %w", err) } + supplements.Meta = cfg.Meta + enablePrintRoutes := false if cfg.LogLevel <= slog.LevelDebug { enablePrintRoutes = true diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index 7167d12..2d3bff3 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -6,7 +6,7 @@ {{- range .Meta }} <meta {{with .Name}}name="{{.}}" {{end}}{{with .Property}}property="{{.}}" {{end}}{{with .Content}}content="{{.}}"{{end}}> {{- if eq .Property "og:description" }} - <meta name="description" href="{{.Content}}"> + <meta name="description" content="{{.Content}}"> {{- end }} {{- if eq .Property "og:url" }} <link rel="canonical" href="{{.Content}}"> |