import { websiteUrl, seoPages, socialImage, testflightUrl, sourceUrl } from '../seo.config.js'; import { films, filmUrl } from '../media.config.js'; const absolute = (path) => new URL(path, websiteUrl).href; const organization = { '@type': 'Organization', '@id': absolute('/#org'), name: 'PulseCanvas', url: absolute('/'), logo: absolute('/images/app-icon.webp'), }; const app = { '@type': 'SoftwareApplication', '@id': absolute('/#app'), name: 'PulseCanvas Studio', url: absolute('/'), description: 'PulseCanvas Studio is a free music visualizer and video maker for Mac, iPhone and iPad. Import a soundtrack, arrange beat-aligned visuals, and export an MP4 with audio, up to 4K at 60 fps.', applicationCategory: 'MultimediaApplication', applicationSubCategory: 'Music visualizer', operatingSystem: 'macOS 14 or later, iOS 18 or later, iPadOS 18 or later, visionOS', processorRequirements: 'Apple silicon (Mac)', isAccessibleForFree: true, offers: { '@type': 'Offer', price: 0, priceCurrency: 'USD' }, downloadUrl: [testflightUrl, absolute('/download/')], author: { '@id': organization['@id'] }, publisher: { '@id': organization['@id'] }, sameAs: [testflightUrl], image: absolute('/images/app-icon.png'), screenshot: absolute('/images/app-studio.webp'), featureList: ['Native Metal visualizers in both editions; additional projectM / MilkDrop community effects in Creators Edition', 'Soundtrack import, scrubbing and loop preview', 'Beat-aligned Studio sequences with individual bar lengths', 'Per-visualizer saved styles', 'Save and reopen projects', 'H.264 MP4 exports with audio, up to 4K and 60 fps', 'Wide, landscape, portrait, phone and square canvases'], }; const video = { '@type': 'VideoObject', '@id': absolute('/watch/walkthrough/#video'), name: 'PulseCanvas Studio tutorial: make your first music video', description: seoPages['/watch/walkthrough/'].description, thumbnailUrl: [absolute('/images/tutorial-v6-poster.webp')], // Date first published on this website, rather than the capture's filesystem timestamp. uploadDate: '2026-10-15T22:00:00Z', duration: 'PT1M17.783S', contentUrl: filmUrl(films.walkthrough), url: absolute('/watch/walkthrough/'), inLanguage: 'en', publisher: { '@id': organization['@id'] }, about: { '@id': app['@id'] }, }; // Questions and answers as the support and compare pages show them, so the FAQ data can't drift from the visible text. const plainText = (markup) => markup.replace(/<[^>]+>/g, '').replace(/&/g, '&').replace(/\s+/g, ' ').trim(); export function supportFaq(html) { const block = html.match(/
([\s\S]*?)<\/div>/)?.[1] || ''; return Array.from(block.matchAll(/

([\s\S]*?)<\/h3>\s*

([\s\S]*?)<\/p>/g), ([, question, answer]) => ({ question: plainText(question), answer: plainText(answer) })); } export function structuredData(path, html = '') { const page = seoPages[path]; const graph = [organization, { '@type': 'WebSite', '@id': absolute('/#website'), url: absolute('/'), name: 'PulseCanvas Studio', publisher: { '@id': organization['@id'] }, inLanguage: 'en' }, { '@type': page.video ? 'ItemPage' : path.startsWith('/guides/') && path !== '/guides/' ? 'TechArticle' : 'WebPage', '@id': absolute(path + '#page'), url: absolute(path), name: page.title, description: page.description, isPartOf: { '@id': absolute('/#website') }, inLanguage: 'en', publisher: { '@id': organization['@id'] }, primaryImageOfPage: { '@type': 'ImageObject', url: absolute(socialImage.path), width: socialImage.width, height: socialImage.height }, ...(path.startsWith('/guides/') && path !== '/guides/' ? { headline: page.title, image: absolute('/images/app-studio.webp'), author: { '@id': organization['@id'] } } : {}), ...(page.video ? { mainEntity: { '@id': video['@id'] } } : { about: { '@id': app['@id'] } }), }]; graph.push(app); if (page.video) graph.push(video); const faq = ['/help/', '/compare/'].includes(path) ? supportFaq(html) : []; if (faq.length) graph.push({ '@type': 'FAQPage', '@id': absolute(path + '#faq'), url: absolute(path), about: { '@id': app['@id'] }, mainEntity: faq.map(({ question, answer }) => ({ '@type': 'Question', name: question, acceptedAnswer: { '@type': 'Answer', text: answer } })) }); if (path !== '/') { const crumbs = [{ name: 'Home', path: '/' }]; if (path.startsWith('/guides/') && path !== '/guides/') crumbs.push({ name: 'Guides', path: '/guides/' }); crumbs.push({ name: page.name, path }); graph.push({ '@type': 'BreadcrumbList', itemListElement: crumbs.map((crumb, i) => ({ '@type': 'ListItem', position: i + 1, name: crumb.name, item: absolute(crumb.path) })) }); } return { '@context': 'https://schema.org', '@graph': graph }; } export const sitemap = `\n\n${Object.keys(seoPages).map(path => ` ${absolute(path)}`).join('\n')}\n\n`; // Search engines and AI search, assistant and training crawlers are welcome, and named so the policy is explicit. This does not promise inclusion. const aiCrawlers = ['OAI-SearchBot', 'ChatGPT-User', 'GPTBot', 'ClaudeBot', 'Claude-SearchBot', 'Claude-User', 'PerplexityBot', 'Perplexity-User', 'Google-Extended', 'GoogleOther', 'Applebot', 'Applebot-Extended', 'bingbot', 'Amazonbot', 'meta-externalagent', 'meta-externalfetcher', 'DuckAssistBot', 'MistralAI-User', 'CCBot', 'cohere-ai', 'YouBot']; export const robots = `# PulseCanvas Studio welcomes search engines and AI assistants.\n# A plain-text summary for language models: ${absolute('/llms.txt')}\n\nUser-agent: *\nAllow: /\n\n# AI search, assistant and training crawlers, allowed by name.\n${aiCrawlers.map(name => `User-agent: ${name}\n`).join('')}Allow: /\n\nSitemap: ${absolute('/sitemap.xml')}\n`; // llms.txt: a plain-text summary of the app and a map of the site for AI assistants. Keep it in step with the pages. export const llms = `# PulseCanvas Studio > PulseCanvas Studio is a free music visualizer and video maker for Mac, iPhone and iPad. Import a soundtrack, choose and style visuals, arrange beat-aligned scenes to your song, and export an MP4 with audio, up to 4K at 60 fps. Key facts: - Price: free. Creators Edition and the iPhone and iPad beta are free, and every video and export is free. No account or subscription is required. - License: the application source is in the public domain (Unlicense). - Mac: an Apple silicon Mac with macOS 14 or later. Creators Edition, downloaded from ${absolute('/download/')}, includes over 100 native Metal visualizers plus 7,000+ MilkDrop community effects powered by projectM. - iPhone, iPad and Apple Vision Pro: a free beta on TestFlight, on iOS 18 and iPadOS 18 or later and on visionOS. ${testflightUrl} - Studio: build a sequence that moves with your music. Studio creates beat-aligned sections automatically, and you choose the visuals and how many bars each scene gets. - Export: H.264 MP4 with audio, up to 4K and 60 fps, on wide, landscape, portrait, phone and square canvases. - Also included: soundtrack import with scrubbing and loop preview, saved visual styles, projects you can save and reopen, and Radio. - Community effects: Creators Edition draws its 7,000+ effects from Cream of the Crop, a curated MilkDrop collection by ISOSCELES. ## Pages ${Object.entries(seoPages).filter(([path]) => !['/privacy/', '/licenses/'].includes(path)).map(([path, page]) => `- [${path === '/' ? 'PulseCanvas Studio' : page.name}](${absolute(path)}): ${page.description}`).join('\n')} ## Optional - [Privacy Policy](${absolute('/privacy/')}) - [Licenses](${absolute('/licenses/')}) `; export function seoPlugin() { return { name: 'pulsecanvas-seo', transformIndexHtml: { order: 'pre', handler(html, context) { const path = context.path.replace(/index\.html$/, '').replace(/\/{2,}/g, '/'); if (path === "/404.html") return html; const page = seoPages[path]; if (!page) throw new Error(`Missing SEO configuration for ${context.path}`); // Replace legacy metadata, so every route has exactly one canonical title and description. html = html.replace('href="/images/app-icon.png"', 'href="/images/favicon.png"') .replace(/[\s\S]*?<\/title>/gi, '') .replace(/<meta\b(?=[^>]*\b(?:name\s*=\s*["'](?:description|robots|msvalidate\.01|twitter:[^"']+)["']|property\s*=\s*["']og:[^"']+["']))[^>]*>/gi, '') .replace(/<link\b(?=[^>]*\brel\s*=\s*["']canonical["'])[^>]*>/gi, '') .replace(/<script\b(?=[^>]*\btype\s*=\s*["']application\/ld\+json["'])[^>]*>[\s\S]*?<\/script>/gi, ''); return { html, tags: [ { tag: 'title', children: page.title }, { tag: 'meta', attrs: { name: 'description', content: page.description } }, ...(path === '/' ? [{ tag: 'meta', attrs: { name: 'msvalidate.01', content: 'E2001B47E91F72A19BB1E8E642B26928' } }] : []), { tag: 'link', attrs: { rel: 'canonical', href: absolute(path) } }, { tag: 'meta', attrs: { name: 'robots', content: 'index, follow, max-image-preview:large, max-video-preview:-1' } }, ...Object.entries({ 'og:title': page.socialTitle || page.title, 'og:description': page.description, 'og:type': path.startsWith('/guides/') && path !== '/guides/' ? 'article' : 'website', 'og:url': absolute(path), 'og:site_name': 'PulseCanvas Studio', 'og:locale': 'en_US', 'og:image': absolute(socialImage.path), 'og:image:secure_url': absolute(socialImage.path), 'og:image:type': socialImage.type, 'og:image:width': String(socialImage.width), 'og:image:height': String(socialImage.height), 'og:image:alt': socialImage.alt, }).map(([property, content]) => ({ tag: 'meta', attrs: { property, content } })), ...Object.entries({ 'twitter:card': 'summary_large_image', 'twitter:title': page.socialTitle || page.title, 'twitter:description': page.description, 'twitter:image': absolute(socialImage.path), 'twitter:image:alt': socialImage.alt, }).map(([name, content]) => ({ tag: 'meta', attrs: { name, content } })), { tag: 'script', attrs: { type: 'application/ld+json' }, children: JSON.stringify(structuredData(path, html)).replaceAll('<', '\\u003c') }, ].map(tag => ({ ...tag, injectTo: 'head' })) }; }, }, configureServer(server) { server.middlewares.use((request, response, next) => { const route = request.url?.split('?')[0]; if (!['/sitemap.xml', '/robots.txt', '/llms.txt'].includes(route)) return next(); response.setHeader('Content-Type', route.endsWith('.xml') ? 'application/xml' : 'text/plain'); response.end(route === '/sitemap.xml' ? sitemap : route === '/llms.txt' ? llms : robots); }); }, generateBundle() { this.emitFile({ type: 'asset', fileName: 'sitemap.xml', source: sitemap }); this.emitFile({ type: 'asset', fileName: 'robots.txt', source: robots }); this.emitFile({ type: 'asset', fileName: 'llms.txt', source: llms }); }, }; }