Skip to content

Commit

Permalink
Change check order enable-ads: false
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless committed Dec 6, 2023
1 parent 0700b73 commit 9819b7e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions _extensions/adsense/adsense.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,28 @@ function Meta(m)
quarto.log.error("The Quarto project is missing the `adsense` key in either the document header, `_quarto.yml`, or `_metadata.yml`.")
end

-- Retrieve publisherID from meta
local publisher_id = nil
if isVariablePopulated(adsense_meta['publisher-id']) then
publisher_id = pandoc.utils.stringify(adsense_meta['publisher-id'])
else
quarto.log.error("The `publisher-id` is not set. Please set the `publisher-id` by either the value in the current document, the projects `_quarto.yml`, or `_metadata.yml` for the directory.")
end

-- Retrieve enable-ads from meta
if isVariablePopulated(adsense_meta['enable-ads']) then
enableAds = pandoc.utils.stringify(adsense_meta['enable-ads'])
if not isBoolean(enableAds) then
quarto.log.error("The `enable-ads` must be either `true` or `false`, not `" .. showAds .. "`. Please fix by correcting the value in the current document, the projects `_quarto.yml`, or `_metadata.yml` for the directory.")
end

-- If ads should be disabled; exit here to avoid running into a publisher-id unset error.
if enableAds == false then
return m
end
end

-- Retrieve publisherID from meta
local publisher_id = nil
if isVariablePopulated(adsense_meta['publisher-id']) then
publisher_id = pandoc.utils.stringify(adsense_meta['publisher-id'])
else
quarto.log.error("The `publisher-id` is not set. Please set the `publisher-id` by either the value in the current document, the projects `_quarto.yml`, or `_metadata.yml` for the directory.")
end

if enableAds and isAdsenseUnitMissing then
-- Avoid re-running insertion
isAdsenseUnitMissing = false
Expand Down

0 comments on commit 9819b7e

Please sign in to comment.