Skip to content

Add CookiesNotice plugin with embedded HTML and CSS resources#9

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-cookies-notice-banner
Draft

Add CookiesNotice plugin with embedded HTML and CSS resources#9
Copilot wants to merge 4 commits intomainfrom
copilot/add-cookies-notice-banner

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 14, 2026

Adds a CookiesNotice Statiq plugin that injects a dismissible cookie consent banner into rendered HTML pages, backed by madmurphy/cookies.js.

New plugin (src/Statiq.Plugins/CookiesNotice/)

  • CookiesNoticeModuleParallelModule that post-processes .html destinations, loading a template and styles from embedded resources and injecting the rendered notice before </body>. Config values are HTML-encoded; cookie name is sanitized to safe characters.
  • CookiesNoticeConfigurator — Wires the module into the Content pipeline PostProcessModules automatically.
  • cookies-notice.html — Embedded resource containing the banner HTML/JS. Uses {{COOKIE_NAME}}, {{COOKIE_MESSAGE}}, {{COOKIE_BUTTON_TEXT}}, and {{COOKIE_STYLE}} as substitution tokens, keeping markup editable independently of C# code.
  • cookies-notice.css — Embedded resource containing the banner styles, injected at runtime via the {{COOKIE_STYLE}} placeholder in the HTML template.

Configuration (appsettings.json)

All keys are optional with sensible defaults:

{
  "CookiesNoticeName": "cookiesAccepted",
  "CookiesNoticeMessage": "This website uses Google Analytics, and its cookies.",
  "CookiesNoticeButtonText": "Understood"
}

The banner is hidden on load; cookies.js (jsDelivr CDN, pinned @1.0.0) checks for the named cookie on DOMContentLoaded and shows the banner if absent. Clicking the button sets a non-expiring cookie and hides the banner.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cookies Notice</issue_title>
<issue_description>- https://blog.jermdavis.dev

Cookie Lib

cookies

<div class="min-h-screen bg-gray-300 py-6 flex flex-col justify-center sm:py-12" x-data="{ hide_banner: true }" x-init="hide_banner = docCookies.hasItem('hide_banner');" x-bind:class="{ 'hidden': hide_banner, 'fixed': !hide_banner }">
	<div class="border-2 border-gray-600 bg-gray-100 max-w-screen-lg mx-auto fixed bg-white inset-x-5 p-5 bottom-10 rounded-lg drop-shadow-2xl flex gap-4 flex-wrap md:flex-nowrap text-center md:text-left items-center justify-center md:justify-between">
		<div class="w-full text-lg">
			<a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage" rel="noreferrer" target="_blank">This website uses Google Analytics, and its cookies.</a>
		</div>
		<button type="button" @click="hide_banner = true; docCookies.setItem('hide_banner', true, 'Fri, 31 Dec 9999 23:59:59 GMT', null, null, null, 'strict');" class="bg-gray-400 px-5 py-2 text-white rounded-md hover:bg-gray-600 focus:outline-none" aria-label="Dismiss">Understood</button>
	</div>
</div>

</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cookies notice banner to website Add CookiesNotice plugin Mar 14, 2026
Copilot AI requested a review from AlexHedley March 14, 2026 09:37
Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copilot AI changed the title Add CookiesNotice plugin Add CookiesNotice plugin with embedded HTML template Mar 14, 2026
@AlexHedley
Copy link
Copy Markdown
Owner

@copilot extract the style into a css file

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 14, 2026

@copilot extract the style into a css file

Done in 5537df8. The CSS rules have been moved from cookies-notice.html into a new cookies-notice.css embedded resource. The HTML template now uses a {{COOKIE_STYLE}} placeholder that CookiesNoticeModule fills at runtime by loading the CSS resource via a shared LoadEmbeddedResource helper.

Copilot AI changed the title Add CookiesNotice plugin with embedded HTML template Add CookiesNotice plugin with embedded HTML and CSS resources Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookies Notice

2 participants