Inkspring / website / scripts / seo.mjs
| 1 | // One source of truth for page titles, descriptions, social cards and structured data. |
| 2 | import { faqs } from '../src/faq.js'; |
| 3 | import { compare } from '../src/compare.js'; |
| 4 | |
| 5 | export const SITE_URL = 'https://inkspring.ai'; |
| 6 | export const socialImage = { |
| 7 | path: '/og/inkspring-monochrome.png', |
| 8 | width: 1200, height: 630, type: 'image/png', |
| 9 | alt: 'Inkspring. Write and schedule social posts for LinkedIn, X, and Instagram on your Mac.', |
| 10 | }; |
| 11 | export const pages = { |
| 12 | '/': { |
| 13 | title: 'Inkspring · Craft and schedule social posts on your Mac', |
| 14 | socialTitle: 'Inkspring · Craft your posts. Schedule your week.', |
| 15 | description: 'Download Inkspring, a free social media studio for Apple Silicon Macs. Craft posts in your voice, schedule your week, and post through official LinkedIn, X, and Instagram APIs. Open source.', |
| 16 | socialDescription: 'Craft social posts and witty replies, schedule your week, and post through official LinkedIn, X, and Instagram APIs. The power runs on your Mac; the iPhone and iPad companion syncs through your private iCloud. Free and open source.', |
| 17 | }, |
| 18 | '/privacy': { |
| 19 | title: 'Privacy · Inkspring', |
| 20 | description: 'How the static Inkspring website and the Inkspring Mac and iPhone apps handle your information, including local workspaces, optional iCloud sync, social accounts, support and the AI providers you choose.', |
| 21 | }, |
| 22 | '/research': { |
| 23 | title: 'Research · Inkspring', |
| 24 | description: 'Public research on sharing and social media, summarized in plain words with links to every source.', |
| 25 | }, |
| 26 | '/download': { |
| 27 | title: 'Download and install Inkspring for Mac', |
| 28 | description: 'Download the signed Inkspring installer for Apple Silicon Macs and follow the steps to install it, open your first draft, and get future updates.', |
| 29 | }, |
| 30 | '/404': { |
| 31 | title: 'Page not found · Inkspring', |
| 32 | description: 'Return to Inkspring or find setup and troubleshooting in Help.', |
| 33 | noindex: true, |
| 34 | }, |
| 35 | '/help': { |
| 36 | title: 'Help · Inkspring', |
| 37 | description: 'Set up and troubleshoot writing agents, API keys, official social accounts and Instagram media hosting in Inkspring for Mac.', |
| 38 | }, |
| 39 | '/compare': { title: compare.title, description: compare.description }, |
| 40 | '/app-notices': { |
| 41 | title: 'App notices · Inkspring', |
| 42 | description: 'Notices for the Inkspring Mac and iPhone apps, including your content, provider accounts and the public domain Unlicense.', |
| 43 | }, |
| 44 | }; |
| 45 | |
| 46 | const esc = value => String(value).replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>'); |
| 47 | const absolute = path => new URL(path, SITE_URL).href; |
| 48 | |
| 49 | export function structuredData(path) { |
| 50 | const page = pages[path]; |
| 51 | const org = { '@type': 'Organization', '@id': absolute('/#org'), name: 'Inkspring', url: absolute('/'), logo: absolute('/icon.png') }; |
| 52 | const app = { '@type': 'SoftwareApplication', '@id': absolute('/#app'), name: 'Inkspring', applicationCategory: 'ProductivityApplication', applicationSubCategory: 'Social media posting and scheduling', operatingSystem: 'macOS 14 or later', processorRequirements: 'Apple Silicon', description: faqs[0].a, url: absolute('/'), image: absolute(socialImage.path), isAccessibleForFree: true, offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' }, downloadUrl: absolute('/download'), |
| 53 | featureList: ['Write with your own saved notes and references', 'Write posts, threads, and image or video posts in your own voice', 'Paste a post and get a witty reply in 280 characters or less', 'Publish through the official LinkedIn, X, and Instagram APIs', 'Local workspace on the Mac, with backups you export', 'iPhone and iPad companion that syncs through your own iCloud'], |
| 54 | author: { '@id': org['@id'] }, publisher: { '@id': org['@id'] } }; |
| 55 | const questions = path === '/help' ? faqs : path === '/compare' ? compare.faqs : []; |
| 56 | const extra = questions.length ? [{ '@type': 'FAQPage', '@id': absolute(path + '#faq'), url: absolute(path), mainEntity: questions.map(({ q, a }) => ({ '@type': 'Question', name: q, acceptedAnswer: { '@type': 'Answer', text: a } })) }] : []; |
| 57 | return { '@context': 'https://schema.org', '@graph': [ |
| 58 | org, |
| 59 | { '@type': 'WebSite', '@id': absolute('/#website'), url: absolute('/'), name: 'Inkspring', publisher: { '@id': org['@id'] }, inLanguage: 'en' }, |
| 60 | { '@type': 'WebPage', '@id': absolute(path + '#page'), url: absolute(path), name: page.title, description: page.description, isPartOf: { '@id': absolute('/#website') }, about: { '@id': app['@id'] }, primaryImageOfPage: { '@type': 'ImageObject', url: absolute(socialImage.path), width: socialImage.width, height: socialImage.height }, inLanguage: 'en' }, |
| 61 | app, |
| 62 | ...extra, |
| 63 | ] }; |
| 64 | } |
| 65 | |
| 66 | // Head tags for one page: canonical, Open Graph, X card and JSON-LD. |
| 67 | export function headTags(path) { |
| 68 | const page = pages[path]; |
| 69 | const url = absolute(path); |
| 70 | const title = page.socialTitle || page.title; |
| 71 | const description = page.socialDescription || page.description; |
| 72 | const image = absolute(socialImage.path); |
| 73 | const meta = [ |
| 74 | ['name', 'description', page.description], |
| 75 | ['name', 'robots', page.noindex ? 'noindex, follow' : 'index, follow, max-image-preview:large'], |
| 76 | ['property', 'og:type', 'website'], ['property', 'og:site_name', 'Inkspring'], ['property', 'og:locale', 'en_US'], |
| 77 | ['property', 'og:url', url], ['property', 'og:title', title], ['property', 'og:description', description], |
| 78 | ['property', 'og:image', image], ['property', 'og:image:secure_url', image], ['property', 'og:image:type', socialImage.type], |
| 79 | ['property', 'og:image:width', socialImage.width], ['property', 'og:image:height', socialImage.height], ['property', 'og:image:alt', socialImage.alt], |
| 80 | ['name', 'twitter:card', 'summary_large_image'], |
| 81 | ['name', 'twitter:title', title], ['name', 'twitter:description', description], ['name', 'twitter:image', image], ['name', 'twitter:image:alt', socialImage.alt], |
| 82 | ]; |
| 83 | return [ |
| 84 | `<title>${esc(page.title)}</title>`, |
| 85 | `<link rel="canonical" href="${esc(url)}"/>`, |
| 86 | ...meta.map(([key, name, content]) => `<meta ${key}="${name}" content="${esc(content)}"/>`), |
| 87 | `<script type="application/ld+json">${JSON.stringify(structuredData(path)).replaceAll('<', '\\u003c')}</script>`, |
| 88 | ].join(''); |
| 89 | } |