Skip to content

Commit

Permalink
feat: allow adding google search console property id via env var (#11)
Browse files Browse the repository at this point in the history
when the `NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION` environment variable is
set at build time, this will add a `<meta
name="google-site-verification">` tag to the `<head>` to verify site
ownership for google search console.

also passes the missing `NUXT_PUBLIC_BOTS` variable when building in CI.
  • Loading branch information
katharinawuensche authored Sep 24, 2024
2 parents f3f769f + 30dc94a commit c450693
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ NUXT_PUBLIC_API_BASE_URL="https://sicprod.acdh-dev.oeaw.ac.at/"
# -------------------------------------------------------------------------------------------------
# analytics
# -------------------------------------------------------------------------------------------------
# NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION=
NUXT_PUBLIC_MATOMO_BASE_URL="https://matomo.acdh.oeaw.ac.at"
# NUXT_PUBLIC_MATOMO_ID=

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"NUXT_PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
"NUXT_PUBLIC_API_BASE_URL=${{ vars.NUXT_PUBLIC_API_BASE_URL }}"
"NUXT_PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
"NUXT_PUBLIC_BOTS=${{ vars.NUXT_PUBLIC_BOTS }}"
"NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION=${{ vars.NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION }}"
"NUXT_PUBLIC_IIIF_BASE_URL=${{ vars.NUXT_PUBLIC_IIIF_BASE_URL }}"
"NUXT_PUBLIC_MATOMO_BASE_URL=${{ vars.NUXT_PUBLIC_MATOMO_BASE_URL }}"
"NUXT_PUBLIC_MATOMO_ID=${{ vars.NUXT_PUBLIC_MATOMO_ID }}"
"NUXT_PUBLIC_REDMINE_ID=${{ vars.SERVICE_ID }}"
"NUXT_PUBLIC_IIIF_BASE_URL=${{ vars.NUXT_PUBLIC_IIIF_BASE_URL }}"
cache-from: type=gha
cache-to: type=gha,mode=max

Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ RUN pnpm fetch
COPY --chown=node:node ./ ./
RUN sed -i "s/use-node-version/# use-node-version/" .npmrc

ARG NUXT_PUBLIC_API_BASE_URL
ARG NUXT_PUBLIC_APP_BASE_URL
ARG NUXT_PUBLIC_BOTS
ARG NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION
ARG NUXT_PUBLIC_IIIF_BASE_URL
ARG NUXT_PUBLIC_MATOMO_BASE_URL
ARG NUXT_PUBLIC_MATOMO_ID
ARG NUXT_PUBLIC_REDMINE_ID
ARG NUXT_PUBLIC_API_BASE_URL
ARG NUXT_PUBLIC_IIIF_BASE_URL

RUN pnpm install --frozen-lockfile --offline

Expand Down
11 changes: 10 additions & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ useHead({
];
}),
meta: computed(() => {
return [
const meta = [
{ name: "description", content: t("DefaultLayout.meta.description") },
{ property: "og:type", content: "website" },
{ property: "og:title", content: t(route.meta.title) },
Expand All @@ -57,6 +57,15 @@ useHead({
{ name: "twitter:site", content: "@acdh_oeaw" },
...(i18nHead.value.meta ?? []),
];
if (isNonEmptyString(env.public.NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION)) {
meta.push({
name: "google-site-verification",
content: env.public.NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION,
});
}
return meta;
}),
script: computed(() => {
const jsonLd: WithContext<WebSite> = {
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default defineNuxtConfig({
NUXT_PUBLIC_API_BASE_URL: process.env.NUXT_PUBLIC_API_BASE_URL,
NUXT_PUBLIC_APP_BASE_URL: process.env.NUXT_PUBLIC_APP_BASE_URL,
NUXT_PUBLIC_BOTS: process.env.NUXT_PUBLIC_BOTS,
NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION: process.env.NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION,
NUXT_PUBLIC_MATOMO_BASE_URL: process.env.NUXT_PUBLIC_MATOMO_BASE_URL,
NUXT_PUBLIC_MATOMO_ID: process.env.NUXT_PUBLIC_MATOMO_ID,
NUXT_PUBLIC_REDMINE_ID: process.env.NUXT_PUBLIC_REDMINE_ID,
Expand Down

0 comments on commit c450693

Please sign in to comment.