mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-05-14 22:48:50 +02:00
feat: add AI usage sidebar widget for homepage and blog sidebars
Compact widget showing AI transparency stats (total, AI-involved, human-only, ratio), level breakdown pills, and a 1-year post-graph highlighting AI-involved posts. Links to /ai/ for full report. Confab-Link: http://localhost:8080/sessions/edb1b7b0-da66-4486-bd9c-d1cfa7553b88
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
{% elif widget.type == "toc" %}{% set widgetTitle = "Table of Contents" %}
|
||||
{% elif widget.type == "post-categories" %}{% set widgetTitle = "Categories" %}
|
||||
{% elif widget.type == "share" %}{% set widgetTitle = "Share" %}
|
||||
{% elif widget.type == "ai-usage" %}{% set widgetTitle = "AI Transparency" %}
|
||||
{% elif widget.type == "custom-html" %}{% set widgetTitle = (widget.config.title if widget.config and widget.config.title) or "Custom" %}
|
||||
{% else %}{% set widgetTitle = widget.type %}
|
||||
{% endif %}
|
||||
@@ -56,6 +57,8 @@
|
||||
{% set widgetIcon = "search" %}{% set widgetIconClass = "w-5 h-5 text-surface-500" %}{% set widgetBorder = "" %}
|
||||
{% elif widget.type == "webmentions" %}
|
||||
{% set widgetIcon = "share" %}{% set widgetIconClass = "w-5 h-5 text-surface-500" %}{% set widgetBorder = "" %}
|
||||
{% elif widget.type == "ai-usage" %}
|
||||
{% set widgetIcon = "zap" %}{% set widgetIconClass = "w-5 h-5 text-amber-500" %}{% set widgetBorder = "border-l-[3px] border-l-amber-400 dark:border-l-amber-500" %}
|
||||
{% elif widget.type == "toc" %}
|
||||
{% set widgetIcon = "list" %}{% set widgetIconClass = "w-5 h-5 text-surface-500" %}{% set widgetBorder = "" %}
|
||||
{% elif widget.type == "share" %}
|
||||
@@ -136,6 +139,8 @@
|
||||
{% include "components/widgets/search.njk" %}
|
||||
{% elif widget.type == "fediverse-follow" %}
|
||||
{% include "components/widgets/fediverse-follow.njk" %}
|
||||
{% elif widget.type == "ai-usage" %}
|
||||
{% include "components/widgets/ai-usage.njk" ignore missing %}
|
||||
{% elif widget.type == "custom-html" %}
|
||||
{% set wConfig = widget.config or {} %}
|
||||
<is-land on:visible>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
{% elif widget.type == "recent-comments" %}{% set widgetTitle = "Recent Comments" %}
|
||||
{% elif widget.type == "fediverse-follow" %}{% set widgetTitle = "Fediverse" %}
|
||||
{% elif widget.type == "author-card" %}{% set widgetTitle = "Author" %}
|
||||
{% elif widget.type == "ai-usage" %}{% set widgetTitle = "AI Transparency" %}
|
||||
{% elif widget.type == "custom-html" %}{% set widgetTitle = (widget.config.title if widget.config and widget.config.title) or "Custom" %}
|
||||
{% else %}{% set widgetTitle = widget.type %}
|
||||
{% endif %}
|
||||
@@ -49,6 +50,8 @@
|
||||
{% set widgetIcon = "search" %}{% set widgetIconClass = "w-5 h-5 text-surface-500" %}{% set widgetBorder = "" %}
|
||||
{% elif widget.type == "webmentions" %}
|
||||
{% set widgetIcon = "share" %}{% set widgetIconClass = "w-5 h-5 text-surface-500" %}{% set widgetBorder = "" %}
|
||||
{% elif widget.type == "ai-usage" %}
|
||||
{% set widgetIcon = "zap" %}{% set widgetIconClass = "w-5 h-5 text-amber-500" %}{% set widgetBorder = "border-l-[3px] border-l-amber-400 dark:border-l-amber-500" %}
|
||||
{% else %}
|
||||
{% set widgetIcon = "" %}{% set widgetIconClass = "" %}{% set widgetBorder = "" %}
|
||||
{% endif %}
|
||||
@@ -115,6 +118,8 @@
|
||||
{% include "components/widgets/recent-comments.njk" %}
|
||||
{% elif widget.type == "fediverse-follow" %}
|
||||
{% include "components/widgets/fediverse-follow.njk" %}
|
||||
{% elif widget.type == "ai-usage" %}
|
||||
{% include "components/widgets/ai-usage.njk" ignore missing %}
|
||||
{% elif widget.type == "custom-html" %}
|
||||
{% set wConfig = widget.config or {} %}
|
||||
<is-land on:visible>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{# AI Usage Widget — compact sidebar version of the /ai/ page AI transparency graph #}
|
||||
{% set stats = collections.posts | aiStats %}
|
||||
{% set aiPostsList = collections.posts | aiPosts %}
|
||||
{% if stats and stats.total > 0 %}
|
||||
<is-land on:visible>
|
||||
<div class="widget">
|
||||
<h3 class="widget-title flex items-center gap-2">
|
||||
<svg class="w-5 h-5 text-amber-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
|
||||
</svg>
|
||||
AI Transparency
|
||||
</h3>
|
||||
|
||||
{# Mini stats — 2x2 grid #}
|
||||
<div class="grid grid-cols-2 gap-2 mb-3">
|
||||
<div class="text-center p-2 rounded-lg bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700">
|
||||
<div class="text-lg font-bold text-surface-900 dark:text-surface-100">{{ stats.total }}</div>
|
||||
<div class="text-[10px] text-surface-500 dark:text-surface-400">Total</div>
|
||||
</div>
|
||||
<div class="text-center p-2 rounded-lg bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700">
|
||||
<div class="text-lg font-bold text-amber-600 dark:text-amber-400">{{ stats.aiCount }}</div>
|
||||
<div class="text-[10px] text-surface-500 dark:text-surface-400">AI-involved</div>
|
||||
</div>
|
||||
<div class="text-center p-2 rounded-lg bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700">
|
||||
<div class="text-lg font-bold text-emerald-600 dark:text-emerald-400">{{ stats.total - stats.aiCount }}</div>
|
||||
<div class="text-[10px] text-surface-500 dark:text-surface-400">Human-only</div>
|
||||
</div>
|
||||
<div class="text-center p-2 rounded-lg bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700">
|
||||
<div class="text-lg font-bold text-surface-900 dark:text-surface-100">{{ stats.percentage }}%</div>
|
||||
<div class="text-[10px] text-surface-500 dark:text-surface-400">AI ratio</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Level breakdown — compact pills #}
|
||||
<div class="flex flex-wrap gap-1.5 text-[10px] mb-3">
|
||||
<span class="px-2 py-0.5 rounded-full bg-surface-100 dark:bg-surface-700 text-surface-600 dark:text-surface-300">
|
||||
L0: {{ stats.byLevel[0] }}
|
||||
</span>
|
||||
<span class="px-2 py-0.5 rounded-full bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300">
|
||||
L1: {{ stats.byLevel[1] }}
|
||||
</span>
|
||||
<span class="px-2 py-0.5 rounded-full bg-amber-100 dark:bg-amber-900/40 text-amber-800 dark:text-amber-200">
|
||||
L2: {{ stats.byLevel[2] }}
|
||||
</span>
|
||||
<span class="px-2 py-0.5 rounded-full bg-amber-200 dark:bg-amber-900/60 text-amber-900 dark:text-amber-100">
|
||||
L3: {{ stats.byLevel[3] }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{# Compact post-graph — current year only, AI posts highlighted #}
|
||||
{% if aiPostsList and aiPostsList.length %}
|
||||
<div class="text-[10px] text-surface-500 dark:text-surface-400 mb-2">AI-involved posts this year</div>
|
||||
{% postGraph aiPostsList, { prefix: "ai-widget", limit: 1, highlightColorLight: "#d97706", highlightColorDark: "#fbbf24" } %}
|
||||
{% endif %}
|
||||
|
||||
<a href="/ai/" class="text-sm text-amber-600 dark:text-amber-400 hover:underline flex items-center gap-1 mt-3">
|
||||
View full AI report
|
||||
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</is-land>
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user