diff --git a/.changeset/soft-readers-shout.md b/.changeset/soft-readers-shout.md new file mode 100644 index 00000000..8b5dda77 --- /dev/null +++ b/.changeset/soft-readers-shout.md @@ -0,0 +1,5 @@ +--- +"@matthiesenxyz/starlight-ghostcms": patch +--- + +Adds 2 new pages, Authors, and about page(Link will disappear if you dont have the default ghost about page with slug "about"). Also adds auto links from ghost settings for twitter and facebook if not set my the user in starlight. diff --git a/packages/starlight-ghostcms/index.ts b/packages/starlight-ghostcms/index.ts index ad9f00ae..0c018270 100644 --- a/packages/starlight-ghostcms/index.ts +++ b/packages/starlight-ghostcms/index.ts @@ -2,12 +2,16 @@ import type { StarlightPlugin, StarlightUserConfig } from '@astrojs/starlight/ty import type { AstroIntegrationLogger } from 'astro' import { type StarlightGhostConfig, validateConfig } from './src/schemas/config' import { vitePluginStarlightGhostConfig } from './src/integrations/vite' +import { facebook, getSettings, invariant, twitter } from './src/utils/api' + +const settings = await getSettings() export type { StarlightGhostConfig } export default function starlightGhostCMS(userConfig?: StarlightGhostConfig): StarlightPlugin { const config: StarlightGhostConfig = validateConfig(userConfig) - + invariant(settings, "Settings not available... check your api key/url") + return { name: '@matthiesenxyz/starlight-ghostcms-plugin', hooks: { @@ -15,7 +19,9 @@ export default function starlightGhostCMS(userConfig?: StarlightGhostConfig): St updateStarlightConfig({ social: { ...starlightConfig.social, - rss: `${astroConfig.site}/rss.xml` + rss: `${astroConfig.site}/rss.xml`, + twitter: twitter(settings.twitter?settings.twitter:""), + facebook: facebook(settings.facebook?settings.facebook:""), }, components: { ...starlightConfig.components, @@ -39,6 +45,15 @@ export default function starlightGhostCMS(userConfig?: StarlightGhostConfig): St entrypoint: '@matthiesenxyz/starlight-ghostcms/routes/[slug].astro', prerender: true, }) + injectRoute({ + pattern: '/blog/about', + entrypoint: '@matthiesenxyz/starlight-ghostcms/routes/about.astro', + prerender: true, + }) + injectRoute({ + pattern: '/blog/authors', + entrypoint: '@matthiesenxyz/starlight-ghostcms/routes/authors.astro', + }) injectRoute({ pattern: '/rss.xml', entrypoint: '@matthiesenxyz/starlight-ghostcms/routes/rss.xml.ts' diff --git a/packages/starlight-ghostcms/package.json b/packages/starlight-ghostcms/package.json index deb081fd..b2a7d8ff 100644 --- a/packages/starlight-ghostcms/package.json +++ b/packages/starlight-ghostcms/package.json @@ -46,6 +46,8 @@ "./overrides/Sidebar.astro": "./src/overrides/Sidebar.astro", "./overrides/SiteTitle.astro": "./src/overrides/SiteTitle.astro", "./routes/index.astro": "./src/routes/index.astro", + "./routes/about.astro": "./src/routes/about.astro", + "./routes/authors.astro": "./src/routes/authors.astro", "./routes/[slug].astro": "./src/routes/[slug].astro", "./routes/rss.xml.ts": "./src/routes/rss.xml.ts", "./schema": "./src/schemas/config.ts" diff --git a/packages/starlight-ghostcms/src/components/AdvancedAuthorCard.astro b/packages/starlight-ghostcms/src/components/AdvancedAuthorCard.astro new file mode 100644 index 00000000..fd16ec71 --- /dev/null +++ b/packages/starlight-ghostcms/src/components/AdvancedAuthorCard.astro @@ -0,0 +1,70 @@ +--- +import type { Author } from '../schemas/authors' +import { facebook } from '../utils/api' + +interface Props { + author: Author +} + +const { author } = Astro.props + +--- + +
+ + diff --git a/packages/starlight-ghostcms/src/components/Author.astro b/packages/starlight-ghostcms/src/components/Author.astro index bbf982a7..bfacf6e3 100644 --- a/packages/starlight-ghostcms/src/components/Author.astro +++ b/packages/starlight-ghostcms/src/components/Author.astro @@ -7,11 +7,11 @@ interface Props { const { author } = Astro.props -const isLink = author.website !== undefined +const isLink = author.slug !== undefined const Element = isLink ? 'a' : 'div' --- -