diff --git a/site/src/components/CopyButton.astro b/site/src/components/CopyButton.astro index dc4b1fa..de0930c 100644 --- a/site/src/components/CopyButton.astro +++ b/site/src/components/CopyButton.astro @@ -8,9 +8,10 @@ interface Props { class?: string; withAttribution?: boolean; nudge?: boolean; + copyData?: Record | null; } -const { targetId, label = 'Copy', variant = 'icon', class: extraClass = '', withAttribution = false, nudge = false } = Astro.props; +const { targetId, label = 'Copy', variant = 'icon', class: extraClass = '', withAttribution = false, nudge = false, copyData = null } = Astro.props; const btnId = `copy-btn-${targetId}`; const nudgeId = `star-nudge-${btnId}`; --- @@ -65,7 +66,7 @@ const nudgeId = `star-nudge-${btnId}`; )} - diff --git a/site/src/components/ExporterSection.astro b/site/src/components/ExporterSection.astro index fd72974..d57d50d 100644 --- a/site/src/components/ExporterSection.astro +++ b/site/src/components/ExporterSection.astro @@ -8,7 +8,10 @@ interface Props { exporter: Exporter; service: Service; groupIndex: number; + groupName: string; + groupSlug: string; serviceIndex: number; + serviceSlug: string; exporterIndex: number; showExporterNumber: boolean; } @@ -17,7 +20,10 @@ const { exporter, service, groupIndex, + groupName, + groupSlug, serviceIndex, + serviceSlug, exporterIndex, showExporterNumber, } = Astro.props; @@ -68,7 +74,26 @@ const exporterPrefix = showExporterNumber
- +
@@ -88,7 +113,23 @@ const exporterPrefix = showExporterNumber
{wgetCommand}
- + )} @@ -114,6 +155,26 @@ const exporterPrefix = showExporterNumber rule={rule} anchorId={anchorId} ruleNumber={ruleNumber} + copyData={{ + name: 'rule_copy', + scope: 'rule', + group_index: groupIndex, + group_name: groupName, + group_slug: groupSlug, + service_index: serviceIndex, + service_name: service.name, + service_slug: serviceSlug, + exporter_index: exporterIndex, + exporter_name: exporter.name ?? null, + exporter_slug: exporter.slug, + rule_index: ruleIdx + 1, + rule_slug: anchorId, + rule_name: rule.name, + rule_severity: rule.severity, + rule_for: rule.for ?? null, + rule_number: ruleNumber, + with_attribution: false, + }} /> ); })} diff --git a/site/src/components/RuleCard.astro b/site/src/components/RuleCard.astro index c89d2c0..d6a6ab1 100644 --- a/site/src/components/RuleCard.astro +++ b/site/src/components/RuleCard.astro @@ -8,9 +8,10 @@ interface Props { rule: Rule; anchorId: string; ruleNumber: string; + copyData?: Record | null; } -const { rule, anchorId, ruleNumber } = Astro.props; +const { rule, anchorId, ruleNumber, copyData = null } = Astro.props; const yamlContent = formatRuleAsYaml(rule); const codeId = `code-${anchorId}`; --- @@ -37,7 +38,7 @@ const codeId = `code-${anchorId}`; - + diff --git a/site/src/layouts/BaseLayout.astro b/site/src/layouts/BaseLayout.astro index ee04246..70a77d4 100644 --- a/site/src/layouts/BaseLayout.astro +++ b/site/src/layouts/BaseLayout.astro @@ -98,5 +98,12 @@ const canonical = canonicalUrl ?? `${SITE_ORIGIN}${base}${Astro.url.pathname.rep