From ca8fb6df3faee1f0ee8d37d3902cdd711ba6facd Mon Sep 17 00:00:00 2001 From: shigahi Date: Thu, 22 Jan 2026 16:25:24 +0100 Subject: [PATCH] Add branding options and Twitter handle support - Add Site Name field for og:site_name meta tag (Issue #18) - Add Brand Replacement field to replace 'Notion' text in meta tags (Issue #18) - Add Twitter/X Handle field for twitter:site and twitter:creator meta tags (Issue #19) - Update MetaRewriter to handle branding replacements - Update HeadRewriter to inject Twitter meta tags Closes #18 Closes #19 --- src/App.tsx | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/code.ts | 36 ++++++++++++++++++++++++++-- 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a58328a..f3699df 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -41,6 +41,7 @@ import code, { ImageOptions, PageMetadata, StructuredDataOptions, + BrandingOptions, } from "./code"; import "./styles.css"; @@ -141,6 +142,11 @@ export default function App() { organizationName: "", logoUrl: "", }); + const [branding, setBranding] = useState({ + siteName: "", + brandReplacement: "", + twitterHandle: "", + }); const [slugMetadataExpanded, setSlugMetadataExpanded] = useState< Record >({}); @@ -231,6 +237,17 @@ export default function App() { setCopied(false); } + function handleBrandingChange( + field: keyof BrandingOptions, + value: string, + ): void { + setBranding({ + ...branding, + [field]: value, + }); + setCopied(false); + } + function toggleSlugMetadata(index: number): void { setSlugMetadataExpanded({ ...slugMetadataExpanded, @@ -292,6 +309,7 @@ export default function App() { optionImage, pageMetadata, structuredData, + branding, }; const script = noError ? code(codeData) : undefined; @@ -711,6 +729,55 @@ export default function App() { size="small" /> + + + Branding & Social + + + handleBrandingChange("siteName", e.target.value) + } + value={branding.siteName} + variant="outlined" + size="small" + /> + + handleBrandingChange("brandReplacement", e.target.value) + } + value={branding.brandReplacement} + variant="outlined" + size="small" + /> + + handleBrandingChange("twitterHandle", e.target.value) + } + value={branding.twitterHandle} + variant="outlined" + size="small" + /> + + ; structuredData: StructuredDataOptions; + branding: BrandingOptions; } function getId(url: string): string { @@ -60,6 +67,7 @@ export default function code(data: CodeData): string { optionImage, pageMetadata, structuredData, + branding, } = data; let url = myDomain.replace("https://", "").replace("http://", ""); if (url.slice(-1) === "/") url = url.slice(0, url.length - 1); @@ -103,6 +111,14 @@ ${slugs const ORGANIZATION_NAME = '${structuredData?.organizationName || ""}'; const LOGO_URL = '${structuredData?.logoUrl || ""}'; + /* + * Step 3.3: branding configuration (optional) + * Replace Notion branding with your own and add social media handles + */ + const SITE_NAME = '${branding?.siteName || ""}'; + const BRAND_REPLACEMENT = '${branding?.brandReplacement || ""}'; + const TWITTER_HANDLE = '${branding?.twitterHandle || ""}'; + /* Step 4: enter a Google Font name, you can choose from https://fonts.google.com */ const GOOGLE_FONT = '${googleFont || ""}'; @@ -355,11 +371,21 @@ ${slugs return; } } - if (MY_DOMAIN !== '') { - if (element.getAttribute('property') === 'og:site_name') { + // Set og:site_name - use SITE_NAME if configured, otherwise MY_DOMAIN (Issue #18) + if (element.getAttribute('property') === 'og:site_name') { + if (SITE_NAME !== '') { + element.setAttribute('content', SITE_NAME); + } else if (MY_DOMAIN !== '') { element.setAttribute('content', MY_DOMAIN); } } + // Replace 'Notion' branding in meta content (Issue #18) + if (BRAND_REPLACEMENT !== '') { + const content = element.getAttribute('content'); + if (content && content.includes('Notion')) { + element.setAttribute('content', content.replace(/Notion/g, BRAND_REPLACEMENT)); + } + } if (pageTitle !== '') { if (element.getAttribute('property') === 'og:title' || element.getAttribute('name') === 'twitter:title') { @@ -405,6 +431,12 @@ ${slugs element.append(\`\`, { html: true }); element.append(\`\`, { html: true }); + // Add Twitter/X meta tags for social cards (Issue #19) + if (TWITTER_HANDLE !== '') { + element.append(\`\`, { html: true }); + element.append(\`\`, { html: true }); + } + // Add JSON-LD structured data for rich search results (Issue #10) if (STRUCTURED_DATA_ENABLED) { const pageTitle = this.metadata.title || PAGE_TITLE;