From 8db7190be8933eaeaf5bc408c4d35a8ac5fc7592 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 05:17:54 -0800 Subject: [PATCH 01/46] First group of progress changes... and it works --- package.json | 2 +- packages/astro-ghostcms/.env.demo | 2 - packages/astro-ghostcms/CHANGELOG.md | 2 +- packages/astro-ghostcms/LICENSE | 2 +- packages/astro-ghostcms/README.md | 1 - packages/astro-ghostcms/index.ts | 359 ----------- packages/astro-ghostcms/package.json | 176 ++--- .../src/api/content-api/content-api.test.ts | 84 --- .../src/api/content-api/content-api.ts | 116 ---- .../src/api/content-api/index.ts | 8 - .../schemas/authors/authors.test.ts | 164 ----- .../api/content-api/schemas/authors/index.ts | 1 - .../api/content-api/schemas/helpers/index.ts | 1 - .../api/content-api/schemas/pages/index.ts | 1 - .../api/content-api/schemas/posts/index.ts | 1 - .../content-api/schemas/posts/posts.test.ts | 69 -- .../api/content-api/schemas/settings/index.ts | 1 - .../src/api/content-api/schemas/tags/index.ts | 1 - .../api/content-api/schemas/tiers/index.ts | 1 - .../src/api/{api-functions.ts => ghostAPI.ts} | 10 +- packages/astro-ghostcms/src/api/index.ts | 5 +- .../astro-ghostcms/src/api/invariant.test.ts | 32 - packages/astro-ghostcms/src/api/invariant.ts | 3 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 170 +++++ packages/astro-ghostcms/src/index.ts | 3 + .../src/integrations/robots-txt.ts | 28 - .../rssfeed/astro-ghostcms-rss.ts | 48 ++ .../src/integrations/rssfeed/index.ts | 3 + .../rssfeed/routes}/rss-style.xsl.ts | 2 +- .../rssfeed/routes}/rss.xml.ts | 4 +- .../satoriog/astro-ghostcms-satoriog.ts | 73 +++ .../src/integrations/satoriog/index.ts | 3 + .../satoriog/routes}/[slug].png.ts | 6 +- .../satoriog/routes}/author/[slug].png.ts | 6 +- .../satoriog/routes}/authors.png.ts | 6 +- .../satoriog/routes}/index.png.ts | 6 +- .../satoriog/routes}/tag/[slug].png.ts | 6 +- .../satoriog/routes}/tags.png.ts | 6 +- .../src/integrations/{ => satoriog}/satori.ts | 4 +- .../integrations/satoriog}/types.d.ts | 21 +- .../src/integrations/sitemap.ts | 38 -- .../astro-ghostcms-themeprovider.ts | 81 +++ .../src/integrations/themeprovider/index.ts | 3 + .../src/integrations/virtual-config.ts | 6 - .../src/integrations/virtual.d.ts | 4 - .../{default-routes/404 => routes}/404.astro | 2 +- .../{default-routes/404 => routes}/404.css | 0 .../authors => schemas/api}/authors.ts | 4 +- .../schemas => schemas/api}/index.ts | 4 +- .../schemas/pages => schemas/api}/pages.ts | 8 +- .../schemas/posts => schemas/api}/posts.ts | 8 +- .../settings => schemas/api}/settings.ts | 4 +- .../helpers => schemas/api}/socials.ts | 2 +- .../schemas/tags => schemas/api}/tags.ts | 4 +- .../schemas/tiers => schemas/api}/tiers.ts | 4 +- packages/astro-ghostcms/src/schemas/index.ts | 3 - .../astro-ghostcms/src/schemas/userconfig.ts | 53 +- .../src/utils/add-virtual-import.test.ts | 82 --- .../src/utils/add-virtual-import.ts | 93 --- .../src/utils/add-vite-plugin.test.ts | 69 -- .../src/utils/add-vite-plugin.ts | 55 -- .../astro-ghostcms/src/utils/latestVersion.ts | 26 - .../utils/zod-validation/ValidationError.js | 22 - .../src/utils/zod-validation/config.js | 5 - .../src/utils/zod-validation/errorMap.js | 10 - .../src/utils/zod-validation/fromZodError.js | 37 -- .../src/utils/zod-validation/fromZodIssue.js | 61 -- .../src/utils/zod-validation/index.js | 7 - .../utils/zod-validation/isValidationError.js | 4 - .../zod-validation/isValidationErrorLike.js | 3 - .../src/utils/zod-validation/prefixMessage.js | 13 - .../utils/zod-validation/toValidationError.js | 14 - .../zod-validation/utils/NonEmptyArray.js | 3 - .../utils/zod-validation/utils/joinPath.js | 22 - packages/astro-ghostcms/vitest.config.ts | 15 - playground/.env | 2 - playground/src/env.d.ts | 1 - playgrounds/astro-playground/.env | 1 + .../astro-playground}/.gitignore | 0 .../astro-playground}/.vscode/extensions.json | 0 .../astro-playground}/.vscode/launch.json | 0 .../astro-playground}/CHANGELOG.md | 0 .../astro-playground}/LICENSE | 0 .../astro-playground}/README.md | 0 .../astro-playground}/astro.config.mjs | 8 +- .../astro-playground}/package.json | 6 +- .../astro-playground}/public/favicon.svg | 0 playgrounds/astro-playground/src/env.d.ts | 3 + .../astro-playground}/tailwind.config.cjs | 0 .../astro-playground}/tsconfig.json | 0 .../astro-playground}/uno.config.ts | 0 .../starlight-playground}/.gitignore | 0 .../.vscode/extensions.json | 0 .../starlight-playground}/.vscode/launch.json | 0 .../starlight-playground}/astro.config.mjs | 0 .../starlight-playground}/package.json | 0 .../starlight-playground}/public/favicon.svg | 0 .../src/assets/houston.webp | Bin .../src/content/config.ts | 0 .../src/content/docs/guides/example.md | 0 .../src/content/docs/index.mdx | 0 .../src/content/docs/reference/example.md | 0 .../starlight-playground}/src/env.d.ts | 0 .../starlight-playground}/tsconfig.json | 0 pnpm-lock.yaml | 605 ++++++++++++------ pnpm-workspace.yaml | 3 +- 106 files changed, 944 insertions(+), 1891 deletions(-) delete mode 100644 packages/astro-ghostcms/.env.demo delete mode 100644 packages/astro-ghostcms/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/content-api.test.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/content-api.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.test.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/authors/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/helpers/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/pages/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/posts/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.test.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/settings/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/tags/index.ts delete mode 100644 packages/astro-ghostcms/src/api/content-api/schemas/tiers/index.ts rename packages/astro-ghostcms/src/api/{api-functions.ts => ghostAPI.ts} (90%) delete mode 100644 packages/astro-ghostcms/src/api/invariant.test.ts create mode 100644 packages/astro-ghostcms/src/astro-ghostcms.ts create mode 100644 packages/astro-ghostcms/src/index.ts delete mode 100644 packages/astro-ghostcms/src/integrations/robots-txt.ts create mode 100644 packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts create mode 100644 packages/astro-ghostcms/src/integrations/rssfeed/index.ts rename packages/astro-ghostcms/src/{default-routes => integrations/rssfeed/routes}/rss-style.xsl.ts (99%) rename packages/astro-ghostcms/src/{default-routes => integrations/rssfeed/routes}/rss.xml.ts (90%) create mode 100644 packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts create mode 100644 packages/astro-ghostcms/src/integrations/satoriog/index.ts rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/[slug].png.ts (96%) rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/author/[slug].png.ts (96%) rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/authors.png.ts (96%) rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/index.png.ts (96%) rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/tag/[slug].png.ts (96%) rename packages/astro-ghostcms/src/{default-routes/open-graph => integrations/satoriog/routes}/tags.png.ts (96%) rename packages/astro-ghostcms/src/integrations/{ => satoriog}/satori.ts (98%) rename packages/astro-ghostcms/{ => src/integrations/satoriog}/types.d.ts (63%) delete mode 100644 packages/astro-ghostcms/src/integrations/sitemap.ts create mode 100644 packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts create mode 100644 packages/astro-ghostcms/src/integrations/themeprovider/index.ts delete mode 100644 packages/astro-ghostcms/src/integrations/virtual-config.ts delete mode 100644 packages/astro-ghostcms/src/integrations/virtual.d.ts rename packages/astro-ghostcms/src/{default-routes/404 => routes}/404.astro (88%) rename packages/astro-ghostcms/src/{default-routes/404 => routes}/404.css (100%) rename packages/astro-ghostcms/src/{api/content-api/schemas/authors => schemas/api}/authors.ts (95%) rename packages/astro-ghostcms/src/{api/content-api/schemas => schemas/api}/index.ts (71%) rename packages/astro-ghostcms/src/{api/content-api/schemas/pages => schemas/api}/pages.ts (92%) rename packages/astro-ghostcms/src/{api/content-api/schemas/posts => schemas/api}/posts.ts (93%) rename packages/astro-ghostcms/src/{api/content-api/schemas/settings => schemas/api}/settings.ts (91%) rename packages/astro-ghostcms/src/{api/content-api/schemas/helpers => schemas/api}/socials.ts (99%) rename packages/astro-ghostcms/src/{api/content-api/schemas/tags => schemas/api}/tags.ts (96%) rename packages/astro-ghostcms/src/{api/content-api/schemas/tiers => schemas/api}/tiers.ts (96%) delete mode 100644 packages/astro-ghostcms/src/schemas/index.ts delete mode 100644 packages/astro-ghostcms/src/utils/add-virtual-import.test.ts delete mode 100644 packages/astro-ghostcms/src/utils/add-virtual-import.ts delete mode 100644 packages/astro-ghostcms/src/utils/add-vite-plugin.test.ts delete mode 100644 packages/astro-ghostcms/src/utils/add-vite-plugin.ts delete mode 100644 packages/astro-ghostcms/src/utils/latestVersion.ts delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/ValidationError.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/config.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/errorMap.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/fromZodError.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/fromZodIssue.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/index.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/isValidationError.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/isValidationErrorLike.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/prefixMessage.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/toValidationError.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/utils/NonEmptyArray.js delete mode 100644 packages/astro-ghostcms/src/utils/zod-validation/utils/joinPath.js delete mode 100644 packages/astro-ghostcms/vitest.config.ts delete mode 100644 playground/.env delete mode 100644 playground/src/env.d.ts create mode 100644 playgrounds/astro-playground/.env rename {playground => playgrounds/astro-playground}/.gitignore (100%) rename {playground => playgrounds/astro-playground}/.vscode/extensions.json (100%) rename {playground => playgrounds/astro-playground}/.vscode/launch.json (100%) rename {playground => playgrounds/astro-playground}/CHANGELOG.md (100%) rename {playground => playgrounds/astro-playground}/LICENSE (100%) rename {playground => playgrounds/astro-playground}/README.md (100%) rename {playground => playgrounds/astro-playground}/astro.config.mjs (71%) rename {playground => playgrounds/astro-playground}/package.json (79%) rename {playground => playgrounds/astro-playground}/public/favicon.svg (100%) create mode 100644 playgrounds/astro-playground/src/env.d.ts rename {playground => playgrounds/astro-playground}/tailwind.config.cjs (100%) rename {playground => playgrounds/astro-playground}/tsconfig.json (100%) rename {playground => playgrounds/astro-playground}/uno.config.ts (100%) rename {starlight-playground => playgrounds/starlight-playground}/.gitignore (100%) rename {starlight-playground => playgrounds/starlight-playground}/.vscode/extensions.json (100%) rename {starlight-playground => playgrounds/starlight-playground}/.vscode/launch.json (100%) rename {starlight-playground => playgrounds/starlight-playground}/astro.config.mjs (100%) rename {starlight-playground => playgrounds/starlight-playground}/package.json (100%) rename {starlight-playground => playgrounds/starlight-playground}/public/favicon.svg (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/assets/houston.webp (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/content/config.ts (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/content/docs/guides/example.md (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/content/docs/index.mdx (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/content/docs/reference/example.md (100%) rename {starlight-playground => playgrounds/starlight-playground}/src/env.d.ts (100%) rename {starlight-playground => playgrounds/starlight-playground}/tsconfig.json (100%) diff --git a/package.json b/package.json index ad52c7b5..04ff3b53 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "node": ">=18.19.0" }, "scripts": { - "dev": "pnpm --filter playground dev", + "astro:dev": "pnpm --filter astro-playground dev", "starlight:dev": "pnpm --filter starlight-playground dev", "lint": "biome check .", "lint:fix": "biome check --apply .", diff --git a/packages/astro-ghostcms/.env.demo b/packages/astro-ghostcms/.env.demo deleted file mode 100644 index e1699c0e..00000000 --- a/packages/astro-ghostcms/.env.demo +++ /dev/null @@ -1,2 +0,0 @@ -CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48 -CONTENT_API_URL=https://ghostdemo.matthiesen.xyz \ No newline at end of file diff --git a/packages/astro-ghostcms/CHANGELOG.md b/packages/astro-ghostcms/CHANGELOG.md index a9e053ba..19219270 100644 --- a/packages/astro-ghostcms/CHANGELOG.md +++ b/packages/astro-ghostcms/CHANGELOG.md @@ -60,4 +60,4 @@ - Initialization of changeset cli - Updated dependencies - - @matthiesenxyz/astro-ghostcms-theme-default@0.1.10 + - @matthiesenxyz/astro-ghostcms-theme-default@0.1.10 \ No newline at end of file diff --git a/packages/astro-ghostcms/LICENSE b/packages/astro-ghostcms/LICENSE index 592eb27d..5fe4487a 100644 --- a/packages/astro-ghostcms/LICENSE +++ b/packages/astro-ghostcms/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index 8029250d..b50af9a8 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -113,4 +113,3 @@ For more information and to see the docs please check our website: [Astro-GhostC # Foot Notes & Credits [^1]: Ghost.org, Ghost.io, Ghost are all trademarks of [The Ghost Foundation](https://ghost.org/). This project is Open Source and not directly related to or provided by The Ghost Foundation and is intended to help create a easier method to utilize their provided JavaScript tools to link a Headless GhostCMS install in to your Astro project. - diff --git a/packages/astro-ghostcms/index.ts b/packages/astro-ghostcms/index.ts deleted file mode 100644 index 88715ed3..00000000 --- a/packages/astro-ghostcms/index.ts +++ /dev/null @@ -1,359 +0,0 @@ -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import type { AstroIntegration } from "astro"; -import type { SafeParseError, SafeParseSuccess } from "astro/zod"; -import fse from "fs-extra"; -import { loadEnv } from "vite"; -import ghostRobots from "./src/integrations/robots-txt"; -import ghostSitemap from "./src/integrations/sitemap"; -import { UserConfigSchema } from "./src/schemas"; -import { addVirtualImport } from "./src/utils/add-virtual-import"; -import latestVersion from "./src/utils/latestVersion.js"; -import { fromZodError } from "./src/utils/zod-validation/fromZodError.js"; -import type { UserConfig } from "./types"; - -/** INTERNAL CONSTANTS */ -const IC = { - /** INTERNAL PACKAGE NAME */ - PKG: "@matthiesenxyz/astro-ghostcms", - /** INTERNAL PACKAGE NAME (THEME) */ - DT: "@matthiesenxyz/astro-ghostcms-theme-default", - /** INTERNAL STRING */ - CHECK_ENV: "Checking for Environment Variables...", - /** SET ENV GRABBER MODE */ - MODE: "all", - /** SET ENV GRABBER PREFIXES */ - PREFIXES: "CONTENT_API", - /** INTERNAL STRING */ - KEY_MISSING: "CONTENT_API_KEY Missing from .env/environment variables", - /** INTERNAL STRING */ - URL_MISSING: - "CONTENT_API_URL Missing from .env/environment variables or ghostURL under the integration settings in `astro.config.mjs`", - /** INTERNAL STRING */ - IT: "Injecting Theme: ", - /** INTERNAL STRING */ - IDR: "Injecting Default Routes...", - /** INTERNAL STRING */ - ITR: "Injecting Default Theme Routes...", - /** INTERNAL STRING */ - IRD: "Route Injection Disabled - Skipping...", - /** INTERNAL STRING */ - IIR: "Injecting Integration Route: ", - /** INTERNAL STRING */ - II: "Injecting Integration: ", - /** INTERNAL STRING */ - AIbU: "Already Imported by User: ", - /** INTERNAL STRING */ - CF: "Checking for ", - /** INTERNAL STRING */ - CONFSETUPDONE: "Step Complete", - /** INTERNAL STRING */ - F0FR: "Inject `/404` Route", - /** INTERNAL STRING */ - RSS: "Injecting `/rss.xml` Route and `@astrojs/rss` Integration", - /** INTERNAL STRING */ - NOURL: - "No Ghost URL defined in User Config: Falling back to environment variables.", - /** INTERNAL STRING */ - id404: "404 Injection Disabled", - /** INTERNAL STRING */ - idRSS: "RSS Injection Disabled", - /** INTERNAL STRING */ - satori_e: "Injecting Satori-OpenGraph Generator", - /** INTERNAL STRING */ - satori_d: "Satori Injection disabled", -}; - -/** CONTENT API ENVIRONMENT VARIABLES */ -const ENV = loadEnv(IC.MODE, process.cwd(), IC.PREFIXES); - -/** Astro-GhostCMS Integration - * @ For more information and to see the docs check - * @see https://astro-ghostcms.xyz - */ -export default function GhostCMS(options: UserConfig): AstroIntegration { - return { - name: "astro-ghostcms", - hooks: { - "astro:config:setup": async ({ - injectRoute, - config, - updateConfig, - logger, - }) => { - // DEFINE LOGGERS - const logConfigCheck = logger.fork("astro-ghostcms/config:check"); - const logConfigSetup = logger.fork("astro-ghostcms/config:setup"); - - // CHECK USER CONFIG AND MAKE AVAILBLE TO INTEGRATIONS - logConfigCheck.info("Checking Config..."); - const GhostUserConfig = UserConfigSchema.safeParse( - options || {}, - ) as SafeParseSuccess; - if (!GhostUserConfig.success) { - const validationError = fromZodError( - (GhostUserConfig as unknown as SafeParseError).error, - ); - logConfigCheck.error(`Config Error - ${validationError}`); - throw Error(""); - } - const GhostConfig = GhostUserConfig.data; - const GCD = { - theme: GhostConfig.theme, - dRI: GhostConfig.disableRouteInjection, - dCO: GhostConfig.disableConsoleOutput, - SM: GhostConfig.sitemap, - RTXT: GhostConfig.robotstxt, - gSite: GhostConfig.ghostURL, - dRSS: GhostConfig.disableRSS, - d404: GhostConfig.disable404, - dOG: GhostConfig.disableSatoriOG, - }; - - // Check For ENV Variables - if (!GCD.dCO) { - logConfigCheck.info(IC.CHECK_ENV); - } - if (ENV.CONTENT_API_KEY === undefined) { - logConfigCheck.error(IC.KEY_MISSING); - throw IC.KEY_MISSING; - } - if (GCD.gSite === undefined) { - logConfigCheck.warn(IC.NOURL); - if (ENV.CONTENT_API_URL === undefined) { - logConfigCheck.error(IC.URL_MISSING); - throw IC.URL_MISSING; - } - } - - if (!GCD.dRI) { - // THEME SELECTOR - if (GCD.theme === IC.DT) { - if (!GCD.dCO) { - logConfigCheck.info(IC.IT + IC.DT); - } - } else { - if (!GCD.dCO) { - logConfigCheck.info(IC.IT + GCD.theme); - } - } - // INJECT ROUTES - //// DEFAULT PROGRAM ROUTES - if (!GCD.dCO) { - logConfigSetup.info(IC.IDR); - } - if (!GCD.d404) { - if (!GCD.dCO) { - logConfigSetup.info(IC.F0FR); - } - injectRoute({ - pattern: "/404", - entrypoint: `${IC.PKG}/404.astro`, - }); - } else { - if (!GCD.dCO) { - logConfigSetup.info(IC.id404); - } - } - - if (!GCD.dRSS) { - if (!GCD.dCO) { - logConfigSetup.info(IC.RSS); - } - injectRoute({ - pattern: "/rss-style.xsl", - entrypoint: `${IC.PKG}/rss-style.xsl.ts`, - }); - injectRoute({ - pattern: "/rss.xml", - entrypoint: `${IC.PKG}/rss.xml.ts`, - }); - } else { - if (!GCD.dCO) { - logConfigSetup.info(IC.idRSS); - } - } - - if (!GCD.dOG) { - if (!GCD.dCO) { - logConfigSetup.info(IC.satori_e); - } - injectRoute({ - pattern: "/open-graph/[slug].png", - entrypoint: `${IC.PKG}/open-graph/[slug].png.ts`, - }); - injectRoute({ - pattern: "/open-graph/index.png", - entrypoint: `${IC.PKG}/open-graph/index.png.ts`, - }); - injectRoute({ - pattern: "/open-graph/authors.png", - entrypoint: `${IC.PKG}/open-graph/authors.png.ts`, - }); - injectRoute({ - pattern: "/open-graph/author/[slug].png", - entrypoint: `${IC.PKG}/open-graph/author/[slug].png.ts`, - }); - injectRoute({ - pattern: "/open-graph/tags.png", - entrypoint: `${IC.PKG}/open-graph/tags.png.ts`, - }); - injectRoute({ - pattern: "/open-graph/tag/[slug].png", - entrypoint: `${IC.PKG}/open-graph/tag/[slug].png.ts`, - }); - } else { - if (!GCD.dCO) { - logConfigSetup.info(IC.satori_d); - } - } - - // THEME ROUTES - if (!GCD.dCO) { - logConfigSetup.info(IC.ITR); - } - - injectRoute({ - pattern: "/", - entrypoint: `${GCD.theme}/index.astro`, - }); - injectRoute({ - pattern: "/[slug]", - entrypoint: `${GCD.theme}/[slug].astro`, - }); - injectRoute({ - pattern: "/tags", - entrypoint: `${GCD.theme}/tags.astro`, - }); - injectRoute({ - pattern: "/authors", - entrypoint: `${GCD.theme}/authors.astro`, - }); - injectRoute({ - pattern: "/tag/[slug]", - entrypoint: `${GCD.theme}/tag/[slug].astro`, - }); - injectRoute({ - pattern: "/author/[slug]", - entrypoint: `${GCD.theme}/author/[slug].astro`, - }); - injectRoute({ - pattern: "/archives/[...page]", - entrypoint: `${GCD.theme}/archives/[...page].astro`, - }); - } else { - if (!GCD.dCO) { - logConfigSetup.info(IC.IRD); - } - } - - // IMPORT INTEGRATIONS & INTEGRATION ROUTES - const integrations = [...config.integrations]; - - // IMPORT INTEGRATION: @ASTROJS/SITEMAP - if (!GCD.dCO) { - logConfigSetup.info(`${IC.CF}@astrojs/sitemap`); - } - if (!integrations.find(({ name }) => name === "@astrojs/sitemap")) { - if (!GCD.dCO) { - logConfigSetup.info(`${IC.II}@astrojs/sitemap`); - } - integrations.push(ghostSitemap(GCD.SM)); - } else { - if (!GCD.dCO) { - logConfigSetup.info(`${IC.AIbU}@astrojs/sitemap`); - } - } - - // IMPORT INTEGRATION: ASTRO-ROBOTS-TXT - if (!GCD.dCO) { - logConfigSetup.info(`${IC.CF}astro-robots-txt`); - } - if (!integrations.find(({ name }) => name === "astro-robots-txt")) { - if (!GCD.dCO) { - logConfigSetup.info(`${IC.II}astro-robots-txt`); - } - integrations.push(ghostRobots(GCD.RTXT)); - } else { - if (!GCD.dCO) { - logConfigSetup.info(`${IC.AIbU}astro-robots-txt`); - } - } - - // FINAL STEP TO KEEP INTEGRATION LIVE - try { - updateConfig({ - // UPDATE ASTRO CONFIG WITH INTEGRATED INTEGRATIONS - integrations: [ghostSitemap(GCD.SM), ghostRobots(GCD.RTXT)], - vite: { - optimizeDeps: { exclude: ["@resvg/resvg-js"] }, - }, - }); - } catch (e) { - logConfigSetup.error(e as string); - throw e; - } - - addVirtualImport({ - name: "virtual:@matthiesenxyz/astro-ghostcms/config", - content: `export default ${JSON.stringify(GhostUserConfig.data)}`, - updateConfig, - }); - }, - "astro:config:done": async ({ logger }) => { - // Config Done - const logConfigDone = logger.fork("astro-ghostcms/config:done"); - const pJSON = await fse.readJson( - path.resolve(fileURLToPath(import.meta.url), "..", "package.json"), - ); - const pkgVer = pJSON.version; - logConfigDone.info(`Config Done. Current Version: v${pkgVer}`); - }, - "astro:server:setup": async ({ logger }) => { - // Dev Server Start - const logServerSetup = logger.fork("astro-ghostcms/server:setup"); - const logCurrentVersion = logger.fork("astro-ghostcms/current-version"); - const logNpmVersion = logger.fork("astro-ghostcms/npm-pub-version"); - const logCheck = logger.fork("astro-ghostcms/check"); - const pJSON = await fse.readJson( - path.resolve(fileURLToPath(import.meta.url), "..", "package.json"), - ); - const pkgVer = pJSON.version; - const npmVER = await latestVersion(IC.PKG); - if (pkgVer !== npmVER) { - logCurrentVersion.warn(`Current Installed Version is v${pkgVer}`); - logNpmVersion.warn(`Latest Published Version is v${npmVER}`); - logCheck.warn("Please consider updating."); - } - logServerSetup.info( - "Setting up Astro-GhostCMS server for Development!", - ); - }, - "astro:server:start": async ({ logger }) => { - // Server Start - const logServerStart = logger.fork("astro-ghostcms/server:start"); - logServerStart.info("Astro-GhostCMS Integration Ready!"); - }, - "astro:build:done": async ({ logger }) => { - // Build Done - const logBuildDone = logger.fork("astro-ghostcms/build:done"); - const logCurrentVersion = logger.fork("astro-ghostcms/current-version"); - const logNpmVersion = logger.fork("astro-ghostcms/npm-pub-version"); - const logCheck = logger.fork("astro-ghostcms/check"); - const pJSON = await fse.readJson( - path.resolve(fileURLToPath(import.meta.url), "..", "package.json"), - ); - const pkgVer = pJSON.version; - const npmVER = await latestVersion(IC.PKG); - if (pkgVer !== npmVER) { - logCurrentVersion.warn(`Current Installed Version is v${pkgVer}`); - logNpmVersion.warn(`Latest Published Version is v${npmVER}`); - logCheck.warn("Please consider updating."); - } - logBuildDone.info( - `Build Complete, Integration Now ready for Production. Astro-GhostCMS v${pkgVer}`, - ); - }, - }, - }; -} diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 036503d0..c81e3c24 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -1,111 +1,73 @@ { - "name": "@matthiesenxyz/astro-ghostcms", - "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", - "version": "3.2.9", - "homepage": "https://astro-ghostcms.xyz/", - "type": "module", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "sideEffects": false, - "author": { - "email": "adam@matthiesen.xyz", - "name": "Adam Matthiesen - MatthiesenXYZ", - "url": "https://matthiesen.xyz" - }, - "keywords": [ - "astro-component", - "astro-integration", - "withastro", - "astro", - "blog", - "content", - "integration", - "ghost", - "ghostcms", - "ghostcms-theme", - "ghost-theme", - "astro-theme" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/MatthiesenXYZ/astro-ghostcms.git" - }, - "bugs": { - "url": "https://github.com/MatthiesenXYZ/astro-ghostcms/issues", - "email": "issues@astro-ghostcms.xyz" - }, - "main": "index.ts", - "types": "types.d.ts", - "files": [ - "src", - ".env.demo", - "index.ts", - "tsconfig.json", - "types.d.ts" - ], - "exports": { - ".": "./index.ts", - "./api": { - "types": "./src/api/index.ts", - "default": "./src/api/index.ts" + "name": "@matthiesenxyz/astro-ghostcms", + "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", + "version": "3.3.0-dev.1", + "homepage": "https://astro-ghostcms.xyz/", + "type": "module", + "license": "MIT", + "publishConfig": { + "access": "public" }, - "./api-core": "./src/api/content-api/index.ts", - "./config": { - "types": "./src/integrations/virtual.d.ts", - "default": "./src/integrations/virtual-config.ts" + "sideEffects": false, + "author": { + "email": "adam@matthiesen.xyz", + "name": "Adam Matthiesen - MatthiesenXYZ", + "url": "https://matthiesen.xyz" }, - "./satoriOG": "./src/integrations/satori.ts", - "./404.astro": "./src/default-routes/404/404.astro", - "./rss.xml.ts": "./src/default-routes/rss.xml.ts", - "./rss-style.xsl.ts": "./src/default-routes/rss-style.xsl.ts", - "./open-graph/index.png.ts": "./src/default-routes/open-graph/index.png.ts", - "./open-graph/authors.png.ts": "./src/default-routes/open-graph/authors.png.ts", - "./open-graph/tags.png.ts": "./src/default-routes/open-graph/tags.png.ts", - "./open-graph/[slug].png.ts": "./src/default-routes/open-graph/[slug].png.ts", - "./open-graph/author/[slug].png.ts": "./src/default-routes/open-graph/author/[slug].png.ts", - "./open-graph/tag/[slug].png.ts": "./src/default-routes/open-graph/tag/[slug].png.ts" - }, - "scripts": { - "test": "vitest run", - "test:watch": "vitest", - "test:coverage": "vitest run --coverage", - "test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'" - }, - "devDependencies": { - "@astrojs/check": "^0.5.4", - "@ts-ghost/core-api": "*", - "@ts-ghost/tsconfig": "*", - "@matthiesenxyz/astro-ghostcms-theme-default": "*", - "@matthiesenxyz/astro-ghostcms-catppuccin": "*", - "@types/fs-extra": "^11.0.1", - "@types/node": "^20.11.19", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-astro": "^0.31.4", - "prettier": "^3.2.5", - "prettier-plugin-astro": "^0.13.0", - "typescript": "^5.3.3", - "vitest": "^1.3.0", - "vitest-fetch-mock": "^0.2.2" - }, - "dependencies": { - "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.13", - "@astrojs/rss": "^4.0.5", - "@astrojs/sitemap": "^3.0.5", - "@resvg/resvg-js": "^2.6.0", - "@ts-ghost/core-api": "^5.1.2", - "astro": "^4.4.0", - "astro-robots-txt": "^1.0.0", - "fs-extra": "^11.1.0", - "package-json": "9.0.0", - "satori": "^0.10.11", - "satori-html": "^0.3.2", - "vite": "^5.1.3", - "vite-tsconfig-paths": "^4.2.2", - "zod": "^3.22.4" + "keywords": [ + "astro-component", + "astro-integration", + "withastro", + "astro", + "blog", + "content", + "integration", + "ghost", + "ghostcms", + "ghostcms-theme", + "ghost-theme", + "astro-theme" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/MatthiesenXYZ/astro-ghostcms.git" + }, + "bugs": { + "url": "https://github.com/MatthiesenXYZ/astro-ghostcms/issues", + "email": "issues@astro-ghostcms.xyz" + }, + "files": [ + "src", + "index.ts" + ], + "exports": { + ".": "./src/index.ts", + "./api": "./src/api/index.ts", + "./404.astro": "./src/routes/404.astro", + "./rss-routes/*": "./src/integrations/rssfeed/routes/*", + "./satoriOG": "./src/integrations/satoriog/satori.ts", + "./open-graph/*": "./src/integrations/satoriog/routes/*" + }, + "scripts": { + }, + "peerDependencies": { + "astro": "^4.4.1" + }, + "devDependencies": { + }, + "dependencies": { + "@astrojs/rss": "^4.0.5", + "@astrojs/sitemap": "^3.0.5", + "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.13", + "@resvg/resvg-js": "^2.6.0", + "@ts-ghost/core-api": "^6.0.0", + "@ts-ghost/content-api": "^4.0.12", + "astro-integration-kit": "^0.5.0", + "astro-robots-txt": "^1.0.0", + "picocolors": "1.0.0", + "satori": "^0.10.13", + "satori-html": "0.3.2", + "vite": "^5.1.4" + } } -} + \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/content-api.test.ts b/packages/astro-ghostcms/src/api/content-api/content-api.test.ts deleted file mode 100644 index e47ec835..00000000 --- a/packages/astro-ghostcms/src/api/content-api/content-api.test.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { assert, beforeEach, describe, expect, test } from "vitest"; - -import TS_API from "./content-api"; - -describe("content-api", () => { - let api: TS_API; - beforeEach(() => { - api = new TS_API("https://ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); - }); - - test("content-api", () => { - expect(api).toBeDefined(); - }); - - test("content-api shouldn't instantiate with an incorrect url", () => { - assert.throws(() => { - const api = new TS_API("ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); - api.settings; - }); - }); - - test("content-api shouldn't instantiate with an incorrect key", () => { - assert.throws(() => { - const api = new TS_API("https://ghost.org", "a", "v5.0"); - api.settings; - }); - }); - - test("content-api shouldn't instantiate with an incorrect version", () => { - assert.throws(() => { - const api = new TS_API( - "https://ghost.org", - "1efedd9db174adee2d23d982:4b74dca0219bad629852191af326a45037346c2231240e0f7aec1f9371cc14e8", - // @ts-expect-error - "v4.0", - ); - api.settings; - }); - }); - - test("content-api.posts", () => { - expect(api.posts).toBeDefined(); - expect(api.posts.browse).toBeDefined(); - expect(api.posts.read).toBeDefined(); - }); - - test("content-api.pages", () => { - expect(api.pages).toBeDefined(); - expect(api.pages.browse).toBeDefined(); - expect(api.pages.read).toBeDefined(); - }); - - test("content-api.tags", () => { - expect(api.tags).toBeDefined(); - expect(api.tags.browse).toBeDefined(); - expect(api.tags.read).toBeDefined(); - }); - - test("content-api.tiers", () => { - expect(api.tiers).toBeDefined(); - expect(api.tiers.browse).toBeDefined(); - expect(api.tiers.read).toBeDefined(); - }); - - test("content-api.authors", () => { - expect(api.authors).toBeDefined(); - expect(api.authors.browse).toBeDefined(); - expect(api.authors.read).toBeDefined(); - // @ts-expect-error - expect(api.authors.add).toBeUndefined(); - // @ts-expect-error - expect(api.authors.edit).toBeUndefined(); - expect(api.authors).toBeDefined(); - }); - - test("content-api.settings", () => { - expect(api.settings).toBeDefined(); - expect(api.settings.fetch).toBeDefined(); - // @ts-expect-error - expect(api.settings.read).toBeUndefined(); - // @ts-expect-error - expect(api.settings.browse).toBeUndefined(); - }); -}); diff --git a/packages/astro-ghostcms/src/api/content-api/content-api.ts b/packages/astro-ghostcms/src/api/content-api/content-api.ts deleted file mode 100644 index 6035e96a..00000000 --- a/packages/astro-ghostcms/src/api/content-api/content-api.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { - APIComposer, - BasicFetcher, - HTTPClient, - contentAPICredentialsSchema, - slugOrIdSchema, -} from "@ts-ghost/core-api"; - -import { - authorsIncludeSchema, - authorsSchema, - pagesIncludeSchema, - pagesSchema, - postsIncludeSchema, - postsSchema, - settingsSchema, - tagsIncludeSchema, - tagsSchema, - tiersIncludeSchema, - tiersSchema, -} from "./schemas"; - -export type { ContentAPICredentials, APIVersions } from "@ts-ghost/core-api"; - -export enum BrowseEndpointType { - authors = "authors", - tiers = "tiers", - posts = "posts", - pages = "pages", - tags = "tags", - settings = "settings", -} - -export default class TS_API { - private httpClient: HTTPClient; - - constructor( - protected readonly url: string, - protected readonly key: string, - protected readonly version: Version, - ) { - const apiCredentials = contentAPICredentialsSchema.parse({ - key, - version, - url, - }); - this.httpClient = new HTTPClient({ - ...apiCredentials, - endpoint: "content", - }); - } - - get authors() { - return new APIComposer( - "authors", - { - schema: authorsSchema, - identitySchema: slugOrIdSchema, - include: authorsIncludeSchema, - }, - this.httpClient, - ).access(["read", "browse"]); - } - get tiers() { - return new APIComposer( - "tiers", - { - schema: tiersSchema, - identitySchema: slugOrIdSchema, - include: tiersIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get posts() { - return new APIComposer( - "posts", - { - schema: postsSchema, - identitySchema: slugOrIdSchema, - include: postsIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get pages() { - return new APIComposer( - "pages", - { - schema: pagesSchema, - identitySchema: slugOrIdSchema, - include: pagesIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get tags() { - return new APIComposer( - "tags", - { - schema: tagsSchema, - identitySchema: slugOrIdSchema, - include: tagsIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - - get settings() { - return new BasicFetcher( - "settings", - { output: settingsSchema }, - this.httpClient, - ); - } -} diff --git a/packages/astro-ghostcms/src/api/content-api/index.ts b/packages/astro-ghostcms/src/api/content-api/index.ts deleted file mode 100644 index fb09f087..00000000 --- a/packages/astro-ghostcms/src/api/content-api/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { default as TS_API } from "./content-api"; -export * from "./schemas"; - -export type { - InferFetcherDataShape, - InferResponseDataShape, - BrowseParams, -} from "@ts-ghost/core-api"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.test.ts b/packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.test.ts deleted file mode 100644 index 1d24851f..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.test.ts +++ /dev/null @@ -1,164 +0,0 @@ -import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; -import createFetchMock from "vitest-fetch-mock"; - -import TS_API from "../../content-api"; - -const fetchMocker = createFetchMock(vi); - -describe("authors api .browse() Args Type-safety", () => { - const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; - const key = - process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; - const api = new TS_API(url, key, "v5.0"); - test(".browse() params shouldnt accept invalid params", () => { - // @ts-expect-error - shouldnt accept invalid params - const browse = api.authors.browse({ pp: 2 }); - expect(browse.getParams().browseParams).toStrictEqual({}); - }); - - test(".browse() 'order' params should ony accept fields values", () => { - // @ts-expect-error - order should ony contain field - expect(() => api.authors.browse({ order: "foo ASC" })).toThrow(); - // valid - expect( - api.authors.browse({ order: "name ASC" }).getParams().browseParams, - ).toStrictEqual({ - order: "name ASC", - }); - expect( - api.authors.browse({ order: "name ASC,slug DESC" }).getParams() - .browseParams, - ).toStrictEqual({ - order: "name ASC,slug DESC", - }); - expect( - api.authors - .browse({ order: "name ASC,slug DESC,location ASC" }) - .getParams().browseParams, - ).toStrictEqual({ - order: "name ASC,slug DESC,location ASC", - }); - // @ts-expect-error - order should ony contain field (There is a typo in location) - expect(() => - api.authors.browse({ order: "name ASC,slug DESC,locaton ASC" }), - ).toThrow(); - }); - - test(".browse() 'filter' params should ony accept valid field", () => { - expect(() => - api.authors.browse({ - // @ts-expect-error - order should ony contain field - filter: "foo:bar", - }), - ).toThrow(); - expect( - api.authors - .browse({ - filter: "name:bar", - }) - .getParams().browseParams, - ).toStrictEqual({ - filter: "name:bar", - }); - expect( - api.authors - .browse({ - filter: "name:bar+slug:-test", - }) - .getParams().browseParams, - ).toStrictEqual({ - filter: "name:bar+slug:-test", - }); - }); - - test(".browse 'fields' argument should ony accept valid fields", () => { - expect( - api.authors - .browse() - .fields({ - // @ts-expect-error - order should ony contain field - foo: true, - }) - .getOutputFields(), - ).toEqual([]); - - expect( - api.authors.browse().fields({ location: true }).getOutputFields(), - ).toEqual(["location"]); - expect( - api.authors - .browse() - .fields({ name: true, website: true }) - .getOutputFields(), - ).toEqual(["name", "website"]); - }); -}); - -describe("authors resource mocked", () => { - let api: TS_API; - - beforeEach(() => { - api = new TS_API( - "https://my-ghost-blog.com", - "59d4bf56c73c04a18c867dc3ba", - "v5.0", - ); - fetchMocker.enableMocks(); - }); - afterEach(() => { - vi.restoreAllMocks(); - }); - - test("aouthors should be fetched correctly", async () => { - const authors = api.authors; - expect(authors).not.toBeUndefined(); - const browseQuery = authors - .browse({ - page: 2, - }) - .fields({ - name: true, - id: true, - }); - expect(browseQuery).not.toBeUndefined(); - expect(browseQuery.getOutputFields()).toStrictEqual(["name", "id"]); - - fetchMocker.doMockOnce( - JSON.stringify({ - authors: [ - { - name: "foo", - id: "eaoizdjoa1321123", - }, - ], - meta: { - pagination: { - page: 1, - limit: 15, - pages: 1, - total: 1, - next: null, - prev: null, - }, - }, - }), - ); - const result = await browseQuery.fetch(); - expect(fetchMocker).toHaveBeenCalledTimes(1); - expect(fetchMocker).toHaveBeenCalledWith( - "https://my-ghost-blog.com/ghost/api/content/authors/?page=2&fields=name%2Cid&key=59d4bf56c73c04a18c867dc3ba", - { - headers: { - "Content-Type": "application/json", - "Accept-Version": "v5.0", - }, - }, - ); - expect(result).not.toBeUndefined(); - if (result.success) { - expect(result.data.length).toBe(1); - expect(result.data[0].name).toBe("foo"); - expect(result.data[0].id).toBe("eaoizdjoa1321123"); - } - }); -}); diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/authors/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/authors/index.ts deleted file mode 100644 index f9adb07f..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/authors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./authors"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/helpers/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/helpers/index.ts deleted file mode 100644 index f4fb9f52..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/helpers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./socials"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/pages/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/pages/index.ts deleted file mode 100644 index c4e34b27..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/pages/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./pages"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/posts/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/posts/index.ts deleted file mode 100644 index 4f89127a..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/posts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./posts"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.test.ts b/packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.test.ts deleted file mode 100644 index b2dfbbe3..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { describe, expect, test } from "vitest"; - -import TS_API from "../../content-api"; -import type { Post } from "./posts"; - -const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; -const key = - process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; - -describe("posts api .browse() Args Type-safety", () => { - const api = new TS_API(url, key, "v5.0"); - test(".browse() params shouldnt accept invalid params", () => { - // @ts-expect-error - shouldnt accept invalid params - const browse = api.posts.browse({ pp: 2 }); - expect(browse.getParams().browseParams).toStrictEqual({}); - - const outputFields = { - slug: true, - title: true, - // @ts-expect-error - shouldnt accept invalid params - foo: true, - } satisfies { [k in keyof Post]?: true | undefined }; - - // biome-ignore lint/style/useConst: - let test = api.posts - .browse() - // @ts-expect-error - shouldnt accept invalid params - .fields(outputFields); - expect(test.getOutputFields()).toEqual(["slug", "title"]); - - const fields = ["slug", "title", "foo"] as const; - const unknownOriginFields = fields.reduce( - (acc, k) => { - acc[k as keyof Post] = true; - return acc; - }, - {} as { [k in keyof Post]?: true | undefined }, - ); - const result = api.posts.browse().fields(unknownOriginFields); - expect(result.getOutputFields()).toEqual(["slug", "title"]); - }); - test(".browse() params, output fields declare const", () => { - const outputFields = { - slug: true, - title: true, - } satisfies { [k in keyof Post]?: true | undefined }; - - // biome-ignore lint/style/useConst: - let test = api.posts.browse().fields(outputFields); - expect(test.getOutputFields()).toEqual(["slug", "title"]); - - // @ts-expect-error - shouldnt accept invalid params - expect(() => api.posts.browse({ filter: "slugg:test" })).toThrow(); - // @ts-expect-error - shouldnt accept invalid params - expect(() => - api.posts.browse({ filter: "slug:test,foo:-[bar,baz]" }), - ).toThrow(); - expect( - api.posts.browse({ filter: "slug:test,tags:-[bar,baz]" }), - ).toBeDefined(); - expect( - api.posts.browse({ filter: "slug:test,tags:[bar,baz]" }), - ).toBeDefined(); - // @ts-expect-error - shouldnt accept invalid params - expect(() => - api.posts.browse({ filter: "slug:test,food:-[bar,baz]" }), - ).toThrow(); - }); -}); diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/settings/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/settings/index.ts deleted file mode 100644 index dcf101b0..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/settings/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./settings"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/tags/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/tags/index.ts deleted file mode 100644 index 006f4bf5..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/tags/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./tags"; diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/tiers/index.ts b/packages/astro-ghostcms/src/api/content-api/schemas/tiers/index.ts deleted file mode 100644 index aec8c265..00000000 --- a/packages/astro-ghostcms/src/api/content-api/schemas/tiers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./tiers"; diff --git a/packages/astro-ghostcms/src/api/api-functions.ts b/packages/astro-ghostcms/src/api/ghostAPI.ts similarity index 90% rename from packages/astro-ghostcms/src/api/api-functions.ts rename to packages/astro-ghostcms/src/api/ghostAPI.ts index dde659e8..0d031775 100644 --- a/packages/astro-ghostcms/src/api/api-functions.ts +++ b/packages/astro-ghostcms/src/api/ghostAPI.ts @@ -1,10 +1,10 @@ -import { TS_API } from "./content-api"; -import type { Page, Post } from "./content-api/schemas"; +import { TSGhostContentAPI } from "@ts-ghost/content-api"; +import type { Page, Post } from "../schemas/api"; // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; -import config from "../integrations/virtual-config"; +import config from "virtual:@matthiesenxyz/astro-ghostcms/config"; const CONF_URL = config.ghostURL; @@ -17,7 +17,7 @@ const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( const ghostApiKey = CONTENT_API_KEY; const ghostUrl = CONF_URL ? CONF_URL : CONTENT_API_URL; const version = "v5.0"; -const api = new TS_API(ghostUrl, ghostApiKey, version); +const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version); export const getAllAuthors = async () => { const results = await api.authors @@ -121,4 +121,4 @@ export const getFeaturedPosts = async () => { posts: results.data, meta: results.meta, }; -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/index.ts b/packages/astro-ghostcms/src/api/index.ts index 91557560..808a2451 100644 --- a/packages/astro-ghostcms/src/api/index.ts +++ b/packages/astro-ghostcms/src/api/index.ts @@ -1,3 +1,2 @@ -export * from "./api-functions"; -export * from "./content-api/schemas"; -export * from "./invariant"; +export * from "./ghostAPI"; +export * from "./invariant"; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/invariant.test.ts b/packages/astro-ghostcms/src/api/invariant.test.ts deleted file mode 100644 index 20c887b9..00000000 --- a/packages/astro-ghostcms/src/api/invariant.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { describe, expect, it } from "vitest"; - -// Modified version of invariant script to allow tests -const isProduction = false; -const prefix: string = "Invariant failed"; -function invariant(condition: any, message?: string | (() => string)) { - if (condition) { - return; - } - if (isProduction) { - throw new Error(prefix); - } - const provided: string | undefined = - typeof message === "function" ? message() : message; - const value: string = provided ? `${prefix}: ${provided}` : prefix; - return value; -} - -// TEST SECTION -const testTrue = true; -const testFalse = false; -describe("test invariant", () => { - it("Test `true` value", () => { - invariant(testTrue, "This should not error"); - expect(null); - }); - - it("Test `false` value", () => { - invariant(testFalse, "This should Error"); - expect(String("Invariant failed")); - }); -}); diff --git a/packages/astro-ghostcms/src/api/invariant.ts b/packages/astro-ghostcms/src/api/invariant.ts index 787f7935..d17d926a 100644 --- a/packages/astro-ghostcms/src/api/invariant.ts +++ b/packages/astro-ghostcms/src/api/invariant.ts @@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const tinyinvariant = "merged"; const isProduction: boolean = process.env.NODE_ENV === "production"; const prefix: string = "Invariant failed"; @@ -45,4 +44,4 @@ export function invariant( const value: string = provided ? `${prefix}: ${provided}` : prefix; throw new Error(value); -} +} \ No newline at end of file diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts new file mode 100644 index 00000000..68a809b1 --- /dev/null +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -0,0 +1,170 @@ +import { createResolver, defineIntegration } from "astro-integration-kit"; +import { corePlugins } from "astro-integration-kit/plugins"; +import { GhostUserConfigSchema } from "./schemas/userconfig"; +import { loadEnv } from "vite"; +import { AstroError } from "astro/errors"; +import c from "picocolors"; + +// Import External Integrations +import sitemap from "@astrojs/sitemap"; +import robotsTxt from "astro-robots-txt"; + +// Import Internal Integrations +import ghostOGImages from "./integrations/satoriog" +import ghostRSS from "./integrations/rssfeed" +import ghostThemeProvider from "./integrations/themeprovider" + +// Load environment variables +const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); + +/** Astro-GhostCMS Integration + * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project + * @see https://astro-ghostcms.xyz for the most up-to-date documentation! +*/ +export default defineIntegration({ + name: "@matthiesenxyz/astro-ghostcms", + optionsSchema: GhostUserConfigSchema, + plugins: [...corePlugins], + setup({ options, name }) { + const { resolve } = createResolver(import.meta.url); + + return { + "astro:config:setup": ({ + watchIntegration, + hasIntegration, + addIntegration, + addVirtualImports, + addDts, + injectRoute, + logger + }) => { + const GhostLogger = logger.fork(c.bold(c.blue('👻 Astro-GhostCMS'))); + const GhostENVLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('ENV Check')}`); + const GhostIntegrationLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Integrations')}`); + const GhostRouteLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Router')}`); + + watchIntegration(resolve()) + GhostLogger.info('Initializing @matthiesenxyz/astro-ghostcms...') + + const verbose = options.fullConsoleLogs; + + // Check for GhostCMS environment variables + GhostENVLogger.info(c.bold(c.yellow('Checking for GhostCMS environment variables & user configuration'))) + if (ENV.CONTENT_API_KEY === undefined) { + GhostENVLogger.error(c.bgRed(c.bold(c.white('CONTENT_API_KEY is not set in environment variables')))) + throw new AstroError(`${name} CONTENT_API_KEY is not set in environment variables`) + } + + if (options.ghostURL === undefined) { + GhostENVLogger.warn(c.bgYellow(c.bold(c.black('ghostURL is not set in user configuration falling back to environment variable')))) + if (ENV.CONTENT_API_URL === undefined) { + GhostENVLogger.error(c.bgRed(c.bold(c.white('CONTENT_API_URL is not set in environment variables')))) + throw new AstroError(`${name} CONTENT_API_URL is not set in environment variables`) + } + } + GhostENVLogger.info(c.bold(c.green('GhostCMS environment variables are set'))) + + // Set up Astro-GhostCMS Integrations + GhostIntegrationLogger.info(c.bold(c.magenta('Configuring Enabled Integrations'))) + + // Theme Provider + if ( !options.disableThemeProvider ) { + addIntegration( + ghostThemeProvider({ + theme: options.ThemeProvider.theme, + verbose + }) + ) + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray('Theme Provider is disabled')) + } + } + + // Satori OG Images + if ( options.enableOGImages ) { + addIntegration(ghostOGImages({ verbose })) + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray('OG Image Provider is disabled')) + } + } + + // RSS Feed + if ( options.enableRSSFeed ) { + addIntegration(ghostRSS({ verbose })) + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray('RSS Feed is disabled')) + } + } + + // @ASTROJS/SITEMAP + if ( !hasIntegration("@astrojs/sitemap") ) { + if (verbose) { + GhostIntegrationLogger.info(c.bold(c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`))) + } + addIntegration(sitemap()) + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray('@astrojs/sitemap integration already exists, skipping...')) + } + } + // ASTRO-ROBOTS-TXT + if ( !hasIntegration("@astro-robots-txt") ) { + if (verbose) { + GhostIntegrationLogger.info(c.bold(c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`))) + } + addIntegration(robotsTxt()) + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray('astro-robots-txt integration already exists, skipping...')) + } + } + + // Set up default 404 page + if ( !options.disableDefault404 ) { + if (verbose) { + GhostRouteLogger.info(c.bold(c.cyan('Setting up default 404 page'))) + } + injectRoute({ + pattern: "/404", + entrypoint: `${name}/404.astro`, + prerender: true + }) + } else { + if (verbose) { + GhostRouteLogger.info(c.gray('Default 404 page is disabled, Skipping...')) + } + } + + // Add virtual imports for user configuration + addVirtualImports({ + 'virtual:@matthiesenxyz/astro-ghostcms/config': `export default ${JSON.stringify(options)}`, + }) + + // Add types for user configuration + addDts({ + name: "@matthiesenxyz/astro-ghostcms/config", + content: `declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { + const Config: import("../schemas/userconfig").GhostUserConfig; + export default Config; + }` + }) + + }, + "astro:config:done": ({ logger }) => { + const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.green('Config')}`); + GhostLogger.info(c.bold(c.green('Integration Setup & Configuration Complete'))) + }, + "astro:server:start": ({ logger }) => { + const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('DEV'))}`); + GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Deveopment mode'))) + }, + "astro:build:done": ({ logger }) => { + const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('BUILD'))}`); + GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Production mode'))) + } + } + } +}) \ No newline at end of file diff --git a/packages/astro-ghostcms/src/index.ts b/packages/astro-ghostcms/src/index.ts new file mode 100644 index 00000000..58acee04 --- /dev/null +++ b/packages/astro-ghostcms/src/index.ts @@ -0,0 +1,3 @@ +import astroghostcms from './astro-ghostcms.js'; + +export default astroghostcms; diff --git a/packages/astro-ghostcms/src/integrations/robots-txt.ts b/packages/astro-ghostcms/src/integrations/robots-txt.ts deleted file mode 100644 index 38cbe70c..00000000 --- a/packages/astro-ghostcms/src/integrations/robots-txt.ts +++ /dev/null @@ -1,28 +0,0 @@ -import robotsTxt, { type RobotsTxtOptions } from "astro-robots-txt"; -import type { UserConfig } from "../schemas"; - -export function getRobotsTxtConfig( - opts: UserConfig["robotstxt"], -): RobotsTxtOptions { - const robotsConfig: RobotsTxtOptions = {}; - if (opts?.host) { - robotsConfig.host = opts.host; - } - if (opts?.policy) { - robotsConfig.policy = opts.policy; - } - if (opts?.sitemap) { - robotsConfig.sitemap = opts.sitemap; - } - if (opts?.sitemapBaseFileName) { - robotsConfig.sitemapBaseFileName = opts.sitemapBaseFileName; - } - return robotsConfig; -} - -/** - * A wrapped version of the `astro-robots-txt` integration for GhostCMS. - */ -export default function ghostRobots(opts: UserConfig["robotstxt"]) { - return robotsTxt(getRobotsTxtConfig(opts)); -} diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts new file mode 100644 index 00000000..d64cd556 --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -0,0 +1,48 @@ +import { createResolver, defineIntegration } from "astro-integration-kit"; +import { corePlugins } from "astro-integration-kit/plugins"; +import c from "picocolors"; +import { z } from "astro/zod"; + +export default defineIntegration({ + name: "@matthiesenxyz/astro-ghostcms-rss", + optionsSchema: z.object({ + verbose: z.boolean().optional().default(false), + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); + + return { + "astro:config:setup": ({ + watchIntegration, + injectRoute, + logger + }) => { + watchIntegration(resolve()) + const RSSLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('RSSGenerator')}`); + + RSSLogger.info(c.bold(c.magenta('RSS Feed Enabled. Setting up...'))) + + const rssRoute = "@matthiesenxyz/astro-ghostcms/rss-routes" + + injectRoute({ + pattern: "/rss-style.xsl", + entrypoint: `${rssRoute}/rss-style.xsl.ts`, + }); + + injectRoute({ + pattern: "/rss.xml", + entrypoint: `${rssRoute}/rss.xml.ts`, + }); + + }, + "astro:config:done": ({ logger }) => { + const RSSLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('RSSGenerator')}`); + + if (options.verbose) { + RSSLogger.info(c.bold(c.green('RSS Feed Setup Complete'))) + } + } + } + } +}) \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/index.ts b/packages/astro-ghostcms/src/integrations/rssfeed/index.ts new file mode 100644 index 00000000..34ef34e7 --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/rssfeed/index.ts @@ -0,0 +1,3 @@ +import astroGhostcmsRSS from "./astro-ghostcms-rss"; + +export default astroGhostcmsRSS; diff --git a/packages/astro-ghostcms/src/default-routes/rss-style.xsl.ts b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts similarity index 99% rename from packages/astro-ghostcms/src/default-routes/rss-style.xsl.ts rename to packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts index f5282760..61dd87ed 100644 --- a/packages/astro-ghostcms/src/default-routes/rss-style.xsl.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts @@ -78,4 +78,4 @@ export async function GET() { }, }, ); -} +} \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/rss.xml.ts b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts similarity index 90% rename from packages/astro-ghostcms/src/default-routes/rss.xml.ts rename to packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts index 3ca72a34..81c7df11 100644 --- a/packages/astro-ghostcms/src/default-routes/rss.xml.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts @@ -1,6 +1,6 @@ import rss from "@astrojs/rss"; import type { APIContext } from "astro"; -import { getAllPosts, getSettings, invariant } from "../api"; +import { getAllPosts, getSettings, invariant } from "../../../api"; const posts = await getAllPosts(); const settings = await getSettings(); @@ -24,4 +24,4 @@ export async function GET({ site }: APIContext) { author: post.primary_author?.name, })), }); -} +} \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts new file mode 100644 index 00000000..ded0418e --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -0,0 +1,73 @@ +import { createResolver, defineIntegration } from "astro-integration-kit"; +import { corePlugins } from "astro-integration-kit/plugins"; +import c from "picocolors"; +import { z } from "astro/zod"; + +export default defineIntegration({ + name: "@matthiesenxyz/astro-ghostcms-satoriog", + optionsSchema: z.object({ + verbose: z.boolean().optional().default(false), + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); + + return { + "astro:config:setup": ({ + watchIntegration, + updateConfig, + injectRoute, + logger + }) => { + watchIntegration(resolve()) + + const SatoriLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('SatoriOG')}`); + + SatoriLogger.info(c.bold(c.magenta('OG Image Integration Enabled. Setting up...'))) + + const pkgname = "@matthiesenxyz/astro-ghostcms/open-graph" + + injectRoute({ + pattern: "/open-graph/[slug].png", + entrypoint: `${pkgname}/[slug].png.ts`, + }); + + injectRoute({ + pattern: "/open-graph/index.png", + entrypoint: `${pkgname}/index.png.ts`, + }); + + injectRoute({ + pattern: "/open-graph/authors.png", + entrypoint: `${pkgname}/authors.png.ts`, + }); + + injectRoute({ + pattern: "/open-graph/author/[slug].png", + entrypoint: `${pkgname}/author/[slug].png.ts`, + }); + + injectRoute({ + pattern: "/open-graph/tags.png", + entrypoint: `${pkgname}/tags.png.ts`, + }); + + injectRoute({ + pattern: "/open-graph/tag/[slug].png", + entrypoint: `${pkgname}/tag/[slug].png.ts`, + }); + + updateConfig({ + vite: { optimizeDeps: { exclude: ["@resvg/resvg-js"] } } + }) + }, + "astro:config:done": ({ logger }) => { + const SatoriLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('SatoriOG')}`); + + if (options.verbose) { + SatoriLogger.info(c.bold(c.green('OG Image Integration Setup Complete'))) + } + } + } + } +}) \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/satoriog/index.ts b/packages/astro-ghostcms/src/integrations/satoriog/index.ts new file mode 100644 index 00000000..20a40a55 --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/satoriog/index.ts @@ -0,0 +1,3 @@ +import astroGhostcmsSatoriog from "./astro-ghostcms-satoriog"; + +export default astroGhostcmsSatoriog; diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/[slug].png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts index 3be6ca55..f0bf0d9f 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts @@ -10,8 +10,8 @@ import { getAllPosts, getSettings, invariant, -} from "../../api/index.js"; -import satoriOG from "../../integrations/satori.js"; +} from "../../../api"; +import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -67,4 +67,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/author/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/author/[slug].png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts index 95046eba..142b8f27 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/author/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts @@ -10,8 +10,8 @@ import { getAllPosts, getSettings, invariant, -} from "../../../api/index.js"; -import satoriOG from "../../../integrations/satori.js"; +} from "../../../../api"; +import satoriOG from "../../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -61,4 +61,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/authors.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/authors.png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts index 9003a7b7..3eb0d239 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/authors.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts @@ -10,8 +10,8 @@ import { getAllPosts, getSettings, invariant, -} from "../../api/index.js"; -import satoriOG from "../../integrations/satori.js"; +} from "../../../api"; +import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -65,4 +65,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/index.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/index.png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts index 4059cb6c..01dd5dc7 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/index.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts @@ -10,8 +10,8 @@ import { getAllPosts, getSettings, invariant, -} from "../../api/index.js"; -import satoriOG from "../../integrations/satori.js"; +} from "../../../api"; +import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -65,4 +65,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/tag/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/tag/[slug].png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts index f535f543..26176c25 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/tag/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts @@ -10,8 +10,8 @@ import { getAllTags, getSettings, invariant, -} from "../../../api/index.js"; -import satoriOG from "../../../integrations/satori.js"; +} from "../../../../api"; +import satoriOG from "../../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -68,4 +68,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/default-routes/open-graph/tags.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts similarity index 96% rename from packages/astro-ghostcms/src/default-routes/open-graph/tags.png.ts rename to packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts index d81e0d2e..6d562052 100644 --- a/packages/astro-ghostcms/src/default-routes/open-graph/tags.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts @@ -10,8 +10,8 @@ import { getAllPosts, getSettings, invariant, -} from "../../api/index.js"; -import satoriOG from "../../integrations/satori.js"; +} from "../../../api"; +import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; @@ -65,4 +65,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/satori.ts b/packages/astro-ghostcms/src/integrations/satoriog/satori.ts similarity index 98% rename from packages/astro-ghostcms/src/integrations/satori.ts rename to packages/astro-ghostcms/src/integrations/satoriog/satori.ts index 402eab9c..6b38a1a7 100644 --- a/packages/astro-ghostcms/src/integrations/satori.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/satori.ts @@ -5,7 +5,7 @@ import type { ToImageOptions, ToResponseOptions, ToSvgOptions, -} from "../../types.js"; +} from "./types"; const satoriOG = ({ width, height, template }: SatoriAstroOGOptions) => { return { @@ -52,4 +52,4 @@ export function getOgImagePath(inputFilename = "index"): string { filename = "index"; } return `./open-graph/${filename}.png`; -} +} \ No newline at end of file diff --git a/packages/astro-ghostcms/types.d.ts b/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts similarity index 63% rename from packages/astro-ghostcms/types.d.ts rename to packages/astro-ghostcms/src/integrations/satoriog/types.d.ts index b991c890..b4c24795 100644 --- a/packages/astro-ghostcms/types.d.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts @@ -1,24 +1,5 @@ import type { Resvg } from "@resvg/resvg-js"; import type satori from "satori"; - -export type { UserConfig, GhostUserConfig } from "./src/schemas"; - -export type { - Author, - AuthorsIncludeSchema, - Page, - PagesIncludeSchema, - Post, - PostsIncludeSchema, - Settings, - Tag, - TagsIncludeSchema, - Tier, - TiersIncludeSchema, -} from "./src/api/index.ts"; - -export type { ContentAPICredentials, APIVersions } from "@ts-ghost/core-api"; - type SatoriParameters = Parameters; type SatoriOptions = SatoriParameters[1]; type ResvgOptions = NonNullable[1]>; @@ -36,4 +17,4 @@ export type ToImageOptions = { | ResvgOptions | ((params: { width: number; height: number }) => ResvgOptions); }; -export type ToResponseOptions = ToImageOptions & { response?: ResponseInit }; +export type ToResponseOptions = ToImageOptions & { response?: ResponseInit }; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/sitemap.ts b/packages/astro-ghostcms/src/integrations/sitemap.ts deleted file mode 100644 index 0c174e54..00000000 --- a/packages/astro-ghostcms/src/integrations/sitemap.ts +++ /dev/null @@ -1,38 +0,0 @@ -import sitemap, { type SitemapOptions } from "@astrojs/sitemap"; -import type { UserConfig } from "../schemas"; - -export function getSitemapConfig(opts: UserConfig["sitemap"]): SitemapOptions { - const sitemapConfig: SitemapOptions = {}; - if (opts?.filter) { - sitemapConfig.filter = opts.filter; - } - if (opts?.changefreq) { - sitemapConfig.changefreq = opts.changefreq; - } - if (opts?.entryLimit) { - sitemapConfig.entryLimit = opts.entryLimit; - } - if (opts?.customPages) { - sitemapConfig.customPages = opts.customPages; - } - if (opts?.i18n) { - sitemapConfig.i18n = opts.i18n; - } - if (opts?.lastmod) { - sitemapConfig.lastmod = opts.lastmod; - } - if (opts?.priority) { - sitemapConfig.priority = opts.priority; - } - if (opts?.serialize) { - sitemapConfig.serialize = opts.serialize; - } - return sitemapConfig; -} - -/** - * A wrapped version of the `@astrojs/sitemap` integration for GhostCMS. - */ -export default function ghostSitemap(opts: UserConfig["sitemap"]) { - return sitemap(getSitemapConfig(opts)); -} diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts new file mode 100644 index 00000000..17cfc5a3 --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts @@ -0,0 +1,81 @@ +import { createResolver, defineIntegration } from "astro-integration-kit"; +import { corePlugins } from "astro-integration-kit/plugins"; +import { z } from "astro/zod"; +import c from "picocolors"; + +export default defineIntegration({ + name: "@matthiesenxyz/astro-ghostcms-themeprovider", + optionsSchema: z.object({ + theme: z.string().optional().default("@matthiesenxyz/astro-ghostcms-theme-default"), + verbose: z.boolean().optional().default(false), + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); + + return { + "astro:config:setup": ({ + watchIntegration, + injectRoute, + logger + }) => { + watchIntegration(resolve()) + + const themeLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Theme Provider')}`); + + themeLogger.info(c.bold(c.magenta('Theme Provider enabled. Setting up...'))) + + if ( options.verbose) { + if ( options.theme === "@matthiesenxyz/astro-ghostcms-theme-default" ) { + themeLogger.info(c.blue('No theme is set, injecting default theme')) + } else { + themeLogger.info(`${c.bold(c.cyan("Injecting Theme:"))} ${c.bold(c.underline(c.magenta(options.theme)))}`) + } + } + + injectRoute({ + pattern: "/", + entrypoint: `${options.theme}/index.astro`, + }); + + injectRoute({ + pattern: "/[slug]", + entrypoint: `${options.theme}/[slug].astro`, + }); + + injectRoute({ + pattern: "/tags", + entrypoint: `${options.theme}/tags.astro`, + }); + + injectRoute({ + pattern: "/authors", + entrypoint: `${options.theme}/authors.astro`, + }); + + injectRoute({ + pattern: "/tag/[slug]", + entrypoint: `${options.theme}/tag/[slug].astro`, + }); + + injectRoute({ + pattern: "/author/[slug]", + entrypoint: `${options.theme}/author/[slug].astro`, + }); + + injectRoute({ + pattern: "/archives/[...page]", + entrypoint: `${options.theme}/archives/[...page].astro`, + }); + + }, + "astro:config:done": ({ logger }) => { + const themeLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Theme Provider')}`); + + if ( options.verbose ) { + themeLogger.info(c.bold(c.green('Provider Setup Complete'))) + } + } + } + } +}) \ No newline at end of file diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/index.ts b/packages/astro-ghostcms/src/integrations/themeprovider/index.ts new file mode 100644 index 00000000..88e66a21 --- /dev/null +++ b/packages/astro-ghostcms/src/integrations/themeprovider/index.ts @@ -0,0 +1,3 @@ +import astroGhostcmsThemeProvider from "./astro-ghostcms-themeprovider"; + +export default astroGhostcmsThemeProvider; diff --git a/packages/astro-ghostcms/src/integrations/virtual-config.ts b/packages/astro-ghostcms/src/integrations/virtual-config.ts deleted file mode 100644 index e49f5f6e..00000000 --- a/packages/astro-ghostcms/src/integrations/virtual-config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { GhostUserConfig } from "../schemas"; -import config from "virtual:@matthiesenxyz/astro-ghostcms/config"; - -const UserConfig = config as GhostUserConfig; - -export default UserConfig; diff --git a/packages/astro-ghostcms/src/integrations/virtual.d.ts b/packages/astro-ghostcms/src/integrations/virtual.d.ts deleted file mode 100644 index 45a64ba9..00000000 --- a/packages/astro-ghostcms/src/integrations/virtual.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { - const Config: import("../schemas/index").GhostUserConfig; - export default Config; -} diff --git a/packages/astro-ghostcms/src/default-routes/404/404.astro b/packages/astro-ghostcms/src/routes/404.astro similarity index 88% rename from packages/astro-ghostcms/src/default-routes/404/404.astro rename to packages/astro-ghostcms/src/routes/404.astro index 8489240a..175a5093 100644 --- a/packages/astro-ghostcms/src/default-routes/404/404.astro +++ b/packages/astro-ghostcms/src/routes/404.astro @@ -1,6 +1,6 @@ --- import './404.css'; -import { getSettings, invariant } from '../../api'; +import { getSettings, invariant } from '../api'; const settings = await getSettings(); invariant(settings, "Settings not found"); diff --git a/packages/astro-ghostcms/src/default-routes/404/404.css b/packages/astro-ghostcms/src/routes/404.css similarity index 100% rename from packages/astro-ghostcms/src/default-routes/404/404.css rename to packages/astro-ghostcms/src/routes/404.css diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.ts b/packages/astro-ghostcms/src/schemas/api/authors.ts similarity index 95% rename from packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.ts rename to packages/astro-ghostcms/src/schemas/api/authors.ts index 5091b306..ea02b3dc 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/authors/authors.ts +++ b/packages/astro-ghostcms/src/schemas/api/authors.ts @@ -3,7 +3,7 @@ import { ghostMetaSchema, ghostMetadataSchema, } from "@ts-ghost/core-api"; -import { z } from "zod"; +import { z } from "astro/zod"; export const authorsSchema = z.object({ ...ghostIdentitySchema.shape, @@ -34,4 +34,4 @@ export const ghostFetchAuthorsSchema = z.object({ export const authorsIncludeSchema = z.object({ "count.posts": z.literal(true).optional(), }); -export type AuthorsIncludeSchema = z.infer; +export type AuthorsIncludeSchema = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/index.ts b/packages/astro-ghostcms/src/schemas/api/index.ts similarity index 71% rename from packages/astro-ghostcms/src/api/content-api/schemas/index.ts rename to packages/astro-ghostcms/src/schemas/api/index.ts index 88bfc1b9..09360d62 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/index.ts +++ b/packages/astro-ghostcms/src/schemas/api/index.ts @@ -1,7 +1,7 @@ export * from "./authors"; -export * from "./helpers"; export * from "./pages"; export * from "./posts"; export * from "./settings"; +export * from "./socials"; export * from "./tags"; -export * from "./tiers"; +export * from "./tiers"; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/pages/pages.ts b/packages/astro-ghostcms/src/schemas/api/pages.ts similarity index 92% rename from packages/astro-ghostcms/src/api/content-api/schemas/pages/pages.ts rename to packages/astro-ghostcms/src/schemas/api/pages.ts index cc4165e6..ac002aae 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/pages/pages.ts +++ b/packages/astro-ghostcms/src/schemas/api/pages.ts @@ -5,10 +5,10 @@ import { ghostSocialMediaSchema, ghostVisibilitySchema, } from "@ts-ghost/core-api"; -import { z } from "zod"; +import { z } from "astro/zod"; -import { authorsSchema } from "../authors"; -import { tagsSchema } from "../tags"; +import { authorsSchema } from "./authors"; +import { tagsSchema } from "./tags"; const postsAuthorSchema = authorsSchema.extend({ url: z.string().nullish(), @@ -52,4 +52,4 @@ export const pagesIncludeSchema = z.object({ authors: z.literal(true).optional(), tags: z.literal(true).optional(), }); -export type PagesIncludeSchema = z.infer; +export type PagesIncludeSchema = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.ts b/packages/astro-ghostcms/src/schemas/api/posts.ts similarity index 93% rename from packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.ts rename to packages/astro-ghostcms/src/schemas/api/posts.ts index dc0d982a..18b1aa5e 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/posts/posts.ts +++ b/packages/astro-ghostcms/src/schemas/api/posts.ts @@ -5,10 +5,10 @@ import { ghostSocialMediaSchema, ghostVisibilitySchema, } from "@ts-ghost/core-api"; -import { z } from "zod"; +import { z } from "astro/zod"; -import { authorsSchema } from "../authors"; -import { tagsSchema } from "../tags"; +import { authorsSchema } from "./authors"; +import { tagsSchema } from "./tags"; const postsAuthorSchema = authorsSchema.extend({ url: z.string().nullish(), @@ -51,4 +51,4 @@ export const postsIncludeSchema = z.object({ authors: z.literal(true).optional(), tags: z.literal(true).optional(), }); -export type PostsIncludeSchema = z.infer; +export type PostsIncludeSchema = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/settings/settings.ts b/packages/astro-ghostcms/src/schemas/api/settings.ts similarity index 91% rename from packages/astro-ghostcms/src/api/content-api/schemas/settings/settings.ts rename to packages/astro-ghostcms/src/schemas/api/settings.ts index 8f91873d..240aa74b 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/settings/settings.ts +++ b/packages/astro-ghostcms/src/schemas/api/settings.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import { z } from "astro/zod"; export const settingsSchema = z.object({ title: z.string(), @@ -37,4 +37,4 @@ export const settingsSchema = z.object({ url: z.string(), }); -export type Settings = z.infer; +export type Settings = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/helpers/socials.ts b/packages/astro-ghostcms/src/schemas/api/socials.ts similarity index 99% rename from packages/astro-ghostcms/src/api/content-api/schemas/helpers/socials.ts rename to packages/astro-ghostcms/src/schemas/api/socials.ts index 95dc9a9b..9d07e4a1 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/helpers/socials.ts +++ b/packages/astro-ghostcms/src/schemas/api/socials.ts @@ -29,4 +29,4 @@ export const twitter = (username: string) => { export const facebook = (username: string) => { // Handles a starting slash, this shouldn't happen, but just in case return `https://www.facebook.com/${username.replace(/^\//, "")}`; -}; +}; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/tags/tags.ts b/packages/astro-ghostcms/src/schemas/api/tags.ts similarity index 96% rename from packages/astro-ghostcms/src/api/content-api/schemas/tags/tags.ts rename to packages/astro-ghostcms/src/schemas/api/tags.ts index e1a1eb0f..ef805c49 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/tags/tags.ts +++ b/packages/astro-ghostcms/src/schemas/api/tags.ts @@ -5,7 +5,7 @@ import { ghostSocialMediaSchema, ghostVisibilitySchema, } from "@ts-ghost/core-api"; -import { z } from "zod"; +import { z } from "astro/zod"; export const tagsSchema = z.object({ ...ghostIdentitySchema.shape, @@ -31,4 +31,4 @@ export type Tag = z.infer; export const tagsIncludeSchema = z.object({ "count.posts": z.literal(true).optional(), }); -export type TagsIncludeSchema = z.infer; +export type TagsIncludeSchema = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/api/content-api/schemas/tiers/tiers.ts b/packages/astro-ghostcms/src/schemas/api/tiers.ts similarity index 96% rename from packages/astro-ghostcms/src/api/content-api/schemas/tiers/tiers.ts rename to packages/astro-ghostcms/src/schemas/api/tiers.ts index a8571b89..7c6e8ef3 100644 --- a/packages/astro-ghostcms/src/api/content-api/schemas/tiers/tiers.ts +++ b/packages/astro-ghostcms/src/schemas/api/tiers.ts @@ -1,5 +1,5 @@ import { ghostIdentitySchema, ghostVisibilitySchema } from "@ts-ghost/core-api"; -import { z } from "zod"; +import { z } from "astro/zod"; export const tiersSchema = z.object({ ...ghostIdentitySchema.shape, @@ -37,4 +37,4 @@ export const tiersIncludeSchema = z.object({ yearly_price: z.literal(true).optional(), benefits: z.literal(true).optional(), }); -export type TiersIncludeSchema = z.infer; +export type TiersIncludeSchema = z.infer; \ No newline at end of file diff --git a/packages/astro-ghostcms/src/schemas/index.ts b/packages/astro-ghostcms/src/schemas/index.ts deleted file mode 100644 index eb3d58e3..00000000 --- a/packages/astro-ghostcms/src/schemas/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./robots"; -export * from "./sitemap"; -export * from "./userconfig"; diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index b949e271..3b281af7 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -1,7 +1,8 @@ import { z } from "astro/zod"; -import { RobotsTxtSchema, SitemapSchema } from "./index"; +import { RobotsTxtSchema } from "./robots.ts"; +import { SitemapSchema } from "./sitemap.ts"; -export const UserConfigSchema = z.object({ +export const GhostUserConfigSchema = z.object({ /** OPTIONAL - Either set the URL in your .env or put it here * @example * // https://astro.build/config @@ -13,31 +14,24 @@ export const UserConfigSchema = z.object({ * ], * }); */ ghostURL: z.string().url().optional(), - /** OPTIONAL - Allows the user to disable the `/rss.xml` injection */ - disableRSS: z.boolean().default(false), - /** OPTIONAL - Allows the user to disable the `/open-graph/*` route injection - * @ This feature uses `satori` to generate OpenGraph Images + /** OPTIONAL - Disable the theme provider + * @default false */ - disableSatoriOG: z.boolean().default(false), - /** OPTIONAL - Allows the user to disable the `/404` injection */ - disable404: z.boolean().default(false), - /** OPTIONAL - Disable Route Injector - * This option allows the user to disable the route injection system and utilize just the integraions other functions. Such as API, sitemap and robotstxt integrations. */ - disableRouteInjection: z.boolean().default(false), - /** OPTIONAL - (Default: true) Allows the user to disable "info" console output */ - disableConsoleOutput: z.boolean().default(true), - /** OPTIONAL - Theme Selector - * This option allows the user to replace the included theme with an external npm module - * @example - * // https://astro.build/config - * export default defineConfig({ - * integrations: [ - * ghostcms({ - * theme: "@matthiesenxyz/astro-ghostcms-theme-default" - * }) - * ], - * }); */ - theme: z.string().default("@matthiesenxyz/astro-ghostcms-theme-default"), + disableThemeProvider: z.boolean().optional().default(false), + ThemeProvider: z.object({ + /** OPTIONAL - Set the theme you want to use + * @default "@matthiesenxyz/astro-ghostcms-theme-default" + */ + theme: z.string().optional().default("@matthiesenxyz/astro-ghostcms-theme-default"), + }).optional(), + /** Allows the user to disable the provided 404 page */ + disableDefault404: z.boolean().optional().default(false), + /** Allows the user to disable the provided RSS Feed */ + enableRSSFeed: z.boolean().optional().default(true), + /** Allows the user to Enable or Disable the default Satori OG Image Generation + * @default true + */ + enableOGImages: z.boolean().optional().default(true), /** OPTIONAL - astrojs/sitemap * This option allows the user to configure the included integration * Options shown are the availble options @@ -50,8 +44,11 @@ export const UserConfigSchema = z.object({ * REFERENCE https://www.npmjs.com/package/astro-robots-txt#configuration */ robotstxt: RobotsTxtSchema.optional(), + /** Allows the user to turn on/off Full Console Logs + * @default true + */ + fullConsoleLogs: z.boolean().optional().default(false), }); /** USER CONFIGURATION SCHEMA */ -export type UserConfig = z.infer; -export type GhostUserConfig = z.infer; +export type GhostUserConfig = z.infer; diff --git a/packages/astro-ghostcms/src/utils/add-virtual-import.test.ts b/packages/astro-ghostcms/src/utils/add-virtual-import.test.ts deleted file mode 100644 index 8e2374dd..00000000 --- a/packages/astro-ghostcms/src/utils/add-virtual-import.test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** MIT License - -Copyright (c) 2024 Florian Lefebvre - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ -import { type Mock, afterEach, describe, expect, test, vi } from "vitest"; -import { addVirtualImport } from "./add-virtual-import.js"; -import { addVitePlugin } from "./add-vite-plugin.js"; - -vi.mock("./add-vite-plugin"); - -const pluginNameStub = (name: T): `vite-plugin-${T}` => - `vite-plugin-${name}`; - -describe("add-virtual-import", () => { - const name = "test-module"; - const content = "export default {}"; - - afterEach(() => { - vi.clearAllMocks(); - }); - - test("It should call `addVitePlugin`", () => { - const updateConfig = vi.fn(); - - addVirtualImport({ - name, - content, - updateConfig, - }); - - expect(addVitePlugin).toHaveBeenCalled(); - }); - - test("`addVitePlugin` should get called with the correct plugin name", () => { - const updateConfig = vi.fn(); - - addVirtualImport({ - name, - content, - updateConfig, - }); - - const expectedName = pluginNameStub(name); - - const { plugin } = (addVitePlugin as Mock).mock.lastCall[0]; - - expect(plugin.name).toEqual(expectedName); - }); - - test("Virtual module should resolve correct name", () => { - const updateConfig = vi.fn(); - - addVirtualImport({ - name, - content, - updateConfig, - }); - - const { plugin } = (addVitePlugin as Mock).mock.lastCall[0]; - - const resolvedVirtualModuleId = plugin.resolveId(name); - - expect(resolvedVirtualModuleId).toEqual(`\0${name}`); - }); -}); diff --git a/packages/astro-ghostcms/src/utils/add-virtual-import.ts b/packages/astro-ghostcms/src/utils/add-virtual-import.ts deleted file mode 100644 index c655f947..00000000 --- a/packages/astro-ghostcms/src/utils/add-virtual-import.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** MIT License - -Copyright (c) 2024 Florian Lefebvre - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ -import type { HookParameters } from "astro"; -import type { Plugin } from "vite"; -import { addVitePlugin } from "./add-vite-plugin.js"; - -const resolveVirtualModuleId = (id: T): `\0${T}` => { - return `\0${id}`; -}; - -const createVirtualModule = (name: string, content: string): Plugin => { - const pluginName = `vite-plugin-${name}`; - - return { - name: pluginName, - resolveId(id) { - if (id === name) { - return resolveVirtualModuleId(id); - } - }, - load(id) { - if (id === resolveVirtualModuleId(name)) { - return content; - } - }, - }; -}; - -/** - * Creates a Vite virtual module and updates the Astro config. - * Virtual imports are useful for passing things like config options, or data computed within the integration. - * - * @param {object} params - * @param {string} params.name - * @param {string} params.content - * @param {import("astro").HookParameters<"astro:config:setup">["updateConfig"]} params.updateConfig - * - * @see https://astro-integration-kit.netlify.app/utilities/add-virtual-import/ - * - * @example - * ```ts - * // my-integration/index.ts - * import { addVirtualImport } from "astro-integration-kit"; - * - * addVirtualImport( - * name: 'virtual:my-integration/config', - * content: `export default ${ JSON.stringify({foo: "bar"}) }`, - * updateConfig - * ); - * ``` - * - * This is then readable anywhere else in your integration: - * - * ```ts - * // myIntegration/src/component/layout.astro - * import config from "virtual:my-integration/config"; - * - * console.log(config.foo) // "bar" - * ``` - */ -export const addVirtualImport = ({ - name, - content, - updateConfig, -}: { - name: string; - content: string; - updateConfig: HookParameters<"astro:config:setup">["updateConfig"]; -}) => { - addVitePlugin({ - plugin: createVirtualModule(name, content), - updateConfig, - }); -}; diff --git a/packages/astro-ghostcms/src/utils/add-vite-plugin.test.ts b/packages/astro-ghostcms/src/utils/add-vite-plugin.test.ts deleted file mode 100644 index 203f888a..00000000 --- a/packages/astro-ghostcms/src/utils/add-vite-plugin.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import type { Plugin } from "vite"; -import { describe, expect, test, vi } from "vitest"; -import { addVitePlugin } from "./add-vite-plugin.js"; - -describe("addVitePlugin", () => { - test("Should run", () => { - const updateConfig = vi.fn(); - - expect(() => - addVitePlugin({ - plugin: null, - updateConfig, - }), - ).not.toThrow(); - }); - - test("Should call updateConfig", () => { - const updateConfig = vi.fn(); - - addVitePlugin({ - plugin: null, - updateConfig, - }); - - expect(updateConfig).toHaveBeenCalled(); - }); - - test("Should add vite plugin", () => { - let plugin: Plugin; - const pluginName = "test-plugin"; - - const updateConfig = vi.fn((config) => { - plugin = config.vite.plugins[0]; - }); - - const expectedPlugin = { - name: pluginName, - }; - - addVitePlugin({ - plugin: expectedPlugin, - updateConfig, - }); - - // @ts-ignore - expect(plugin).toBeDefined(); - }); - - test("Plugin name should match", () => { - let plugin: Plugin; - const pluginName = "test-plugin"; - - const updateConfig = vi.fn((config) => { - plugin = config.vite.plugins[0]; - }); - - const expectedPlugin = { - name: pluginName, - }; - - addVitePlugin({ - plugin: expectedPlugin, - updateConfig, - }); - - // @ts-ignore - expect(plugin.name).toBe(pluginName); - }); -}); diff --git a/packages/astro-ghostcms/src/utils/add-vite-plugin.ts b/packages/astro-ghostcms/src/utils/add-vite-plugin.ts deleted file mode 100644 index 8d0279ba..00000000 --- a/packages/astro-ghostcms/src/utils/add-vite-plugin.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** MIT License - -Copyright (c) 2024 Florian Lefebvre - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ -import type { HookParameters } from "astro"; -import type { PluginOption } from "vite"; - -/** - * Adds a [vite plugin](https://vitejs.dev/guide/using-plugins) to the - * Astro config. - * - * @param {Params} params - * @param {import("vite").Plugin} params.plugin - * @param {import("astro").HookParameters<"astro:config:setup">["updateConfig"]} params.updateConfig - * - * @see https://astro-integration-kit.netlify.app/utilities/add-vite-plugin/ - * - * @example - * ```ts - * addVitePlugin({ - * plugin, - * updateConfig - * }) - * ``` - */ -export const addVitePlugin = ({ - plugin, - updateConfig, -}: { - plugin: PluginOption; - updateConfig: HookParameters<"astro:config:setup">["updateConfig"]; -}) => { - updateConfig({ - vite: { - plugins: [plugin], - }, - }); -}; diff --git a/packages/astro-ghostcms/src/utils/latestVersion.ts b/packages/astro-ghostcms/src/utils/latestVersion.ts deleted file mode 100644 index b41085af..00000000 --- a/packages/astro-ghostcms/src/utils/latestVersion.ts +++ /dev/null @@ -1,26 +0,0 @@ -import packageJson from "package-json"; - -export type Options = { - /** - A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag). - */ - readonly version?: string; -}; - -/** -Get the latest version of an npm package. - -@example -``` -console.log(await latestVersion('ava')); -//=> '0.18.0' -``` -*/ -export default async function latestVersion( - packageName: string, - options?: Options, -) { - const { version } = await packageJson(packageName.toLowerCase(), options); - - return version; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/ValidationError.js b/packages/astro-ghostcms/src/utils/zod-validation/ValidationError.js deleted file mode 100644 index ff3e97ce..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/ValidationError.js +++ /dev/null @@ -1,22 +0,0 @@ -import * as zod from "zod"; -export class ValidationError extends Error { - name; - details; - constructor(message, options) { - super(message, options); - this.name = "ZodValidationError"; - this.details = getIssuesFromErrorOptions(options); - } - toString() { - return this.message; - } -} -function getIssuesFromErrorOptions(options) { - if (options) { - const cause = options.cause; - if (cause instanceof zod.ZodError) { - return cause.issues; - } - } - return []; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/config.js b/packages/astro-ghostcms/src/utils/zod-validation/config.js deleted file mode 100644 index c3d9c30a..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/config.js +++ /dev/null @@ -1,5 +0,0 @@ -export const ISSUE_SEPARATOR = "; "; -export const MAX_ISSUES_IN_MESSAGE = 99; -export const PREFIX = "Validation error"; -export const PREFIX_SEPARATOR = ": "; -export const UNION_SEPARATOR = ", or "; diff --git a/packages/astro-ghostcms/src/utils/zod-validation/errorMap.js b/packages/astro-ghostcms/src/utils/zod-validation/errorMap.js deleted file mode 100644 index dae66709..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/errorMap.js +++ /dev/null @@ -1,10 +0,0 @@ -import { fromZodIssue } from "./fromZodIssue"; -export const errorMap = (issue, ctx) => { - const error = fromZodIssue({ - ...issue, - message: issue.message ?? ctx.defaultError, - }); - return { - message: error.message, - }; -}; diff --git a/packages/astro-ghostcms/src/utils/zod-validation/fromZodError.js b/packages/astro-ghostcms/src/utils/zod-validation/fromZodError.js deleted file mode 100644 index e5a0e383..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/fromZodError.js +++ /dev/null @@ -1,37 +0,0 @@ -import { ValidationError } from "./ValidationError"; -import { - ISSUE_SEPARATOR, - MAX_ISSUES_IN_MESSAGE, - PREFIX, - PREFIX_SEPARATOR, - UNION_SEPARATOR, -} from "./config"; -import { getMessageFromZodIssue } from "./fromZodIssue"; -import { prefixMessage } from "./prefixMessage"; -export function fromZodError(zodError, options = {}) { - const { - maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE, - issueSeparator = ISSUE_SEPARATOR, - unionSeparator = UNION_SEPARATOR, - prefixSeparator = PREFIX_SEPARATOR, - prefix = PREFIX, - includePath = true, - } = options; - const zodIssues = zodError.errors; - const reason = - zodIssues.length === 0 - ? zodError.message - : zodIssues - .slice(0, maxIssuesInMessage) - .map((issue) => - getMessageFromZodIssue({ - issue, - issueSeparator, - unionSeparator, - includePath, - }), - ) - .join(issueSeparator); - const message = prefixMessage(reason, prefix, prefixSeparator); - return new ValidationError(message, { cause: zodError }); -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/fromZodIssue.js b/packages/astro-ghostcms/src/utils/zod-validation/fromZodIssue.js deleted file mode 100644 index fa5dddc5..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/fromZodIssue.js +++ /dev/null @@ -1,61 +0,0 @@ -import * as zod from "zod"; -import { ValidationError } from "./ValidationError"; -import { - ISSUE_SEPARATOR, - PREFIX, - PREFIX_SEPARATOR, - UNION_SEPARATOR, -} from "./config"; -import { prefixMessage } from "./prefixMessage"; -import { isNonEmptyArray } from "./utils/NonEmptyArray"; -import { joinPath } from "./utils/joinPath"; -export function getMessageFromZodIssue(props) { - const { issue, issueSeparator, unionSeparator, includePath } = props; - if (issue.code === "invalid_union") { - return issue.unionErrors - .reduce((acc, zodError) => { - const newIssues = zodError.issues - .map((issue) => - getMessageFromZodIssue({ - issue, - issueSeparator, - unionSeparator, - includePath, - }), - ) - .join(issueSeparator); - if (!acc.includes(newIssues)) { - acc.push(newIssues); - } - return acc; - }, []) - .join(unionSeparator); - } - if (includePath && isNonEmptyArray(issue.path)) { - if (issue.path.length === 1) { - const identifier = issue.path[0]; - if (typeof identifier === "number") { - return `${issue.message} at index ${identifier}`; - } - } - return `${issue.message} at "${joinPath(issue.path)}"`; - } - return issue.message; -} -export function fromZodIssue(issue, options = {}) { - const { - issueSeparator = ISSUE_SEPARATOR, - unionSeparator = UNION_SEPARATOR, - prefixSeparator = PREFIX_SEPARATOR, - prefix = PREFIX, - includePath = true, - } = options; - const reason = getMessageFromZodIssue({ - issue, - issueSeparator, - unionSeparator, - includePath, - }); - const message = prefixMessage(reason, prefix, prefixSeparator); - return new ValidationError(message, { cause: new zod.ZodError([issue]) }); -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/index.js b/packages/astro-ghostcms/src/utils/zod-validation/index.js deleted file mode 100644 index 3c273d4a..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/index.js +++ /dev/null @@ -1,7 +0,0 @@ -export { ValidationError } from "./ValidationError"; -export { isValidationError } from "./isValidationError"; -export { isValidationErrorLike } from "./isValidationErrorLike"; -export { errorMap } from "./errorMap"; -export { fromZodIssue } from "./fromZodIssue"; -export { fromZodError } from "./fromZodError"; -export { toValidationError } from "./toValidationError"; diff --git a/packages/astro-ghostcms/src/utils/zod-validation/isValidationError.js b/packages/astro-ghostcms/src/utils/zod-validation/isValidationError.js deleted file mode 100644 index 4df3123c..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/isValidationError.js +++ /dev/null @@ -1,4 +0,0 @@ -import { ValidationError } from "./ValidationError"; -export function isValidationError(err) { - return err instanceof ValidationError; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/isValidationErrorLike.js b/packages/astro-ghostcms/src/utils/zod-validation/isValidationErrorLike.js deleted file mode 100644 index 120a726b..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/isValidationErrorLike.js +++ /dev/null @@ -1,3 +0,0 @@ -export function isValidationErrorLike(err) { - return err instanceof Error && err.name === "ZodValidationError"; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/prefixMessage.js b/packages/astro-ghostcms/src/utils/zod-validation/prefixMessage.js deleted file mode 100644 index 3016dcba..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/prefixMessage.js +++ /dev/null @@ -1,13 +0,0 @@ -import { PREFIX } from "./config"; -export function prefixMessage(message, prefix, prefixSeparator) { - if (prefix !== null) { - if (message.length > 0) { - return [prefix, message].join(prefixSeparator); - } - return prefix; - } - if (message.length > 0) { - return message; - } - return PREFIX; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/toValidationError.js b/packages/astro-ghostcms/src/utils/zod-validation/toValidationError.js deleted file mode 100644 index ea7e74f6..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/toValidationError.js +++ /dev/null @@ -1,14 +0,0 @@ -import * as zod from "zod"; -import { ValidationError } from "./ValidationError"; -import { fromZodError } from "./fromZodError"; -export const toValidationError = - (options = {}) => - (err) => { - if (err instanceof zod.ZodError) { - return fromZodError(err, options); - } - if (err instanceof Error) { - return new ValidationError(err.message, { cause: err }); - } - return new ValidationError("Unknown error"); - }; diff --git a/packages/astro-ghostcms/src/utils/zod-validation/utils/NonEmptyArray.js b/packages/astro-ghostcms/src/utils/zod-validation/utils/NonEmptyArray.js deleted file mode 100644 index 9fd10456..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/utils/NonEmptyArray.js +++ /dev/null @@ -1,3 +0,0 @@ -export function isNonEmptyArray(value) { - return value.length !== 0; -} diff --git a/packages/astro-ghostcms/src/utils/zod-validation/utils/joinPath.js b/packages/astro-ghostcms/src/utils/zod-validation/utils/joinPath.js deleted file mode 100644 index 86cef5ef..00000000 --- a/packages/astro-ghostcms/src/utils/zod-validation/utils/joinPath.js +++ /dev/null @@ -1,22 +0,0 @@ -const identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u; -export function joinPath(path) { - if (path.length === 1) { - return path[0].toString(); - } - return path.reduce((acc, item) => { - if (typeof item === "number") { - return `${acc}[${item.toString()}]`; - } - if (item.includes('"')) { - return `${acc}["${escapeQuotes(item)}"]`; - } - if (!identifierRegex.test(item)) { - return `${acc}["${item}"]`; - } - const separator = acc.length === 0 ? "" : "."; - return acc + separator + item; - }, ""); -} -function escapeQuotes(str) { - return str.replace(/"/g, '\\"'); -} diff --git a/packages/astro-ghostcms/vitest.config.ts b/packages/astro-ghostcms/vitest.config.ts deleted file mode 100644 index deec7256..00000000 --- a/packages/astro-ghostcms/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// -/// - -import tsconfigPaths from "vite-tsconfig-paths"; -import { defineProject } from "vitest/config"; - -export default defineProject({ - plugins: [tsconfigPaths()], - test: { - globals: true, - include: ["./**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], - watchExclude: [".*\\/node_modules\\/.*", ".*\\/build\\/.*"], - exclude: ["node_modules", "dist", ".idea", ".git", ".cache"], - }, -}); diff --git a/playground/.env b/playground/.env deleted file mode 100644 index e1699c0e..00000000 --- a/playground/.env +++ /dev/null @@ -1,2 +0,0 @@ -CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48 -CONTENT_API_URL=https://ghostdemo.matthiesen.xyz \ No newline at end of file diff --git a/playground/src/env.d.ts b/playground/src/env.d.ts deleted file mode 100644 index f964fe0c..00000000 --- a/playground/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/playgrounds/astro-playground/.env b/playgrounds/astro-playground/.env new file mode 100644 index 00000000..8f084c23 --- /dev/null +++ b/playgrounds/astro-playground/.env @@ -0,0 +1 @@ +CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48 \ No newline at end of file diff --git a/playground/.gitignore b/playgrounds/astro-playground/.gitignore similarity index 100% rename from playground/.gitignore rename to playgrounds/astro-playground/.gitignore diff --git a/playground/.vscode/extensions.json b/playgrounds/astro-playground/.vscode/extensions.json similarity index 100% rename from playground/.vscode/extensions.json rename to playgrounds/astro-playground/.vscode/extensions.json diff --git a/playground/.vscode/launch.json b/playgrounds/astro-playground/.vscode/launch.json similarity index 100% rename from playground/.vscode/launch.json rename to playgrounds/astro-playground/.vscode/launch.json diff --git a/playground/CHANGELOG.md b/playgrounds/astro-playground/CHANGELOG.md similarity index 100% rename from playground/CHANGELOG.md rename to playgrounds/astro-playground/CHANGELOG.md diff --git a/playground/LICENSE b/playgrounds/astro-playground/LICENSE similarity index 100% rename from playground/LICENSE rename to playgrounds/astro-playground/LICENSE diff --git a/playground/README.md b/playgrounds/astro-playground/README.md similarity index 100% rename from playground/README.md rename to playgrounds/astro-playground/README.md diff --git a/playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs similarity index 71% rename from playground/astro.config.mjs rename to playgrounds/astro-playground/astro.config.mjs index 3dc022d3..934e3c7a 100644 --- a/playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -10,12 +10,10 @@ export default defineConfig({ //tailwind(), UnoCSS({ injectReset: true }), ghostcms({ - disable404: false, - disableRSS: false, - disableRouteInjection: false, - disableConsoleOutput: false, - theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", ghostURL: "https://ghostdemo.matthiesen.xyz", + ThemeProvider: { + theme: '@matthiesenxyz/astro-ghostcms-brutalbyelian', + }, }), ], }); diff --git a/playground/package.json b/playgrounds/astro-playground/package.json similarity index 79% rename from playground/package.json rename to playgrounds/astro-playground/package.json index e78563f4..533aece7 100644 --- a/playground/package.json +++ b/playgrounds/astro-playground/package.json @@ -1,5 +1,5 @@ { - "name": "playground", + "name": "astro-playground", "type": "module", "version": "0.0.2", "private": true, @@ -12,10 +12,8 @@ }, "dependencies": { "astro": "^4.4.0", - "@matthiesenxyz/astro-ghostcms-theme-default": "workspace:*", - "@matthiesenxyz/astro-ghostcms-catppuccin": "workspace:*", - "@matthiesenxyz/astro-ghostcms-brutalbyelian": "workspace:*", "@matthiesenxyz/astro-ghostcms": "workspace:*", + "@matthiesenxyz/astro-ghostcms-brutalbyelian": "workspace:*", "@astrojs/tailwind": "^5.1.0", "@unocss/astro": "^0.58.5", "tailwindcss": "^3.3.5" diff --git a/playground/public/favicon.svg b/playgrounds/astro-playground/public/favicon.svg similarity index 100% rename from playground/public/favicon.svg rename to playgrounds/astro-playground/public/favicon.svg diff --git a/playgrounds/astro-playground/src/env.d.ts b/playgrounds/astro-playground/src/env.d.ts new file mode 100644 index 00000000..e49580d9 --- /dev/null +++ b/playgrounds/astro-playground/src/env.d.ts @@ -0,0 +1,3 @@ +/// +/// +/// diff --git a/playground/tailwind.config.cjs b/playgrounds/astro-playground/tailwind.config.cjs similarity index 100% rename from playground/tailwind.config.cjs rename to playgrounds/astro-playground/tailwind.config.cjs diff --git a/playground/tsconfig.json b/playgrounds/astro-playground/tsconfig.json similarity index 100% rename from playground/tsconfig.json rename to playgrounds/astro-playground/tsconfig.json diff --git a/playground/uno.config.ts b/playgrounds/astro-playground/uno.config.ts similarity index 100% rename from playground/uno.config.ts rename to playgrounds/astro-playground/uno.config.ts diff --git a/starlight-playground/.gitignore b/playgrounds/starlight-playground/.gitignore similarity index 100% rename from starlight-playground/.gitignore rename to playgrounds/starlight-playground/.gitignore diff --git a/starlight-playground/.vscode/extensions.json b/playgrounds/starlight-playground/.vscode/extensions.json similarity index 100% rename from starlight-playground/.vscode/extensions.json rename to playgrounds/starlight-playground/.vscode/extensions.json diff --git a/starlight-playground/.vscode/launch.json b/playgrounds/starlight-playground/.vscode/launch.json similarity index 100% rename from starlight-playground/.vscode/launch.json rename to playgrounds/starlight-playground/.vscode/launch.json diff --git a/starlight-playground/astro.config.mjs b/playgrounds/starlight-playground/astro.config.mjs similarity index 100% rename from starlight-playground/astro.config.mjs rename to playgrounds/starlight-playground/astro.config.mjs diff --git a/starlight-playground/package.json b/playgrounds/starlight-playground/package.json similarity index 100% rename from starlight-playground/package.json rename to playgrounds/starlight-playground/package.json diff --git a/starlight-playground/public/favicon.svg b/playgrounds/starlight-playground/public/favicon.svg similarity index 100% rename from starlight-playground/public/favicon.svg rename to playgrounds/starlight-playground/public/favicon.svg diff --git a/starlight-playground/src/assets/houston.webp b/playgrounds/starlight-playground/src/assets/houston.webp similarity index 100% rename from starlight-playground/src/assets/houston.webp rename to playgrounds/starlight-playground/src/assets/houston.webp diff --git a/starlight-playground/src/content/config.ts b/playgrounds/starlight-playground/src/content/config.ts similarity index 100% rename from starlight-playground/src/content/config.ts rename to playgrounds/starlight-playground/src/content/config.ts diff --git a/starlight-playground/src/content/docs/guides/example.md b/playgrounds/starlight-playground/src/content/docs/guides/example.md similarity index 100% rename from starlight-playground/src/content/docs/guides/example.md rename to playgrounds/starlight-playground/src/content/docs/guides/example.md diff --git a/starlight-playground/src/content/docs/index.mdx b/playgrounds/starlight-playground/src/content/docs/index.mdx similarity index 100% rename from starlight-playground/src/content/docs/index.mdx rename to playgrounds/starlight-playground/src/content/docs/index.mdx diff --git a/starlight-playground/src/content/docs/reference/example.md b/playgrounds/starlight-playground/src/content/docs/reference/example.md similarity index 100% rename from starlight-playground/src/content/docs/reference/example.md rename to playgrounds/starlight-playground/src/content/docs/reference/example.md diff --git a/starlight-playground/src/env.d.ts b/playgrounds/starlight-playground/src/env.d.ts similarity index 100% rename from starlight-playground/src/env.d.ts rename to playgrounds/starlight-playground/src/env.d.ts diff --git a/starlight-playground/tsconfig.json b/playgrounds/starlight-playground/tsconfig.json similarity index 100% rename from starlight-playground/tsconfig.json rename to playgrounds/starlight-playground/tsconfig.json diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d3f2040..4965dfb2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,7 +19,7 @@ importers: version: 1.3.0(vitest@1.3.0) vitest: specifier: ^1.3.0 - version: 1.3.0(@vitest/ui@1.3.0) + version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) vitest-fetch-mock: specifier: ^0.2.2 version: 0.2.2(vitest@1.3.0) @@ -38,82 +38,33 @@ importers: '@resvg/resvg-js': specifier: ^2.6.0 version: 2.6.0 + '@ts-ghost/content-api': + specifier: ^4.0.12 + version: 4.0.12 '@ts-ghost/core-api': - specifier: ^5.1.2 - version: 5.1.2 + specifier: ^6.0.0 + version: 6.0.0 astro: - specifier: ^4.4.0 - version: 4.4.0(@types/node@20.11.19)(typescript@5.3.3) + specifier: ^4.4.1 + version: 4.4.9 + astro-integration-kit: + specifier: ^0.5.0 + version: 0.5.0(astro@4.4.9) astro-robots-txt: specifier: ^1.0.0 version: 1.0.0 - fs-extra: - specifier: ^11.1.0 - version: 11.2.0 - package-json: - specifier: 9.0.0 - version: 9.0.0 + picocolors: + specifier: 1.0.0 + version: 1.0.0 satori: - specifier: ^0.10.11 + specifier: ^0.10.13 version: 0.10.13 satori-html: - specifier: ^0.3.2 + specifier: 0.3.2 version: 0.3.2 vite: - specifier: ^5.1.3 - version: 5.1.3(@types/node@20.11.19) - vite-tsconfig-paths: - specifier: ^4.2.2 - version: 4.3.1(typescript@5.3.3)(vite@5.1.3) - zod: - specifier: ^3.22.4 - version: 3.22.4 - devDependencies: - '@astrojs/check': - specifier: ^0.5.4 - version: 0.5.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3) - '@matthiesenxyz/astro-ghostcms-catppuccin': - specifier: '*' - version: link:../astro-ghostcms-catppuccin - '@ts-ghost/tsconfig': - specifier: '*' - version: link:../tsconfig - '@types/fs-extra': - specifier: ^11.0.1 - version: 11.0.4 - '@types/node': - specifier: ^20.11.19 - version: 20.11.19 - '@typescript-eslint/eslint-plugin': - specifier: ^7.0.1 - version: 7.0.1(@typescript-eslint/parser@7.0.1)(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/parser': - specifier: ^7.0.1 - version: 7.0.1(eslint@8.56.0)(typescript@5.3.3) - eslint: - specifier: ^8.56.0 - version: 8.56.0 - eslint-config-prettier: - specifier: ^9.1.0 - version: 9.1.0(eslint@8.56.0) - eslint-plugin-astro: - specifier: ^0.31.4 - version: 0.31.4(eslint@8.56.0) - prettier: - specifier: ^3.2.5 - version: 3.2.5 - prettier-plugin-astro: - specifier: ^0.13.0 - version: 0.13.0 - typescript: - specifier: ^5.3.3 - version: 5.3.3 - vitest: - specifier: ^1.3.0 - version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) - vitest-fetch-mock: - specifier: ^0.2.2 - version: 0.2.2(vitest@1.3.0) + specifier: ^5.1.4 + version: 5.1.4(@types/node@20.11.19) packages/astro-ghostcms-brutalbyelian: dependencies: @@ -128,19 +79,19 @@ importers: version: 1.1.8 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: link:../astro-ghostcms + version: 3.2.9(typescript@5.3.3) '@matthiesenxyz/astro-ghostcms-rendercontent': specifier: ^0.0.7 version: link:../astro-ghostcms-rendercontent '@unocss/astro': specifier: ^0.58.5 - version: 0.58.5(vite@5.1.3) + version: 0.58.5(vite@5.1.4) '@unocss/reset': specifier: ^0.58.5 version: 0.58.5 astro: specifier: ^4.2.0 - version: 4.3.7(sass@1.71.0)(typescript@5.3.3) + version: 4.3.7(typescript@5.3.3) astro-font: specifier: ^0.0.77 version: 0.0.77 @@ -152,7 +103,7 @@ importers: version: 1.5.2 unocss: specifier: ^0.58.5 - version: 0.58.5(postcss@8.4.35)(vite@5.1.3) + version: 0.58.5(postcss@8.4.35)(vite@5.1.4) devDependencies: '@typescript-eslint/parser': specifier: ^7.0.1 @@ -186,13 +137,13 @@ importers: version: 5.0.16 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: link:../astro-ghostcms + version: 3.2.9(typescript@5.3.3) '@tailwindcss/typography': specifier: ^0.5.10 version: 0.5.10(tailwindcss@3.4.1) astro: specifier: ^4.2.1 - version: 4.3.7(sass@1.71.0)(typescript@5.3.3) + version: 4.3.7(typescript@5.3.3) astro-navbar: specifier: ^2.3.1 version: 2.3.1 @@ -220,7 +171,7 @@ importers: dependencies: '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: link:../astro-ghostcms + version: 3.2.9(sass@1.71.0)(typescript@5.3.3) astro: specifier: ^4.2.1 version: 4.3.7(sass@1.71.0)(typescript@5.3.3) @@ -233,7 +184,7 @@ importers: devDependencies: '@astrojs/check': specifier: ^0.5.4 - version: 0.5.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3) + version: 0.5.4(typescript@5.3.3) typescript: specifier: ^5.3.3 version: 5.3.3 @@ -312,10 +263,10 @@ importers: version: 5.1.2 vite: specifier: ^5.1.2 - version: 5.1.3(sass@1.71.0) + version: 5.1.3(@types/node@20.11.19) vite-tsconfig-paths: specifier: ^4.2.2 - version: 4.3.1(vite@5.1.3) + version: 4.3.1(typescript@5.3.3)(vite@5.1.3) devDependencies: '@astrojs/starlight': specifier: ^0.19.0 @@ -335,26 +286,20 @@ importers: packages/tsconfig: {} - playground: + playgrounds/astro-playground: dependencies: '@astrojs/tailwind': specifier: ^5.1.0 version: 5.1.0(astro@4.4.0)(tailwindcss@3.4.1) '@matthiesenxyz/astro-ghostcms': specifier: workspace:* - version: link:../packages/astro-ghostcms + version: link:../../packages/astro-ghostcms '@matthiesenxyz/astro-ghostcms-brutalbyelian': specifier: workspace:* - version: link:../packages/astro-ghostcms-brutalbyelian - '@matthiesenxyz/astro-ghostcms-catppuccin': - specifier: workspace:* - version: link:../packages/astro-ghostcms-catppuccin - '@matthiesenxyz/astro-ghostcms-theme-default': - specifier: workspace:* - version: link:../packages/astro-ghostcms-theme-default + version: link:../../packages/astro-ghostcms-brutalbyelian '@unocss/astro': specifier: ^0.58.5 - version: 0.58.5(vite@5.1.3) + version: 0.58.5(vite@5.1.4) astro: specifier: ^4.4.0 version: 4.4.0(typescript@5.3.3) @@ -370,16 +315,16 @@ importers: version: 5.3.3 unocss: specifier: ^0.58.5 - version: 0.58.5(postcss@8.4.35)(vite@5.1.3) + version: 0.58.5(postcss@8.4.35)(vite@5.1.4) - starlight-playground: + playgrounds/starlight-playground: dependencies: '@astrojs/starlight': specifier: ^0.19.0 version: 0.19.0(astro@4.4.0) '@matthiesenxyz/starlight-ghostcms': specifier: workspace:* - version: link:../packages/starlight-ghostcms + version: link:../../packages/starlight-ghostcms astro: specifier: ^4.4.0 version: 4.4.0(typescript@5.3.3) @@ -415,13 +360,13 @@ packages: /@antfu/utils@0.7.7: resolution: {integrity: sha512-gFPqTG7otEJ8uP6wrhDv6mqwGWYZKNvAcCq6u9hOj0c+IKCEsY4L1oC9trPq2SaWIzAfHvqfBDxF591JkMf+kg==} - /@astrojs/check@0.5.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3): + /@astrojs/check@0.5.4(typescript@5.3.3): resolution: {integrity: sha512-BFClaLEuRzpfF9wrmh9KDS5gmRHGhkVN7qvm6tWPBvUxOADXiNz+hzrYFvZVqXTXhHjS0Ern1g3yHifgu0zsmw==} hasBin: true peerDependencies: typescript: ^5.0.0 dependencies: - '@astrojs/language-server': 2.7.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3) + '@astrojs/language-server': 2.7.4(typescript@5.3.3) chokidar: 3.6.0 fast-glob: 3.3.2 kleur: 4.1.5 @@ -433,6 +378,7 @@ packages: /@astrojs/compiler@1.8.2: resolution: {integrity: sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==} + dev: true /@astrojs/compiler@2.5.3: resolution: {integrity: sha512-jzj01BRv/fmo+9Mr2FhocywGzEYiyiP2GVHje1ziGNU6c97kwhYGsnvwMkHrncAy9T9Vi54cjaMK7UE4ClX4vA==} @@ -440,7 +386,7 @@ packages: /@astrojs/internal-helpers@0.2.1: resolution: {integrity: sha512-06DD2ZnItMwUnH81LBLco3tWjcZ1lGU9rLCCBaeUCGYe9cI0wKyY2W3kDyoW1I6GmcWgt1fu+D1CTvz+FIKf8A==} - /@astrojs/language-server@2.7.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3): + /@astrojs/language-server@2.7.4(typescript@5.3.3): resolution: {integrity: sha512-U317ZKx5VXg2Sy6iPgYOliOZ10Ji/eo8MGFCry2/yT+rYTfb81HbrSWUu9nsZzpFK66So5aprQutRWWM/m7mPQ==} hasBin: true peerDependencies: @@ -460,12 +406,10 @@ packages: '@volar/language-service': 2.0.4 '@volar/typescript': 2.0.4 fast-glob: 3.3.2 - prettier: 3.2.5 - prettier-plugin-astro: 0.13.0 volar-service-css: 0.0.29(@volar/language-service@2.0.4) volar-service-emmet: 0.0.29(@volar/language-service@2.0.4) volar-service-html: 0.0.29(@volar/language-service@2.0.4) - volar-service-prettier: 0.0.29(@volar/language-service@2.0.4)(prettier@3.2.5) + volar-service-prettier: 0.0.29(@volar/language-service@2.0.4) volar-service-typescript: 0.0.29(@volar/language-service@2.0.4)(@volar/typescript@2.0.4) volar-service-typescript-twoslash-queries: 0.0.29(@volar/language-service@2.0.4) vscode-html-languageservice: 5.1.2 @@ -570,7 +514,7 @@ packages: astro: ^3.0.0 || ^4.0.0 tailwindcss: ^3.0.24 dependencies: - astro: 4.3.7(sass@1.71.0)(typescript@5.3.3) + astro: 4.3.7(typescript@5.3.3) autoprefixer: 10.4.17(postcss@8.4.35) postcss: 8.4.35 postcss-load-config: 4.0.2(postcss@8.4.35) @@ -1572,6 +1516,84 @@ packages: globby: 11.1.0 read-yaml-file: 1.1.0 + /@matthiesenxyz/astro-ghostcms-theme-default@0.1.13(astro@4.4.0)(typescript@5.3.3): + resolution: {integrity: sha512-W3zMuu+lJNkO+ccCsjCuGDwe/j8U08WAOowDy2fmwb5vkMu5QWYlCv8tR4Gh3VKfWodRTYoJsSkxETIQ7pXKxQ==} + peerDependencies: + astro: ^4.2.1 + dependencies: + '@matthiesenxyz/astro-ghostcms': 3.2.9(sass@1.71.0)(typescript@5.3.3) + astro: 4.4.0(typescript@5.3.3) + astro-font: 0.0.77 + sass: 1.71.0 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - stylus + - sugarss + - supports-color + - terser + - typescript + dev: false + + /@matthiesenxyz/astro-ghostcms@3.2.9(sass@1.71.0)(typescript@5.3.3): + resolution: {integrity: sha512-LuMXWwo8/AozHKLuu9okjmDqZWSRuJ+Pt2ggZv/gMQrfD4CLIucS4UMl2YQviU1QpguY46j7SP9x0BoIAhFBeA==} + dependencies: + '@astrojs/rss': 4.0.5 + '@astrojs/sitemap': 3.0.5 + '@matthiesenxyz/astro-ghostcms-theme-default': 0.1.13(astro@4.4.0)(typescript@5.3.3) + '@resvg/resvg-js': 2.6.0 + '@ts-ghost/core-api': 5.1.2 + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) + astro-robots-txt: 1.0.0 + fs-extra: 11.2.0 + package-json: 9.0.0 + satori: 0.10.13 + satori-html: 0.3.2 + vite: 5.1.4(sass@1.71.0) + vite-tsconfig-paths: 4.3.1(typescript@5.3.3)(vite@5.1.4) + zod: 3.22.4 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + - typescript + dev: false + + /@matthiesenxyz/astro-ghostcms@3.2.9(typescript@5.3.3): + resolution: {integrity: sha512-LuMXWwo8/AozHKLuu9okjmDqZWSRuJ+Pt2ggZv/gMQrfD4CLIucS4UMl2YQviU1QpguY46j7SP9x0BoIAhFBeA==} + dependencies: + '@astrojs/rss': 4.0.5 + '@astrojs/sitemap': 3.0.5 + '@matthiesenxyz/astro-ghostcms-theme-default': 0.1.13(astro@4.4.0)(typescript@5.3.3) + '@resvg/resvg-js': 2.6.0 + '@ts-ghost/core-api': 5.1.2 + astro: 4.4.0(typescript@5.3.3) + astro-robots-txt: 1.0.0 + fs-extra: 11.2.0 + package-json: 9.0.0 + satori: 0.10.13 + satori-html: 0.3.2 + vite: 5.1.4(@types/node@20.11.19) + vite-tsconfig-paths: 4.3.1(typescript@5.3.3)(vite@5.1.4) + zod: 3.22.4 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + - typescript + dev: false + /@mdx-js/mdx@3.0.1: resolution: {integrity: sha512-eIQ4QTrOWyL3LWEe/bu6Taqzq2HQvHcyTMaOrI95P2/LmJE7AsfPfgJGuFLPVqBUE1BC1rik3VIhU+s9u72arA==} dependencies: @@ -1963,6 +1985,13 @@ packages: tailwindcss: 3.4.1 dev: false + /@ts-ghost/content-api@4.0.12: + resolution: {integrity: sha512-EjpF83pOR1pC0F2USGhFTCGuJBYsM+P4n0ndKfQGO5KITYuMPV1BE4+J1iarFNnFu2g/BovFhohrRGv3mtJhIg==} + dependencies: + '@ts-ghost/core-api': 6.0.0 + zod: 3.22.4 + dev: false + /@ts-ghost/core-api@5.1.2: resolution: {integrity: sha512-YqLLGAJ8GxHx3GvotnZxmkDuT9ZjJo4DVLl30n5aXr/+1Y3O6PpNpwAa1ws67cshx0rbFmTAGN76goKbVfLDTg==} dependencies: @@ -1970,6 +1999,13 @@ packages: zod: 3.22.4 dev: false + /@ts-ghost/core-api@6.0.0: + resolution: {integrity: sha512-5Q7nbrmAoJ/5PcW2lPgCVyAJloVaQqybHpzXuFRbKj5sYWNeJbcwSrnYOBw/3t1tA2ghPrNVXqWOGrGKqZl1Zg==} + dependencies: + jose: 5.2.2 + zod: 3.22.4 + dev: false + /@types/acorn@4.0.6: resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} dependencies: @@ -2273,7 +2309,7 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - /@unocss/astro@0.58.5(vite@5.1.3): + /@unocss/astro@0.58.5(vite@5.1.4): resolution: {integrity: sha512-LtuVnj8oFAK9663OVhQO8KpdJFiOyyPsYfnOZlDCOFK3gHb/2WMrzdBwr1w8LoQF3bDedkFMKirVF7gWjyZiaw==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -2283,8 +2319,8 @@ packages: dependencies: '@unocss/core': 0.58.5 '@unocss/reset': 0.58.5 - '@unocss/vite': 0.58.5(vite@5.1.3) - vite: 5.1.3(sass@1.71.0) + '@unocss/vite': 0.58.5(vite@5.1.4) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - rollup @@ -2444,7 +2480,7 @@ packages: dependencies: '@unocss/core': 0.58.5 - /@unocss/vite@0.58.5(vite@5.1.3): + /@unocss/vite@0.58.5(vite@5.1.4): resolution: {integrity: sha512-p4o1XNX1rvjmoUqSSdua8XyWNg/d+YUChDd2L/xEty+6j2qv0wUaohs3UQ87vWlv632/UmgdX+2MbrgtqthCtw==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -2459,7 +2495,7 @@ packages: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.7 - vite: 5.1.3(sass@1.71.0) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - rollup @@ -2535,7 +2571,7 @@ packages: pathe: 1.1.2 picocolors: 1.0.0 sirv: 2.0.4 - vitest: 1.3.0(@vitest/ui@1.3.0) + vitest: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) dev: true /@vitest/utils@1.2.2: @@ -2844,6 +2880,34 @@ packages: resolution: {integrity: sha512-dh5TX2uxwqdFq15DF9cbRZgEdE9o8q522MP6xZYs+rnd3dexfDsIJMeEIDNVO7rkRxwJ7sphhCqTmdWvUJaiDg==} dev: false + /astro-integration-kit@0.5.0(astro@4.4.9): + resolution: {integrity: sha512-RbviqerotzLoVBGF8L1aFw5jIP40oWKScRXuzJNp399uDnPMPq7/cIh2x3MIS62U17h7o3d0S3kGt/Ael+tj1g==} + peerDependencies: + '@vitejs/plugin-react': ^4.2.1 + astro: ^4.4.1 + preact: ^10.19.4 + react: ^18.2.0 + solid-js: ^1.8.15 + svelte: ^4.2.11 + vue: ^3.4.19 + peerDependenciesMeta: + '@vitejs/plugin-react': + optional: true + preact: + optional: true + react: + optional: true + solid-js: + optional: true + svelte: + optional: true + vue: + optional: true + dependencies: + astro: 4.4.9 + pathe: 1.1.2 + dev: false + /astro-navbar@2.3.1: resolution: {integrity: sha512-lLvhWS03Qc3heMU23adFwEnBUJFlL6gxYi0xPvIyX1atb2oCov4kOS/MaWOPGnvj2nK63szebUzlG+NdIoUZzQ==} dev: false @@ -2858,7 +2922,7 @@ packages: /astro-seo@0.8.2(typescript@5.3.3): resolution: {integrity: sha512-9hu+2y0QboOShFly9r+LcasfEOsWFhV5GKzsfnPG4kbNm9mqXuEP7YrUt7XrEA7rJOzC1DInOV+cIT+7zBasBQ==} dependencies: - '@astrojs/check': 0.5.4(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.3.3) + '@astrojs/check': 0.5.4(typescript@5.3.3) transitivePeerDependencies: - prettier - prettier-plugin-astro @@ -2930,8 +2994,8 @@ packages: tsconfck: 3.0.2(typescript@5.3.3) unist-util-visit: 5.0.0 vfile: 6.0.1 - vite: 5.1.3(sass@1.71.0) - vitefu: 0.2.5(vite@5.1.3) + vite: 5.1.4(sass@1.71.0) + vitefu: 0.2.5(vite@5.1.4) which-pm: 2.1.1 yargs-parser: 21.1.1 zod: 3.22.4 @@ -2949,7 +3013,91 @@ packages: - typescript dev: false - /astro@4.4.0(@types/node@20.11.19)(typescript@5.3.3): + /astro@4.3.7(typescript@5.3.3): + resolution: {integrity: sha512-spdl+Ae6WZjQ0w8VBPq8ulN1hdN0m4EWvKG7ecgHjPQIHidMnzWJoZLEFEeKASqCGB1fDibqr7RDHoHkhZbp2Q==} + engines: {node: '>=18.14.1', npm: '>=6.14.0'} + hasBin: true + dependencies: + '@astrojs/compiler': 2.5.3 + '@astrojs/internal-helpers': 0.2.1 + '@astrojs/markdown-remark': 4.2.1 + '@astrojs/telemetry': 3.0.4 + '@babel/core': 7.23.9 + '@babel/generator': 7.23.6 + '@babel/parser': 7.23.9 + '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.9) + '@babel/traverse': 7.23.9 + '@babel/types': 7.23.9 + '@types/babel__core': 7.20.5 + acorn: 8.11.3 + aria-query: 5.3.0 + axobject-query: 4.0.0 + boxen: 7.1.1 + chokidar: 3.6.0 + ci-info: 4.0.0 + clsx: 2.1.0 + common-ancestor-path: 1.0.1 + cookie: 0.6.0 + cssesc: 3.0.0 + debug: 4.3.4 + deterministic-object-hash: 2.0.2 + devalue: 4.3.2 + diff: 5.2.0 + dlv: 1.1.3 + dset: 3.1.3 + es-module-lexer: 1.4.1 + esbuild: 0.19.12 + estree-walker: 3.0.3 + execa: 8.0.1 + fast-glob: 3.3.2 + flattie: 1.1.0 + github-slugger: 2.0.0 + gray-matter: 4.0.3 + html-escaper: 3.0.3 + http-cache-semantics: 4.1.1 + js-yaml: 4.1.0 + kleur: 4.1.5 + magic-string: 0.30.7 + mdast-util-to-hast: 13.0.2 + mime: 3.0.0 + ora: 7.0.1 + p-limit: 5.0.0 + p-queue: 8.0.1 + path-to-regexp: 6.2.1 + preferred-pm: 3.1.2 + probe-image-size: 7.2.3 + prompts: 2.4.2 + rehype: 13.0.1 + resolve: 1.22.8 + semver: 7.6.0 + server-destroy: 1.0.1 + shikiji: 0.9.19 + shikiji-core: 0.9.19 + string-width: 7.1.0 + strip-ansi: 7.1.0 + tsconfck: 3.0.2(typescript@5.3.3) + unist-util-visit: 5.0.0 + vfile: 6.0.1 + vite: 5.1.4(@types/node@20.11.19) + vitefu: 0.2.5(vite@5.1.4) + which-pm: 2.1.1 + yargs-parser: 21.1.1 + zod: 3.22.4 + optionalDependencies: + sharp: 0.32.6 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + - typescript + dev: false + + /astro@4.4.0(sass@1.71.0)(typescript@5.3.3): resolution: {integrity: sha512-JAsMrm1Z6W4Iqg9Q7LW/6lCXrqa4jndEOlR/yu7NGNP0BrPwSM8i4+yzya6hxgsNvyyVK8ywthaNhFmqd8Z+cg==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} hasBin: true @@ -3014,8 +3162,8 @@ packages: tsconfck: 3.0.2(typescript@5.3.3) unist-util-visit: 5.0.0 vfile: 6.0.1 - vite: 5.1.3(@types/node@20.11.19) - vitefu: 0.2.5(vite@5.1.3) + vite: 5.1.4(sass@1.71.0) + vitefu: 0.2.5(vite@5.1.4) which-pm: 2.1.1 yargs-parser: 21.1.1 zod: 3.22.4 @@ -3098,8 +3246,8 @@ packages: tsconfck: 3.0.2(typescript@5.3.3) unist-util-visit: 5.0.0 vfile: 6.0.1 - vite: 5.1.3(sass@1.71.0) - vitefu: 0.2.5(vite@5.1.3) + vite: 5.1.4(@types/node@20.11.19) + vitefu: 0.2.5(vite@5.1.4) which-pm: 2.1.1 yargs-parser: 21.1.1 zod: 3.22.4 @@ -3116,6 +3264,89 @@ packages: - terser - typescript + /astro@4.4.9: + resolution: {integrity: sha512-FTWhzKjao7rHHiF/CqPqPS18AFad+fmUcYUFhWWIsYETHcc9g0IIIiv6cHXUE7g6mEZf7ycAa+WdboeEHUhraQ==} + engines: {node: '>=18.14.1', npm: '>=6.14.0'} + hasBin: true + dependencies: + '@astrojs/compiler': 2.5.3 + '@astrojs/internal-helpers': 0.2.1 + '@astrojs/markdown-remark': 4.2.1 + '@astrojs/telemetry': 3.0.4 + '@babel/core': 7.23.9 + '@babel/generator': 7.23.6 + '@babel/parser': 7.23.9 + '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.9) + '@babel/traverse': 7.23.9 + '@babel/types': 7.23.9 + '@medv/finder': 3.1.0 + '@types/babel__core': 7.20.5 + acorn: 8.11.3 + aria-query: 5.3.0 + axobject-query: 4.0.0 + boxen: 7.1.1 + chokidar: 3.6.0 + ci-info: 4.0.0 + clsx: 2.1.0 + common-ancestor-path: 1.0.1 + cookie: 0.6.0 + cssesc: 3.0.0 + debug: 4.3.4 + deterministic-object-hash: 2.0.2 + devalue: 4.3.2 + diff: 5.2.0 + dlv: 1.1.3 + dset: 3.1.3 + es-module-lexer: 1.4.1 + esbuild: 0.19.12 + estree-walker: 3.0.3 + execa: 8.0.1 + fast-glob: 3.3.2 + flattie: 1.1.0 + github-slugger: 2.0.0 + gray-matter: 4.0.3 + html-escaper: 3.0.3 + http-cache-semantics: 4.1.1 + js-yaml: 4.1.0 + kleur: 4.1.5 + magic-string: 0.30.7 + mdast-util-to-hast: 13.0.2 + mime: 3.0.0 + ora: 7.0.1 + p-limit: 5.0.0 + p-queue: 8.0.1 + path-to-regexp: 6.2.1 + preferred-pm: 3.1.2 + prompts: 2.4.2 + rehype: 13.0.1 + resolve: 1.22.8 + semver: 7.6.0 + shikiji: 0.9.19 + shikiji-core: 0.9.19 + string-width: 7.1.0 + strip-ansi: 7.1.0 + tsconfck: 3.0.2(typescript@5.3.3) + unist-util-visit: 5.0.0 + vfile: 6.0.1 + vite: 5.1.4(@types/node@20.11.19) + vitefu: 0.2.5(vite@5.1.4) + which-pm: 2.1.1 + yargs-parser: 21.1.1 + zod: 3.22.4 + optionalDependencies: + sharp: 0.32.6 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + - typescript + dev: false + /astrojs-compiler-sync@0.3.5(@astrojs/compiler@2.5.3): resolution: {integrity: sha512-y420rhIIJ2HHDkYeqKArBHSdJNIIGMztLH90KGIX3zjcJyt/cr9Z2wYA8CP5J1w6KE7xqMh0DAkhfjhNDpQb2Q==} engines: {node: ^14.18.0 || >=16.0.0} @@ -5060,6 +5291,7 @@ packages: /immutable@4.3.5: resolution: {integrity: sha512-8eabxkth9gZatlwl5TBuJnCsoTADlL6ftEr7A4qgdaTsPyreilDSnUk57SO+jfKcNtxPa22U5KK6DSeAYhpBJw==} + dev: false /import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -5502,6 +5734,7 @@ packages: /lilconfig@3.1.0: resolution: {integrity: sha512-p3cz0JV5vw/XeouBU3Ldnp+ZkBjE+n8ydJ4mcwBrOiXXPqNlrzGBqWs9X4MWF7f+iKUBu794Y8Hh8yawiJbCjw==} engines: {node: '>=14'} + deprecated: This version contains a security issue. Please upgrade to 3.1.1 or later. dev: false /linebreak@1.1.0: @@ -6816,6 +7049,7 @@ packages: '@astrojs/compiler': 1.8.2 prettier: 3.2.5 sass-formatter: 0.7.9 + dev: true /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} @@ -6826,6 +7060,7 @@ packages: resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} engines: {node: '>=14'} hasBin: true + dev: true /pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} @@ -7220,6 +7455,7 @@ packages: /s.color@0.0.15: resolution: {integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==} + dev: true /safe-array-concat@1.1.0: resolution: {integrity: sha512-ZdQ0Jeb9Ofti4hbt5lX3T2JcAamT9hfzYU1MNB+z/jaEbB6wfFfPIR/zEORmZqobkCCJhSjodobH6WHNmJ97dg==} @@ -7249,6 +7485,7 @@ packages: resolution: {integrity: sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==} dependencies: suf-log: 2.5.3 + dev: true /sass@1.71.0: resolution: {integrity: sha512-HKKIKf49Vkxlrav3F/w6qRuPcmImGVbIXJ2I3Kg0VMA+3Bav+8yE9G5XmP5lMj6nl4OlqbPftGAscNaNu28b8w==} @@ -7258,6 +7495,7 @@ packages: chokidar: 3.6.0 immutable: 4.3.5 source-map-js: 1.0.2 + dev: false /satori-html@0.3.2: resolution: {integrity: sha512-wjTh14iqADFKDK80e51/98MplTGfxz2RmIzh0GqShlf4a67+BooLywF17TvJPD6phO0Hxm7Mf1N5LtRYvdkYRA==} @@ -7684,6 +7922,7 @@ packages: resolution: {integrity: sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==} dependencies: s.color: 0.0.15 + dev: true /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -8145,7 +8384,7 @@ packages: engines: {node: '>= 10.0.0'} dev: false - /unocss@0.58.5(postcss@8.4.35)(vite@5.1.3): + /unocss@0.58.5(postcss@8.4.35)(vite@5.1.4): resolution: {integrity: sha512-0g4P6jLgRRNnhscxw7nQ9RHGrKJ1UPPiHPet+YT3TXUcmy4mTiYgo9+kGQf5bjyrzsELJ10cT6Qz2y6g9Tls4g==} engines: {node: '>=14'} peerDependencies: @@ -8157,7 +8396,7 @@ packages: vite: optional: true dependencies: - '@unocss/astro': 0.58.5(vite@5.1.3) + '@unocss/astro': 0.58.5(vite@5.1.4) '@unocss/cli': 0.58.5 '@unocss/core': 0.58.5 '@unocss/extractor-arbitrary-variants': 0.58.5 @@ -8176,8 +8415,8 @@ packages: '@unocss/transformer-compile-class': 0.58.5 '@unocss/transformer-directives': 0.58.5 '@unocss/transformer-variant-group': 0.58.5 - '@unocss/vite': 0.58.5(vite@5.1.3) - vite: 5.1.3(sass@1.71.0) + '@unocss/vite': 0.58.5(vite@5.1.4) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - postcss - rollup @@ -8263,28 +8502,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.3(sass@1.71.0) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - - /vite-node@1.3.0: - resolution: {integrity: sha512-D/oiDVBw75XMnjAXne/4feCkCEwcbr2SU1bjAhCcfI5Bq3VoOHji8/wCPAfUkDIeohJ5nSZ39fNxM3dNZ6OBOA==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - dependencies: - cac: 6.7.14 - debug: 4.3.4 - pathe: 1.1.2 - picocolors: 1.0.0 - vite: 5.1.3(sass@1.71.0) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - '@types/node' - less @@ -8305,7 +8523,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.3(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - '@types/node' - less @@ -8333,7 +8551,7 @@ packages: - supports-color - typescript - /vite-tsconfig-paths@4.3.1(vite@5.1.3): + /vite-tsconfig-paths@4.3.1(typescript@5.3.3)(vite@5.1.4): resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} peerDependencies: vite: '*' @@ -8344,7 +8562,7 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 3.0.2(typescript@5.3.3) - vite: 5.1.3(sass@1.71.0) + vite: 5.1.4(@types/node@20.11.19) transitivePeerDependencies: - supports-color - typescript @@ -8385,8 +8603,43 @@ packages: optionalDependencies: fsevents: 2.3.3 - /vite@5.1.3(sass@1.71.0): - resolution: {integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==} + /vite@5.1.4(@types/node@20.11.19): + resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 20.11.19 + esbuild: 0.19.12 + postcss: 8.4.35 + rollup: 4.11.0 + optionalDependencies: + fsevents: 2.3.3 + + /vite@5.1.4(sass@1.71.0): + resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -8419,8 +8672,9 @@ packages: sass: 1.71.0 optionalDependencies: fsevents: 2.3.3 + dev: false - /vitefu@0.2.5(vite@5.1.3): + /vitefu@0.2.5(vite@5.1.4): resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} peerDependencies: vite: ^3.0.0 || ^4.0.0 || ^5.0.0 @@ -8428,7 +8682,7 @@ packages: vite: optional: true dependencies: - vite: 5.1.3(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.19) /vitest-fetch-mock@0.2.2(vitest@1.2.2): resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} @@ -8449,7 +8703,7 @@ packages: vitest: '>=0.16.0' dependencies: cross-fetch: 3.1.8 - vitest: 1.3.0(@vitest/ui@1.3.0) + vitest: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) transitivePeerDependencies: - encoding dev: true @@ -8498,7 +8752,7 @@ packages: strip-literal: 1.3.0 tinybench: 2.6.0 tinypool: 0.8.2 - vite: 5.1.3(sass@1.71.0) + vite: 5.1.4(@types/node@20.11.19) vite-node: 1.2.2 why-is-node-running: 2.2.2 transitivePeerDependencies: @@ -8568,62 +8822,6 @@ packages: - terser dev: true - /vitest@1.3.0(@vitest/ui@1.3.0): - resolution: {integrity: sha512-V9qb276J1jjSx9xb75T2VoYXdO1UKi+qfflY7V7w93jzX7oA/+RtYE6TcifxksxsZvygSSMwu2Uw6di7yqDMwg==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 1.3.0 - '@vitest/ui': 1.3.0 - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@types/node': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - dependencies: - '@vitest/expect': 1.3.0 - '@vitest/runner': 1.3.0 - '@vitest/snapshot': 1.3.0 - '@vitest/spy': 1.3.0 - '@vitest/ui': 1.3.0(vitest@1.3.0) - '@vitest/utils': 1.3.0 - acorn-walk: 8.3.2 - chai: 4.4.1 - debug: 4.3.4 - execa: 8.0.1 - local-pkg: 0.5.0 - magic-string: 0.30.7 - pathe: 1.1.2 - picocolors: 1.0.0 - std-env: 3.7.0 - strip-literal: 2.0.0 - tinybench: 2.6.0 - tinypool: 0.8.2 - vite: 5.1.3(sass@1.71.0) - vite-node: 1.3.0 - why-is-node-running: 2.2.2 - transitivePeerDependencies: - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - /volar-service-css@0.0.29(@volar/language-service@2.0.4): resolution: {integrity: sha512-2kNdgEYEiLeeer3wkagNBVDPa3Zj7mBDeM7D3iYmBXA0LCwd2tQL3eASzcDW9Gvac1g478UtptK468GxzUAEcA==} peerDependencies: @@ -8660,7 +8858,7 @@ packages: vscode-html-languageservice: 5.1.2 vscode-uri: 3.0.8 - /volar-service-prettier@0.0.29(@volar/language-service@2.0.4)(prettier@3.2.5): + /volar-service-prettier@0.0.29(@volar/language-service@2.0.4): resolution: {integrity: sha512-GxcDKfiVv3fc4XUtUOkQpX0QlFjWppRCVWIBp751gOKJwDex142xMlbTxP9la9tollbmj2O/tVUrqqLDGQ+Lsg==} peerDependencies: '@volar/language-service': ~2.0.1 @@ -8672,7 +8870,6 @@ packages: optional: true dependencies: '@volar/language-service': 2.0.4 - prettier: 3.2.5 vscode-uri: 3.0.8 /volar-service-typescript-twoslash-queries@0.0.29(@volar/language-service@2.0.4): diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index a2aec9a0..f30c9659 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,3 @@ packages: - "packages/*" - - "playground" - - "starlight-playground" \ No newline at end of file + - "playgrounds/*" \ No newline at end of file From fd21ee8df5d88ce555329be9c2a1a4effaea1245 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 07:06:58 -0800 Subject: [PATCH 02/46] Some basic tests --- package.json | 14 +- packages/astro-ghostcms/package.json | 6 + .../astro-ghostcms/src/api/ghostAPI.test.ts | 84 ++++++++++ .../astro-ghostcms/src/api/invariant.test.ts | 32 ++++ .../src/schemas/api/authors.test.ts | 146 ++++++++++++++++++ .../src/schemas/api/posts.test.ts | 55 +++++++ .../src/schemas/api/settings.test.ts | 36 +++++ .../src/schemas/userconfig.test.ts | 54 +++++++ packages/astro-ghostcms/vitest.config.ts | 12 ++ pnpm-lock.yaml | 9 +- 10 files changed, 440 insertions(+), 8 deletions(-) create mode 100644 packages/astro-ghostcms/src/api/ghostAPI.test.ts create mode 100644 packages/astro-ghostcms/src/api/invariant.test.ts create mode 100644 packages/astro-ghostcms/src/schemas/api/authors.test.ts create mode 100644 packages/astro-ghostcms/src/schemas/api/posts.test.ts create mode 100644 packages/astro-ghostcms/src/schemas/api/settings.test.ts create mode 100644 packages/astro-ghostcms/src/schemas/userconfig.test.ts create mode 100644 packages/astro-ghostcms/vitest.config.ts diff --git a/package.json b/package.json index 04ff3b53..1b518edb 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,14 @@ "lint:fix": "biome check --apply .", "ci:version": "pnpm changeset version", "ci:publish": "pnpm changeset publish", - "ci:test:api": "pnpm --filter astro-ghostcms test:ci", - "test:api": "pnpm --filter astro-ghostcms test", - "test:api:watch": "pnpm --filter astro-ghostcms test:watch", - "test:api:coverage": "pnpm --filter astro-ghostcms test:coverage", + "ci:test:integration": "pnpm --filter astro-ghostcms test:ci", + "test:integration": "pnpm --filter astro-ghostcms test", + "test:integration:watch": "pnpm --filter astro-ghostcms test:watch", + "test:integration:coverage": "pnpm --filter astro-ghostcms test:coverage", "test:create": "pnpm --filter create-astro-ghostcms test", - "test:slg": "pnpm --filter starlight-ghostcms test", - "test:slg:watch": "pnpm --filter starlight-ghostcms test:watch", - "test:slg:coverage": "pnpm --filter starlight-ghostcms test:coverage" + "test:starlight": "pnpm --filter starlight-ghostcms test", + "test:starlight:watch": "pnpm --filter starlight-ghostcms test:watch", + "test:starlight:coverage": "pnpm --filter starlight-ghostcms test:coverage" }, "devDependencies": { "@biomejs/biome": "1.5.3", diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index c81e3c24..64518bcb 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -49,11 +49,17 @@ "./open-graph/*": "./src/integrations/satoriog/routes/*" }, "scripts": { + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage", + "test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'" }, "peerDependencies": { "astro": "^4.4.1" }, "devDependencies": { + "vitest": "^1.3.0", + "vitest-fetch-mock": "^0.2.2" }, "dependencies": { "@astrojs/rss": "^4.0.5", diff --git a/packages/astro-ghostcms/src/api/ghostAPI.test.ts b/packages/astro-ghostcms/src/api/ghostAPI.test.ts new file mode 100644 index 00000000..c4599fc1 --- /dev/null +++ b/packages/astro-ghostcms/src/api/ghostAPI.test.ts @@ -0,0 +1,84 @@ +import { assert, beforeEach, describe, expect, test } from "vitest"; + +import { TSGhostContentAPI } from "@ts-ghost/content-api"; + +describe("content-api", () => { + let api: TSGhostContentAPI; + beforeEach(() => { + api = new TSGhostContentAPI("https://ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + }); + + test("content-api", () => { + expect(api).toBeDefined(); + }); + + test("content-api shouldn't instantiate with an incorrect url", () => { + assert.throws(() => { + const api = new TSGhostContentAPI("ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + api.settings; + }); + }); + + test("content-api shouldn't instantiate with an incorrect key", () => { + assert.throws(() => { + const api = new TSGhostContentAPI("https://ghost.org", "a", "v5.0"); + api.settings; + }); + }); + + test("content-api shouldn't instantiate with an incorrect version", () => { + assert.throws(() => { + const api = new TSGhostContentAPI( + "https://ghost.org", + "1efedd9db174adee2d23d982:4b74dca0219bad629852191af326a45037346c2231240e0f7aec1f9371cc14e8", + // @ts-expect-error + "v4.0", + ); + api.settings; + }); + }); + + test("content-api.posts", () => { + expect(api.posts).toBeDefined(); + expect(api.posts.browse).toBeDefined(); + expect(api.posts.read).toBeDefined(); + }); + + test("content-api.pages", () => { + expect(api.pages).toBeDefined(); + expect(api.pages.browse).toBeDefined(); + expect(api.pages.read).toBeDefined(); + }); + + test("content-api.tags", () => { + expect(api.tags).toBeDefined(); + expect(api.tags.browse).toBeDefined(); + expect(api.tags.read).toBeDefined(); + }); + + test("content-api.tiers", () => { + expect(api.tiers).toBeDefined(); + expect(api.tiers.browse).toBeDefined(); + expect(api.tiers.read).toBeDefined(); + }); + + test("content-api.authors", () => { + expect(api.authors).toBeDefined(); + expect(api.authors.browse).toBeDefined(); + expect(api.authors.read).toBeDefined(); + // @ts-expect-error + expect(api.authors.add).toBeUndefined(); + // @ts-expect-error + expect(api.authors.edit).toBeUndefined(); + expect(api.authors).toBeDefined(); + }); + + test("content-api.settings", () => { + expect(api.settings).toBeDefined(); + expect(api.settings.fetch).toBeDefined(); + // @ts-expect-error + expect(api.settings.read).toBeUndefined(); + // @ts-expect-error + expect(api.settings.browse).toBeUndefined(); + }); +}); diff --git a/packages/astro-ghostcms/src/api/invariant.test.ts b/packages/astro-ghostcms/src/api/invariant.test.ts new file mode 100644 index 00000000..20c887b9 --- /dev/null +++ b/packages/astro-ghostcms/src/api/invariant.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, it } from "vitest"; + +// Modified version of invariant script to allow tests +const isProduction = false; +const prefix: string = "Invariant failed"; +function invariant(condition: any, message?: string | (() => string)) { + if (condition) { + return; + } + if (isProduction) { + throw new Error(prefix); + } + const provided: string | undefined = + typeof message === "function" ? message() : message; + const value: string = provided ? `${prefix}: ${provided}` : prefix; + return value; +} + +// TEST SECTION +const testTrue = true; +const testFalse = false; +describe("test invariant", () => { + it("Test `true` value", () => { + invariant(testTrue, "This should not error"); + expect(null); + }); + + it("Test `false` value", () => { + invariant(testFalse, "This should Error"); + expect(String("Invariant failed")); + }); +}); diff --git a/packages/astro-ghostcms/src/schemas/api/authors.test.ts b/packages/astro-ghostcms/src/schemas/api/authors.test.ts new file mode 100644 index 00000000..9cee527b --- /dev/null +++ b/packages/astro-ghostcms/src/schemas/api/authors.test.ts @@ -0,0 +1,146 @@ +import createFetchMock from "vitest-fetch-mock"; +import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; + +import { TSGhostContentAPI } from "@ts-ghost/content-api"; + +const fetchMocker = createFetchMock(vi); + +describe("authors api .browse() Args Type-safety", () => { + const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; + const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; + const api = new TSGhostContentAPI(url, key, "v5.0"); + test(".browse() params shouldnt accept invalid params", () => { + // @ts-expect-error - shouldnt accept invalid params + const browse = api.authors.browse({ pp: 2 }); + expect(browse.getParams().browseParams).toStrictEqual({}); + }); + + test(".browse() 'order' params should ony accept fields values", () => { + // @ts-expect-error - order should ony contain field + expect(() => api.authors.browse({ order: "foo ASC" })).toThrow(); + // valid + expect(api.authors.browse({ order: "name ASC" }).getParams().browseParams).toStrictEqual({ + order: "name ASC", + }); + expect(api.authors.browse({ order: "name ASC,slug DESC" }).getParams().browseParams).toStrictEqual({ + order: "name ASC,slug DESC", + }); + expect( + api.authors.browse({ order: "name ASC,slug DESC,location ASC" }).getParams().browseParams + ).toStrictEqual({ + order: "name ASC,slug DESC,location ASC", + }); + // @ts-expect-error - order should ony contain field (There is a typo in location) + expect(() => api.authors.browse({ order: "name ASC,slug DESC,locaton ASC" })).toThrow(); + }); + + test(".browse() 'filter' params should ony accept valid field", () => { + expect(() => + api.authors.browse({ + // @ts-expect-error - order should ony contain field + filter: "foo:bar", + }) + ).toThrow(); + expect( + api.authors + .browse({ + filter: "name:bar", + }) + .getParams().browseParams + ).toStrictEqual({ + filter: "name:bar", + }); + expect( + api.authors + .browse({ + filter: "name:bar+slug:-test", + }) + .getParams().browseParams + ).toStrictEqual({ + filter: "name:bar+slug:-test", + }); + }); + + test(".browse 'fields' argument should ony accept valid fields", () => { + expect( + api.authors + .browse() + .fields({ + // @ts-expect-error - order should ony contain field + foo: true, + }) + .getOutputFields() + ).toEqual([]); + + expect(api.authors.browse().fields({ location: true }).getOutputFields()).toEqual(["location"]); + expect(api.authors.browse().fields({ name: true, website: true }).getOutputFields()).toEqual([ + "name", + "website", + ]); + }); +}); + +describe("authors resource mocked", () => { + let api: TSGhostContentAPI; + + beforeEach(() => { + api = new TSGhostContentAPI("https://my-ghost-blog.com", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + fetchMocker.enableMocks(); + }); + afterEach(() => { + vi.restoreAllMocks(); + }); + + test("aouthors should be fetched correctly", async () => { + const authors = api.authors; + expect(authors).not.toBeUndefined(); + const browseQuery = authors + .browse({ + page: 2, + }) + .fields({ + name: true, + id: true, + }); + expect(browseQuery).not.toBeUndefined(); + expect(browseQuery.getOutputFields()).toStrictEqual(["name", "id"]); + + fetchMocker.doMockOnce( + JSON.stringify({ + authors: [ + { + name: "foo", + id: "eaoizdjoa1321123", + }, + ], + meta: { + pagination: { + page: 1, + limit: 15, + pages: 1, + total: 1, + next: null, + prev: null, + }, + }, + }) + ); + const result = await browseQuery.fetch(); + expect(fetchMocker).toHaveBeenCalledTimes(1); + expect(fetchMocker).toHaveBeenCalledWith( + "https://my-ghost-blog.com/ghost/api/content/authors/?page=2&fields=name%2Cid&key=59d4bf56c73c04a18c867dc3ba", + { + headers: { + "Content-Type": "application/json", + "Accept-Version": "v5.0", + }, + } + ); + expect(result).not.toBeUndefined(); + if (result.success) { + expect(result.data.length).toBe(1); + expect(result.data[0].name).toBe("foo"); + expect(result.data[0].id).toBe("eaoizdjoa1321123"); + } + }); +}); \ No newline at end of file diff --git a/packages/astro-ghostcms/src/schemas/api/posts.test.ts b/packages/astro-ghostcms/src/schemas/api/posts.test.ts new file mode 100644 index 00000000..f682720b --- /dev/null +++ b/packages/astro-ghostcms/src/schemas/api/posts.test.ts @@ -0,0 +1,55 @@ +import { describe, expect, test } from "vitest"; + +import { TSGhostContentAPI } from "@ts-ghost/content-api"; +import type { Post } from "./index"; + +const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; +const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; + +describe("posts api .browse() Args Type-safety", () => { + const api = new TSGhostContentAPI(url, key, "v5.0"); + test(".browse() params shouldnt accept invalid params", () => { + // @ts-expect-error - shouldnt accept invalid params + const browse = api.posts.browse({ pp: 2 }); + expect(browse.getParams().browseParams).toStrictEqual({}); + + const outputFields = { + slug: true, + title: true, + // @ts-expect-error - shouldnt accept invalid params + foo: true, + } satisfies { [k in keyof Post]?: true | undefined }; + + const test = api.posts + .browse() + // @ts-expect-error - shouldnt accept invalid params + .fields(outputFields); + expect(test.getOutputFields()).toEqual(["slug", "title"]); + + const fields = ["slug", "title", "foo"] as const; + const unknownOriginFields = fields.reduce((acc, k) => { + acc[k as keyof Post] = true; + return acc; + }, {} as { [k in keyof Post]?: true | undefined }); + const result = api.posts.browse().fields(unknownOriginFields); + expect(result.getOutputFields()).toEqual(["slug", "title"]); + }); + test(".browse() params, output fields declare const", () => { + const outputFields = { + slug: true, + title: true, + } satisfies { [k in keyof Post]?: true | undefined }; + + const test = api.posts.browse().fields(outputFields); + expect(test.getOutputFields()).toEqual(["slug", "title"]); + + // @ts-expect-error - shouldnt accept invalid params + expect(() => api.posts.browse({ filter: "slugg:test" })).toThrow(); + // @ts-expect-error - shouldnt accept invalid params + expect(() => api.posts.browse({ filter: "slug:test,foo:-[bar,baz]" })).toThrow(); + expect(api.posts.browse({ filter: "slug:test,tags:-[bar,baz]" })).toBeDefined(); + expect(api.posts.browse({ filter: "slug:test,tags:[bar,baz]" })).toBeDefined(); + // @ts-expect-error - shouldnt accept invalid params + expect(() => api.posts.browse({ filter: "slug:test,food:-[bar,baz]" })).toThrow(); + }); +}); \ No newline at end of file diff --git a/packages/astro-ghostcms/src/schemas/api/settings.test.ts b/packages/astro-ghostcms/src/schemas/api/settings.test.ts new file mode 100644 index 00000000..e5da99da --- /dev/null +++ b/packages/astro-ghostcms/src/schemas/api/settings.test.ts @@ -0,0 +1,36 @@ +import { beforeEach, describe, expect, test } from "vitest"; + +import { TSGhostContentAPI } from "@ts-ghost/content-api"; + +const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; +const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; + +describe("settings integration tests browse", () => { + let api: TSGhostContentAPI; + beforeEach(() => { + api = new TSGhostContentAPI(url, key, "v5.0"); + }); + test("settings.fetch()", async () => { + const result = await api.settings.fetch(); + expect(result).not.toBeUndefined(); + expect(result).not.toBeNull(); + if (!result.success) { + expect(result.errors).toBeDefined(); + expect(result.errors).toHaveLength(1); + } else { + expect(result.data).toBeDefined(); + const settings = result.data; + expect(settings).toBeDefined(); + expect(settings.title).toBe("Astro Starter"); + expect(settings.description).toBe("Thoughts, stories and ideas."); + expect(settings.logo).toBeNull(); + expect(settings.cover_image).toBe("https://static.ghost.org/v4.0.0/images/publication-cover.jpg"); + expect(settings.icon).toBeNull(); + expect(settings.lang).toBe("en"); + expect(settings.timezone).toBe("Etc/UTC"); + expect(settings.codeinjection_head).toBeNull(); + expect(settings.codeinjection_foot).toBeNull(); + expect(settings.members_support_address).toBe("noreply"); + } + }); +}); \ No newline at end of file diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts new file mode 100644 index 00000000..8c1274bb --- /dev/null +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -0,0 +1,54 @@ +import { expect, describe, it } from "vitest"; +import { GhostUserConfigSchema } from "./userconfig"; + +describe("GhostUserConfigSchema", () => { + it("should validate a valid user config", () => { + const validConfig = { + ghostURL: "https://ghostdemo.matthiesen.xyz", + disableThemeProvider: true, + ThemeProvider: { + theme: "@matthiesenxyz/astro-ghostcms-theme-default", + }, + disableDefault404: false, + enableRSSFeed: true, + enableOGImages: true, + sitemap: { + // sitemap configuration + }, + robotstxt: { + // robotstxt configuration + }, + fullConsoleLogs: false, + }; + + const result = GhostUserConfigSchema.safeParse(validConfig); + + expect(result.success).to.be.true; + expect(result.data).to.deep.equal(validConfig); + }); + + it("should invalidate an invalid user config", () => { + const invalidConfig = { + ghostURL: "invalid-url", + disableThemeProvider: "true", + ThemeProvider: { + theme: 123, + }, + disableDefault404: "false", + enableRSSFeed: "true", + enableOGImages: "true", + sitemap: { + // invalid sitemap configuration + }, + robotstxt: { + // invalid robotstxt configuration + }, + fullConsoleLogs: "false", + }; + + const result = GhostUserConfigSchema.safeParse(invalidConfig); + + expect(result.success).to.be.false; + expect(!result.success).to.exist; + }); +}); \ No newline at end of file diff --git a/packages/astro-ghostcms/vitest.config.ts b/packages/astro-ghostcms/vitest.config.ts new file mode 100644 index 00000000..f19e0d02 --- /dev/null +++ b/packages/astro-ghostcms/vitest.config.ts @@ -0,0 +1,12 @@ +/// +/// +import { defineProject } from 'vitest/config' + +export default defineProject({ + test: { + globals: true, + include: ["./**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], + watchExclude: [".*\\/node_modules\\/.*", ".*\\/build\\/.*"], + exclude: ["node_modules", "dist", ".idea", ".git", ".cache"], + }, +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4965dfb2..3546f039 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,6 +65,13 @@ importers: vite: specifier: ^5.1.4 version: 5.1.4(@types/node@20.11.19) + devDependencies: + vitest: + specifier: ^1.3.0 + version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) + vitest-fetch-mock: + specifier: ^0.2.2 + version: 0.2.2(vitest@1.3.0) packages/astro-ghostcms-brutalbyelian: dependencies: @@ -8809,7 +8816,7 @@ packages: strip-literal: 2.0.0 tinybench: 2.6.0 tinypool: 0.8.2 - vite: 5.1.3(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.19) vite-node: 1.3.0(@types/node@20.11.19) why-is-node-running: 2.2.2 transitivePeerDependencies: From 557120f6e662c29e06e11af1fbd00b531156b388 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 08:16:17 -0800 Subject: [PATCH 03/46] New version check system setup --- package.json | 8 +- packages/astro-ghostcms/package.json | 6 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 28 +- .../astro-ghostcms/src/utils/latestVersion.ts | 26 + packages/create-astro-ghostcms/package.json | 12 +- pnpm-lock.yaml | 803 +++++------------- 6 files changed, 271 insertions(+), 612 deletions(-) create mode 100644 packages/astro-ghostcms/src/utils/latestVersion.ts diff --git a/package.json b/package.json index 1b518edb..b82aa01e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:integration": "pnpm --filter astro-ghostcms test", "test:integration:watch": "pnpm --filter astro-ghostcms test:watch", "test:integration:coverage": "pnpm --filter astro-ghostcms test:coverage", - "test:create": "pnpm --filter create-astro-ghostcms test", + "test:create-utility": "pnpm --filter create-astro-ghostcms test", "test:starlight": "pnpm --filter starlight-ghostcms test", "test:starlight:watch": "pnpm --filter starlight-ghostcms test:watch", "test:starlight:coverage": "pnpm --filter starlight-ghostcms test:coverage" @@ -24,8 +24,8 @@ "devDependencies": { "@biomejs/biome": "1.5.3", "@changesets/cli": "^2.27.1", - "vitest": "^1.3.0", - "vitest-fetch-mock": "^0.2.2", - "@vitest/ui": "1.3.0" + "@vitest/ui": "^1.3.1", + "vitest": "^1.3.1", + "vitest-fetch-mock": "^0.2.2" } } diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 64518bcb..7c74ea7e 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -58,7 +58,9 @@ "astro": "^4.4.1" }, "devDependencies": { - "vitest": "^1.3.0", + "@types/fs-extra": "11.0.4", + "@types/node": "20.11.24", + "vitest": "^1.3.1", "vitest-fetch-mock": "^0.2.2" }, "dependencies": { @@ -70,6 +72,8 @@ "@ts-ghost/content-api": "^4.0.12", "astro-integration-kit": "^0.5.0", "astro-robots-txt": "^1.0.0", + "fs-extra": "11.2.0", + "package-json": "10.0.0", "picocolors": "1.0.0", "satori": "^0.10.13", "satori-html": "0.3.2", diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 68a809b1..e4a5f4db 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -4,6 +4,9 @@ import { GhostUserConfigSchema } from "./schemas/userconfig"; import { loadEnv } from "vite"; import { AstroError } from "astro/errors"; import c from "picocolors"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import fse from "fs-extra"; // Import External Integrations import sitemap from "@astrojs/sitemap"; @@ -13,6 +16,7 @@ import robotsTxt from "astro-robots-txt"; import ghostOGImages from "./integrations/satoriog" import ghostRSS from "./integrations/rssfeed" import ghostThemeProvider from "./integrations/themeprovider" +import latestVersion from "./utils/latestVersion"; // Load environment variables const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); @@ -154,16 +158,32 @@ export default defineIntegration({ }, "astro:config:done": ({ logger }) => { - const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.green('Config')}`); + const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.green('CONFIG')}`); GhostLogger.info(c.bold(c.green('Integration Setup & Configuration Complete'))) }, - "astro:server:start": ({ logger }) => { + "astro:server:start": async ({ logger }) => { const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('DEV'))}`); - GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Deveopment mode'))) + const GhostUpdateLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('VERSION CHECK'))}`); + const verbose = options.fullConsoleLogs; + + // Start the DEV server + GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Deveopment mode 🚀'))) + + // Check for updates + const currentNPMVersion = await latestVersion("@matthiesenxyz/astro-ghostcms"); + const packageJson = await fse.readJson(path.resolve(fileURLToPath(import.meta.url), "../../package.json")); + const localVersion = packageJson.version; + + if (currentNPMVersion !== localVersion) { + GhostUpdateLogger.warn(`\n${c.bgYellow(c.bold(c.black(" There is a new version of Astro-GhostCMS available! ")))}\n${c.bold(c.white(" Current Installed Version: ")) + c.bold(c.red(`${localVersion} `))} \n ${c.bold(c.white("New Available Version: "))} ${c.green(currentNPMVersion)} \n ${c.bold(c.white("Please consider updating to the latest version by running: "))} ${c.bold(c.green("npm i @matthiesenxyz/astro-ghostcms@latest"))} \n`) + } else { + GhostUpdateLogger.info(c.bold(c.green(`Astro-GhostCMS is up to date! v${localVersion}`))) + } + }, "astro:build:done": ({ logger }) => { const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('BUILD'))}`); - GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Production mode'))) + GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Production mode 🚀'))) } } } diff --git a/packages/astro-ghostcms/src/utils/latestVersion.ts b/packages/astro-ghostcms/src/utils/latestVersion.ts new file mode 100644 index 00000000..f117b9b1 --- /dev/null +++ b/packages/astro-ghostcms/src/utils/latestVersion.ts @@ -0,0 +1,26 @@ +import packageJson from "package-json"; + +export type Options = { + /** + A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag). + */ + readonly version?: string; +}; + +/** +Get the latest version of an npm package. + +@example +``` +console.log(await latestVersion('ava')); +//=> '0.18.0' +``` +*/ +export default async function latestVersion( + packageName: string, + options?: Options, +) { + const { version } = await packageJson(packageName.toLowerCase(), options); + + return version; +} \ No newline at end of file diff --git a/packages/create-astro-ghostcms/package.json b/packages/create-astro-ghostcms/package.json index 02538d4d..0e125b70 100644 --- a/packages/create-astro-ghostcms/package.json +++ b/packages/create-astro-ghostcms/package.json @@ -46,17 +46,7 @@ "@types/gunzip-maybe": "^1.4.0", "@types/node": "^20.11.19", "@types/tar-fs": "^2.0.1", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "eslint-import-resolver-node": "^0.3.7", - "eslint-import-resolver-typescript": "^3.5.3", - "prettier": "^3.2.5", - "typescript": "^5.3.3", - "vitest": "^1.3.0", - "vite": "^5.1.3", - "vite-tsconfig-paths": "^4.2.2" + "typescript": "^5.3.3" }, "publishConfig": { "access": "public" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3546f039..650bc7de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,14 +15,14 @@ importers: specifier: ^2.27.1 version: 2.27.1 '@vitest/ui': - specifier: 1.3.0 - version: 1.3.0(vitest@1.3.0) + specifier: ^1.3.1 + version: 1.3.1(vitest@1.3.1) vitest: - specifier: ^1.3.0 - version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) + specifier: ^1.3.1 + version: 1.3.1(@vitest/ui@1.3.1) vitest-fetch-mock: specifier: ^0.2.2 - version: 0.2.2(vitest@1.3.0) + version: 0.2.2(vitest@1.3.1) packages/astro-ghostcms: dependencies: @@ -46,13 +46,19 @@ importers: version: 6.0.0 astro: specifier: ^4.4.1 - version: 4.4.9 + version: 4.4.9(@types/node@20.11.24) astro-integration-kit: specifier: ^0.5.0 version: 0.5.0(astro@4.4.9) astro-robots-txt: specifier: ^1.0.0 version: 1.0.0 + fs-extra: + specifier: 11.2.0 + version: 11.2.0 + package-json: + specifier: 10.0.0 + version: 10.0.0 picocolors: specifier: 1.0.0 version: 1.0.0 @@ -64,14 +70,20 @@ importers: version: 0.3.2 vite: specifier: ^5.1.4 - version: 5.1.4(@types/node@20.11.19) + version: 5.1.4(@types/node@20.11.24) devDependencies: + '@types/fs-extra': + specifier: 11.0.4 + version: 11.0.4 + '@types/node': + specifier: 20.11.24 + version: 20.11.24 vitest: - specifier: ^1.3.0 - version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) + specifier: ^1.3.1 + version: 1.3.1(@types/node@20.11.24)(@vitest/ui@1.3.1) vitest-fetch-mock: specifier: ^0.2.2 - version: 0.2.2(vitest@1.3.0) + version: 0.2.2(vitest@1.3.1) packages/astro-ghostcms-brutalbyelian: dependencies: @@ -86,7 +98,7 @@ importers: version: 1.1.8 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: 3.2.9(typescript@5.3.3) + version: 3.2.9(sass@1.71.0)(typescript@5.3.3) '@matthiesenxyz/astro-ghostcms-rendercontent': specifier: ^0.0.7 version: link:../astro-ghostcms-rendercontent @@ -98,7 +110,7 @@ importers: version: 0.58.5 astro: specifier: ^4.2.0 - version: 4.3.7(typescript@5.3.3) + version: 4.3.7(sass@1.71.0)(typescript@5.3.3) astro-font: specifier: ^0.0.77 version: 0.0.77 @@ -144,13 +156,13 @@ importers: version: 5.0.16 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: 3.2.9(typescript@5.3.3) + version: 3.2.9(sass@1.71.0)(typescript@5.3.3) '@tailwindcss/typography': specifier: ^0.5.10 version: 0.5.10(tailwindcss@3.4.1) astro: specifier: ^4.2.1 - version: 4.3.7(typescript@5.3.3) + version: 4.3.7(sass@1.71.0)(typescript@5.3.3) astro-navbar: specifier: ^2.3.1 version: 2.3.1 @@ -172,7 +184,7 @@ importers: devDependencies: astro: specifier: 4.4.0 - version: 4.4.0(typescript@5.3.3) + version: 4.4.0(sass@1.71.0)(typescript@5.3.3) packages/astro-ghostcms-theme-default: dependencies: @@ -226,39 +238,9 @@ importers: '@types/tar-fs': specifier: ^2.0.1 version: 2.0.4 - '@typescript-eslint/eslint-plugin': - specifier: ^7.0.1 - version: 7.0.1(@typescript-eslint/parser@7.0.1)(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/parser': - specifier: ^7.0.1 - version: 7.0.1(eslint@8.56.0)(typescript@5.3.3) - eslint: - specifier: ^8.56.0 - version: 8.56.0 - eslint-config-prettier: - specifier: ^9.1.0 - version: 9.1.0(eslint@8.56.0) - eslint-import-resolver-node: - specifier: ^0.3.7 - version: 0.3.9 - eslint-import-resolver-typescript: - specifier: ^3.5.3 - version: 3.6.1(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.56.0) - prettier: - specifier: ^3.2.5 - version: 3.2.5 typescript: specifier: ^5.3.3 version: 5.3.3 - vite: - specifier: ^5.1.3 - version: 5.1.3(@types/node@20.11.19) - vite-tsconfig-paths: - specifier: ^4.2.2 - version: 4.3.1(typescript@5.3.3)(vite@5.1.3) - vitest: - specifier: ^1.3.0 - version: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) packages/starlight-ghostcms: dependencies: @@ -270,10 +252,10 @@ importers: version: 5.1.2 vite: specifier: ^5.1.2 - version: 5.1.3(@types/node@20.11.19) + version: 5.1.3 vite-tsconfig-paths: specifier: ^4.2.2 - version: 4.3.1(typescript@5.3.3)(vite@5.1.3) + version: 4.3.1(vite@5.1.3) devDependencies: '@astrojs/starlight': specifier: ^0.19.0 @@ -283,10 +265,10 @@ importers: version: link:../tsconfig astro: specifier: ^4.4.0 - version: 4.4.0(typescript@5.3.3) + version: 4.4.0(sass@1.71.0)(typescript@5.3.3) vitest: specifier: ^1.2.2 - version: 1.2.2(@vitest/ui@1.3.0) + version: 1.2.2(@vitest/ui@1.3.1) vitest-fetch-mock: specifier: ^0.2.2 version: 0.2.2(vitest@1.2.2) @@ -309,7 +291,7 @@ importers: version: 0.58.5(vite@5.1.4) astro: specifier: ^4.4.0 - version: 4.4.0(typescript@5.3.3) + version: 4.4.0(sass@1.71.0)(typescript@5.3.3) tailwindcss: specifier: ^3.3.5 version: 3.4.1 @@ -334,7 +316,7 @@ importers: version: link:../../packages/starlight-ghostcms astro: specifier: ^4.4.0 - version: 4.4.0(typescript@5.3.3) + version: 4.4.0(sass@1.71.0)(typescript@5.3.3) sharp: specifier: ^0.32.5 version: 0.32.6 @@ -453,7 +435,7 @@ packages: '@astrojs/markdown-remark': 4.2.1 '@mdx-js/mdx': 3.0.1 acorn: 8.11.3 - astro: 4.4.0(typescript@5.3.3) + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) es-module-lexer: 1.4.1 estree-util-visit: 2.0.0 github-slugger: 2.0.0 @@ -498,7 +480,7 @@ packages: '@pagefind/default-ui': 1.0.4 '@types/hast': 3.0.4 '@types/mdast': 4.0.3 - astro: 4.4.0(typescript@5.3.3) + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) astro-expressive-code: 0.32.4(astro@4.4.0) bcp-47: 2.1.0 hast-util-select: 6.0.2 @@ -521,7 +503,7 @@ packages: astro: ^3.0.0 || ^4.0.0 tailwindcss: ^3.0.24 dependencies: - astro: 4.3.7(typescript@5.3.3) + astro: 4.3.7(sass@1.71.0)(typescript@5.3.3) autoprefixer: 10.4.17(postcss@8.4.35) postcss: 8.4.35 postcss-load-config: 4.0.2(postcss@8.4.35) @@ -536,7 +518,7 @@ packages: astro: ^3.0.0 || ^4.0.0 tailwindcss: ^3.0.24 dependencies: - astro: 4.4.0(typescript@5.3.3) + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) autoprefixer: 10.4.17(postcss@8.4.35) postcss: 8.4.35 postcss-load-config: 4.0.2(postcss@8.4.35) @@ -1529,7 +1511,7 @@ packages: astro: ^4.2.1 dependencies: '@matthiesenxyz/astro-ghostcms': 3.2.9(sass@1.71.0)(typescript@5.3.3) - astro: 4.4.0(typescript@5.3.3) + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) astro-font: 0.0.77 sass: 1.71.0 transitivePeerDependencies: @@ -1572,35 +1554,6 @@ packages: - typescript dev: false - /@matthiesenxyz/astro-ghostcms@3.2.9(typescript@5.3.3): - resolution: {integrity: sha512-LuMXWwo8/AozHKLuu9okjmDqZWSRuJ+Pt2ggZv/gMQrfD4CLIucS4UMl2YQviU1QpguY46j7SP9x0BoIAhFBeA==} - dependencies: - '@astrojs/rss': 4.0.5 - '@astrojs/sitemap': 3.0.5 - '@matthiesenxyz/astro-ghostcms-theme-default': 0.1.13(astro@4.4.0)(typescript@5.3.3) - '@resvg/resvg-js': 2.6.0 - '@ts-ghost/core-api': 5.1.2 - astro: 4.4.0(typescript@5.3.3) - astro-robots-txt: 1.0.0 - fs-extra: 11.2.0 - package-json: 9.0.0 - satori: 0.10.13 - satori-html: 0.3.2 - vite: 5.1.4(@types/node@20.11.19) - vite-tsconfig-paths: 4.3.1(typescript@5.3.3)(vite@5.1.4) - zod: 3.22.4 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - typescript - dev: false - /@mdx-js/mdx@3.0.1: resolution: {integrity: sha512-eIQ4QTrOWyL3LWEe/bu6Taqzq2HQvHcyTMaOrI95P2/LmJE7AsfPfgJGuFLPVqBUE1BC1rik3VIhU+s9u72arA==} dependencies: @@ -2060,13 +2013,13 @@ packages: resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 20.11.19 + '@types/node': 20.11.24 dev: true /@types/gunzip-maybe@1.4.2: resolution: {integrity: sha512-2uqXZg1jTCKE1Pjbab8qb74+f2+i9h/jz8rQ+jRR+zaNJF75zWwrpbX8/TjF4m56m3KFOg9umHdCJ074KwiVxg==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 dev: true /@types/hast@2.3.10: @@ -2083,18 +2036,10 @@ packages: resolution: {integrity: sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==} dev: false - /@types/json-schema@7.0.15: - resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - dev: true - - /@types/json5@0.0.29: - resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} - dev: true - /@types/jsonfile@6.1.4: resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 dev: true /@types/mdast@4.0.3: @@ -2126,6 +2071,12 @@ packages: resolution: {integrity: sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==} dependencies: undici-types: 5.26.5 + dev: true + + /@types/node@20.11.24: + resolution: {integrity: sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==} + dependencies: + undici-types: 5.26.5 /@types/normalize-package-data@2.4.4: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -2136,7 +2087,7 @@ packages: /@types/sax@1.2.7: resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 /@types/semver@7.5.7: resolution: {integrity: sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==} @@ -2144,14 +2095,14 @@ packages: /@types/tar-fs@2.0.4: resolution: {integrity: sha512-ipPec0CjTmVDWE+QKr9cTmIIoTl7dFG/yARCM5MqK8i6CNLIG1P8x4kwDsOQY1ChZOZjH0wO9nvfgBvWl4R3kA==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 '@types/tar-stream': 3.1.3 dev: true /@types/tar-stream@3.1.3: resolution: {integrity: sha512-Zbnx4wpkWBMBSu5CytMbrT5ZpMiF55qgM+EpHzR4yIDu7mv52cej8hTkOc6K+LzpkOAbxwn/m7j3iO+/l42YkQ==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 dev: true /@types/unist@2.0.10: @@ -2160,35 +2111,6 @@ packages: /@types/unist@3.0.2: resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} - /@typescript-eslint/eslint-plugin@7.0.1(@typescript-eslint/parser@7.0.1)(eslint@8.56.0)(typescript@5.3.3): - resolution: {integrity: sha512-OLvgeBv3vXlnnJGIAgCLYKjgMEU+wBGj07MQ/nxAaON+3mLzX7mJbhRYrVGiVvFiXtwFlkcBa/TtmglHy0UbzQ==} - engines: {node: ^16.0.0 || >=18.0.0} - peerDependencies: - '@typescript-eslint/parser': ^7.0.0 - eslint: ^8.56.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/scope-manager': 7.0.1 - '@typescript-eslint/type-utils': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/utils': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/visitor-keys': 7.0.1 - debug: 4.3.4 - eslint: 8.56.0 - graphemer: 1.4.0 - ignore: 5.3.1 - natural-compare: 1.4.0 - semver: 7.6.0 - ts-api-utils: 1.2.1(typescript@5.3.3) - typescript: 5.3.3 - transitivePeerDependencies: - - supports-color - dev: true - /@typescript-eslint/parser@7.0.1(eslint@8.56.0)(typescript@5.3.3): resolution: {integrity: sha512-8GcRRZNzaHxKzBPU3tKtFNing571/GwPBeCvmAUw0yBtfE2XVd0zFKJIMSWkHJcPQi0ekxjIts6L/rrZq5cxGQ==} engines: {node: ^16.0.0 || >=18.0.0} @@ -2226,26 +2148,6 @@ packages: '@typescript-eslint/visitor-keys': 7.0.1 dev: true - /@typescript-eslint/type-utils@7.0.1(eslint@8.56.0)(typescript@5.3.3): - resolution: {integrity: sha512-YtT9UcstTG5Yqy4xtLiClm1ZpM/pWVGFnkAa90UfdkkZsR1eP2mR/1jbHeYp8Ay1l1JHPyGvoUYR6o3On5Nhmw==} - engines: {node: ^16.0.0 || >=18.0.0} - peerDependencies: - eslint: ^8.56.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/typescript-estree': 7.0.1(typescript@5.3.3) - '@typescript-eslint/utils': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - debug: 4.3.4 - eslint: 8.56.0 - ts-api-utils: 1.2.1(typescript@5.3.3) - typescript: 5.3.3 - transitivePeerDependencies: - - supports-color - dev: true - /@typescript-eslint/types@5.62.0: resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2278,25 +2180,6 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@7.0.1(eslint@8.56.0)(typescript@5.3.3): - resolution: {integrity: sha512-oe4his30JgPbnv+9Vef1h48jm0S6ft4mNwi9wj7bX10joGn07QRfqIqFHoMiajrtoU88cIhXf8ahwgrcbNLgPA==} - engines: {node: ^16.0.0 || >=18.0.0} - peerDependencies: - eslint: ^8.56.0 - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0) - '@types/json-schema': 7.0.15 - '@types/semver': 7.5.7 - '@typescript-eslint/scope-manager': 7.0.1 - '@typescript-eslint/types': 7.0.1 - '@typescript-eslint/typescript-estree': 7.0.1(typescript@5.3.3) - eslint: 8.56.0 - semver: 7.6.0 - transitivePeerDependencies: - - supports-color - - typescript - dev: true - /@typescript-eslint/visitor-keys@5.62.0: resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2327,7 +2210,7 @@ packages: '@unocss/core': 0.58.5 '@unocss/reset': 0.58.5 '@unocss/vite': 0.58.5(vite@5.1.4) - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - rollup @@ -2502,7 +2385,7 @@ packages: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.7 - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - rollup @@ -2514,11 +2397,11 @@ packages: chai: 4.4.1 dev: true - /@vitest/expect@1.3.0: - resolution: {integrity: sha512-7bWt0vBTZj08B+Ikv70AnLRicohYwFgzNjFqo9SxxqHHxSlUJGSXmCRORhOnRMisiUryKMdvsi1n27Bc6jL9DQ==} + /@vitest/expect@1.3.1: + resolution: {integrity: sha512-xofQFwIzfdmLLlHa6ag0dPV8YsnKOCP1KdAeVVh34vSjN2dcUiXYCD9htu/9eM7t8Xln4v03U9HLxLpPlsXdZw==} dependencies: - '@vitest/spy': 1.3.0 - '@vitest/utils': 1.3.0 + '@vitest/spy': 1.3.1 + '@vitest/utils': 1.3.1 chai: 4.4.1 dev: true @@ -2530,10 +2413,10 @@ packages: pathe: 1.1.2 dev: true - /@vitest/runner@1.3.0: - resolution: {integrity: sha512-1Jb15Vo/Oy7mwZ5bXi7zbgszsdIBNjc4IqP8Jpr/8RdBC4nF1CTzIAn2dxYvpF1nGSseeL39lfLQ2uvs5u1Y9A==} + /@vitest/runner@1.3.1: + resolution: {integrity: sha512-5FzF9c3jG/z5bgCnjr8j9LNq/9OxV2uEBAITOXfoe3rdZJTdO7jzThth7FXv/6b+kdY65tpRQB7WaKhNZwX+Kg==} dependencies: - '@vitest/utils': 1.3.0 + '@vitest/utils': 1.3.1 p-limit: 5.0.0 pathe: 1.1.2 dev: true @@ -2546,8 +2429,8 @@ packages: pretty-format: 29.7.0 dev: true - /@vitest/snapshot@1.3.0: - resolution: {integrity: sha512-swmktcviVVPYx9U4SEQXLV6AEY51Y6bZ14jA2yo6TgMxQ3h+ZYiO0YhAHGJNp0ohCFbPAis1R9kK0cvN6lDPQA==} + /@vitest/snapshot@1.3.1: + resolution: {integrity: sha512-EF++BZbt6RZmOlE3SuTPu/NfwBF6q4ABS37HHXzs2LUVPBLx2QoY/K0fKpRChSo8eLiuxcbCVfqKgx/dplCDuQ==} dependencies: magic-string: 0.30.7 pathe: 1.1.2 @@ -2560,25 +2443,25 @@ packages: tinyspy: 2.2.1 dev: true - /@vitest/spy@1.3.0: - resolution: {integrity: sha512-AkCU0ThZunMvblDpPKgjIi025UxR8V7MZ/g/EwmAGpjIujLVV2X6rGYGmxE2D4FJbAy0/ijdROHMWa2M/6JVMw==} + /@vitest/spy@1.3.1: + resolution: {integrity: sha512-xAcW+S099ylC9VLU7eZfdT9myV67Nor9w9zhf0mGCYJSO+zM2839tOeROTdikOi/8Qeusffvxb/MyBSOja1Uig==} dependencies: tinyspy: 2.2.1 dev: true - /@vitest/ui@1.3.0(vitest@1.3.0): - resolution: {integrity: sha512-gDGEBUddrPOJvF4e0nIeKBz1whiDthBxBB0OUAbUqnY0HxJwqlKg9R257Sxoeh1Q7ZDSzc7qY96n4hrEPy1NaQ==} + /@vitest/ui@1.3.1(vitest@1.3.1): + resolution: {integrity: sha512-2UrFLJ62c/eJGPHcclstMKlAR7E1WB1ITe1isuowEPJJHi3HfqofvsUqQ1cGrEF7kitG1DJuwURUA3HLDtQkXA==} peerDependencies: - vitest: 1.3.0 + vitest: 1.3.1 dependencies: - '@vitest/utils': 1.3.0 + '@vitest/utils': 1.3.1 fast-glob: 3.3.2 fflate: 0.8.2 flatted: 3.2.9 pathe: 1.1.2 picocolors: 1.0.0 sirv: 2.0.4 - vitest: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) + vitest: 1.3.1(@vitest/ui@1.3.1) dev: true /@vitest/utils@1.2.2: @@ -2590,8 +2473,8 @@ packages: pretty-format: 29.7.0 dev: true - /@vitest/utils@1.3.0: - resolution: {integrity: sha512-/LibEY/fkaXQufi4GDlQZhikQsPO2entBKtfuyIpr1jV4DpaeasqkeHjhdOhU24vSHshcSuEyVlWdzvv2XmYCw==} + /@vitest/utils@1.3.1: + resolution: {integrity: sha512-d3Waie/299qqRyHTm2DjADeTaNdNSVsnwHPWrs20JMpjh6eiVq7ggggweO8rc4arhf6rRkWuHKwvxGvejUXZZQ==} dependencies: diff-sequences: 29.6.3 estree-walker: 3.0.3 @@ -2787,28 +2670,6 @@ packages: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - /array.prototype.filter@1.0.3: - resolution: {integrity: sha512-VizNcj/RGJiUyQBgzwxzE5oHdeuXY5hSbbmKMlphj1cy1Vl7Pn2asCGbSrru6hSQjmCzqTBPVWAF/whmEOVHbw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - es-abstract: 1.22.4 - es-array-method-boxes-properly: 1.0.0 - is-string: 1.0.7 - dev: true - - /array.prototype.findlastindex@1.2.4: - resolution: {integrity: sha512-hzvSHUshSpCflDR1QMUBLHGHP1VIEBegT4pix9H/Z92Xw3ySoy6c2qh7lJWTJnRJ8JCZ9bJNCgTyYaJGcJu6xQ==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - es-abstract: 1.22.4 - es-errors: 1.3.0 - es-shim-unscopables: 1.0.2 - dev: true - /array.prototype.flat@1.3.2: resolution: {integrity: sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==} engines: {node: '>= 0.4'} @@ -2879,7 +2740,7 @@ packages: peerDependencies: astro: ^3.3.0 || ^4.0.0-beta dependencies: - astro: 4.4.0(typescript@5.3.3) + astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) hast-util-to-html: 8.0.4 remark-expressive-code: 0.32.4 @@ -2911,7 +2772,7 @@ packages: vue: optional: true dependencies: - astro: 4.4.9 + astro: 4.4.9(@types/node@20.11.24) pathe: 1.1.2 dev: false @@ -3020,90 +2881,6 @@ packages: - typescript dev: false - /astro@4.3.7(typescript@5.3.3): - resolution: {integrity: sha512-spdl+Ae6WZjQ0w8VBPq8ulN1hdN0m4EWvKG7ecgHjPQIHidMnzWJoZLEFEeKASqCGB1fDibqr7RDHoHkhZbp2Q==} - engines: {node: '>=18.14.1', npm: '>=6.14.0'} - hasBin: true - dependencies: - '@astrojs/compiler': 2.5.3 - '@astrojs/internal-helpers': 0.2.1 - '@astrojs/markdown-remark': 4.2.1 - '@astrojs/telemetry': 3.0.4 - '@babel/core': 7.23.9 - '@babel/generator': 7.23.6 - '@babel/parser': 7.23.9 - '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.9) - '@babel/traverse': 7.23.9 - '@babel/types': 7.23.9 - '@types/babel__core': 7.20.5 - acorn: 8.11.3 - aria-query: 5.3.0 - axobject-query: 4.0.0 - boxen: 7.1.1 - chokidar: 3.6.0 - ci-info: 4.0.0 - clsx: 2.1.0 - common-ancestor-path: 1.0.1 - cookie: 0.6.0 - cssesc: 3.0.0 - debug: 4.3.4 - deterministic-object-hash: 2.0.2 - devalue: 4.3.2 - diff: 5.2.0 - dlv: 1.1.3 - dset: 3.1.3 - es-module-lexer: 1.4.1 - esbuild: 0.19.12 - estree-walker: 3.0.3 - execa: 8.0.1 - fast-glob: 3.3.2 - flattie: 1.1.0 - github-slugger: 2.0.0 - gray-matter: 4.0.3 - html-escaper: 3.0.3 - http-cache-semantics: 4.1.1 - js-yaml: 4.1.0 - kleur: 4.1.5 - magic-string: 0.30.7 - mdast-util-to-hast: 13.0.2 - mime: 3.0.0 - ora: 7.0.1 - p-limit: 5.0.0 - p-queue: 8.0.1 - path-to-regexp: 6.2.1 - preferred-pm: 3.1.2 - probe-image-size: 7.2.3 - prompts: 2.4.2 - rehype: 13.0.1 - resolve: 1.22.8 - semver: 7.6.0 - server-destroy: 1.0.1 - shikiji: 0.9.19 - shikiji-core: 0.9.19 - string-width: 7.1.0 - strip-ansi: 7.1.0 - tsconfck: 3.0.2(typescript@5.3.3) - unist-util-visit: 5.0.0 - vfile: 6.0.1 - vite: 5.1.4(@types/node@20.11.19) - vitefu: 0.2.5(vite@5.1.4) - which-pm: 2.1.1 - yargs-parser: 21.1.1 - zod: 3.22.4 - optionalDependencies: - sharp: 0.32.6 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - typescript - dev: false - /astro@4.4.0(sass@1.71.0)(typescript@5.3.3): resolution: {integrity: sha512-JAsMrm1Z6W4Iqg9Q7LW/6lCXrqa4jndEOlR/yu7NGNP0BrPwSM8i4+yzya6hxgsNvyyVK8ywthaNhFmqd8Z+cg==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} @@ -3186,92 +2963,8 @@ packages: - supports-color - terser - typescript - dev: false - /astro@4.4.0(typescript@5.3.3): - resolution: {integrity: sha512-JAsMrm1Z6W4Iqg9Q7LW/6lCXrqa4jndEOlR/yu7NGNP0BrPwSM8i4+yzya6hxgsNvyyVK8ywthaNhFmqd8Z+cg==} - engines: {node: '>=18.14.1', npm: '>=6.14.0'} - hasBin: true - dependencies: - '@astrojs/compiler': 2.5.3 - '@astrojs/internal-helpers': 0.2.1 - '@astrojs/markdown-remark': 4.2.1 - '@astrojs/telemetry': 3.0.4 - '@babel/core': 7.23.9 - '@babel/generator': 7.23.6 - '@babel/parser': 7.23.9 - '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.9) - '@babel/traverse': 7.23.9 - '@babel/types': 7.23.9 - '@medv/finder': 3.1.0 - '@types/babel__core': 7.20.5 - acorn: 8.11.3 - aria-query: 5.3.0 - axobject-query: 4.0.0 - boxen: 7.1.1 - chokidar: 3.6.0 - ci-info: 4.0.0 - clsx: 2.1.0 - common-ancestor-path: 1.0.1 - cookie: 0.6.0 - cssesc: 3.0.0 - debug: 4.3.4 - deterministic-object-hash: 2.0.2 - devalue: 4.3.2 - diff: 5.2.0 - dlv: 1.1.3 - dset: 3.1.3 - es-module-lexer: 1.4.1 - esbuild: 0.19.12 - estree-walker: 3.0.3 - execa: 8.0.1 - fast-glob: 3.3.2 - flattie: 1.1.0 - github-slugger: 2.0.0 - gray-matter: 4.0.3 - html-escaper: 3.0.3 - http-cache-semantics: 4.1.1 - js-yaml: 4.1.0 - kleur: 4.1.5 - magic-string: 0.30.7 - mdast-util-to-hast: 13.0.2 - mime: 3.0.0 - ora: 7.0.1 - p-limit: 5.0.0 - p-queue: 8.0.1 - path-to-regexp: 6.2.1 - preferred-pm: 3.1.2 - prompts: 2.4.2 - rehype: 13.0.1 - resolve: 1.22.8 - semver: 7.6.0 - server-destroy: 1.0.1 - shikiji: 0.9.19 - shikiji-core: 0.9.19 - string-width: 7.1.0 - strip-ansi: 7.1.0 - tsconfck: 3.0.2(typescript@5.3.3) - unist-util-visit: 5.0.0 - vfile: 6.0.1 - vite: 5.1.4(@types/node@20.11.19) - vitefu: 0.2.5(vite@5.1.4) - which-pm: 2.1.1 - yargs-parser: 21.1.1 - zod: 3.22.4 - optionalDependencies: - sharp: 0.32.6 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - typescript - - /astro@4.4.9: + /astro@4.4.9(@types/node@20.11.24): resolution: {integrity: sha512-FTWhzKjao7rHHiF/CqPqPS18AFad+fmUcYUFhWWIsYETHcc9g0IIIiv6cHXUE7g6mEZf7ycAa+WdboeEHUhraQ==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} hasBin: true @@ -3335,7 +3028,7 @@ packages: tsconfck: 3.0.2(typescript@5.3.3) unist-util-visit: 5.0.0 vfile: 6.0.1 - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.24) vitefu: 0.2.5(vite@5.1.4) which-pm: 2.1.1 yargs-parser: 21.1.1 @@ -3907,6 +3600,7 @@ packages: optional: true dependencies: ms: 2.1.3 + dev: false /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -4041,13 +3735,6 @@ packages: /dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} - /doctrine@2.1.0: - resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} - engines: {node: '>=0.10.0'} - dependencies: - esutils: 2.0.3 - dev: true - /doctrine@3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} engines: {node: '>=6.0.0'} @@ -4089,14 +3776,6 @@ packages: dependencies: once: 1.4.0 - /enhanced-resolve@5.15.0: - resolution: {integrity: sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==} - engines: {node: '>=10.13.0'} - dependencies: - graceful-fs: 4.2.11 - tapable: 2.2.1 - dev: true - /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -4159,10 +3838,6 @@ packages: unbox-primitive: 1.0.2 which-typed-array: 1.1.14 - /es-array-method-boxes-properly@1.0.0: - resolution: {integrity: sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==} - dev: true - /es-define-property@1.0.0: resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} engines: {node: '>= 0.4'} @@ -4279,78 +3954,6 @@ packages: semver: 7.6.0 dev: true - /eslint-config-prettier@9.1.0(eslint@8.56.0): - resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==} - hasBin: true - peerDependencies: - eslint: '>=7.0.0' - dependencies: - eslint: 8.56.0 - dev: true - - /eslint-import-resolver-node@0.3.9: - resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} - dependencies: - debug: 3.2.7 - is-core-module: 2.13.1 - resolve: 1.22.8 - transitivePeerDependencies: - - supports-color - dev: true - - /eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.56.0): - resolution: {integrity: sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==} - engines: {node: ^14.18.0 || >=16.0.0} - peerDependencies: - eslint: '*' - eslint-plugin-import: '*' - dependencies: - debug: 4.3.4 - enhanced-resolve: 5.15.0 - eslint: 8.56.0 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) - fast-glob: 3.3.2 - get-tsconfig: 4.7.2 - is-core-module: 2.13.1 - is-glob: 4.0.3 - transitivePeerDependencies: - - '@typescript-eslint/parser' - - eslint-import-resolver-node - - eslint-import-resolver-webpack - - supports-color - dev: true - - /eslint-module-utils@2.8.0(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0): - resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint: '*' - eslint-import-resolver-node: '*' - eslint-import-resolver-typescript: '*' - eslint-import-resolver-webpack: '*' - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - eslint: - optional: true - eslint-import-resolver-node: - optional: true - eslint-import-resolver-typescript: - optional: true - eslint-import-resolver-webpack: - optional: true - dependencies: - '@typescript-eslint/parser': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - debug: 3.2.7 - eslint: 8.56.0 - eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.56.0) - transitivePeerDependencies: - - supports-color - dev: true - /eslint-plugin-astro@0.31.4(eslint@8.56.0): resolution: {integrity: sha512-aU1KYSo7TdnSTBenyAWuRFB07lVUe0/6u9cltC2ZCx0QgcfC+HP7e87OkmvoKh+RZuaSsVgLG4zCOI8LZ6nS/Q==} engines: {node: ^14.18.0 || >=16.0.0} @@ -4369,41 +3972,6 @@ packages: - supports-color dev: true - /eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0): - resolution: {integrity: sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - dependencies: - '@typescript-eslint/parser': 7.0.1(eslint@8.56.0)(typescript@5.3.3) - array-includes: 3.1.7 - array.prototype.findlastindex: 1.2.4 - array.prototype.flat: 1.3.2 - array.prototype.flatmap: 1.3.2 - debug: 3.2.7 - doctrine: 2.1.0 - eslint: 8.56.0 - eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@7.0.1)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) - hasown: 2.0.1 - is-core-module: 2.13.1 - is-glob: 4.0.3 - minimatch: 3.1.2 - object.fromentries: 2.0.7 - object.groupby: 1.0.2 - object.values: 1.1.7 - semver: 6.3.1 - tsconfig-paths: 3.15.0 - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - dev: true - /eslint-plugin-jsx-a11y@6.8.0(eslint@8.56.0): resolution: {integrity: sha512-Hdh937BS3KdwwbBaKd5+PLCOmYY6U4f2h9Z2ktwtNKvIdIEu137rjYbcb9ApSbVJfWxANNuiKTD/9tOKjK9qOA==} engines: {node: '>=4.0'} @@ -4848,12 +4416,6 @@ packages: es-errors: 1.3.0 get-intrinsic: 1.2.4 - /get-tsconfig@4.7.2: - resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} - dependencies: - resolve-pkg-maps: 1.0.0 - dev: true - /github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} requiresBuild: true @@ -4926,6 +4488,7 @@ packages: /globrex@0.1.2: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + dev: false /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} @@ -5298,7 +4861,6 @@ packages: /immutable@4.3.5: resolution: {integrity: sha512-8eabxkth9gZatlwl5TBuJnCsoTADlL6ftEr7A4qgdaTsPyreilDSnUk57SO+jfKcNtxPa22U5KK6DSeAYhpBJw==} - dev: false /import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -5653,13 +5215,6 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true - /json5@1.0.2: - resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} - hasBin: true - dependencies: - minimist: 1.2.8 - dev: true - /json5@2.2.3: resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} engines: {node: '>=6'} @@ -5714,6 +5269,11 @@ packages: /kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} + /ky@1.2.2: + resolution: {integrity: sha512-gYA2QOI3uIaImJPJjaBbLCdvKHzwxsuB03s7PjrXmoO6tcn6k53rwYoSRgqrmVsEV6wFFegOXDVjABxFZ0aRSg==} + engines: {node: '>=18'} + dev: false + /language-subtag-registry@0.3.22: resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==} dev: true @@ -6485,6 +6045,7 @@ packages: /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + dev: false /muggle-string@0.4.1: resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} @@ -6642,16 +6203,6 @@ packages: es-abstract: 1.22.4 dev: true - /object.groupby@1.0.2: - resolution: {integrity: sha512-bzBq58S+x+uo0VjurFT0UktpKHOZmv4/xePiOA1nbB9pMqpGK7rUPNgf+1YC+7mE+0HzhTMqNUuCqvKhj6FnBw==} - dependencies: - array.prototype.filter: 1.0.3 - call-bind: 1.0.7 - define-properties: 1.2.1 - es-abstract: 1.22.4 - es-errors: 1.3.0 - dev: true - /object.values@1.1.7: resolution: {integrity: sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==} engines: {node: '>= 0.4'} @@ -6778,6 +6329,16 @@ packages: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} + /package-json@10.0.0: + resolution: {integrity: sha512-w34pqp733w35nElGG6eH1OnDnHEWud4uxruQ2nKzY/Uy0uOJmWFdjDcAC+xAD4goVuBZStwaAEBS21BANv83HQ==} + engines: {node: '>=18'} + dependencies: + ky: 1.2.2 + registry-auth-token: 5.0.2 + registry-url: 6.0.1 + semver: 7.6.0 + dev: false + /package-json@9.0.0: resolution: {integrity: sha512-vGgkl6BR8SJUcOdhj49/17fqYpBYr4fAlbBA3we5j548q114UAafKBEVck85Kk2HKhVzWGIAVybFpJ9LesJY6w==} engines: {node: '>=18'} @@ -7365,10 +6926,6 @@ packages: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} - /resolve-pkg-maps@1.0.0: - resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - dev: true - /resolve@1.22.8: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true @@ -7502,7 +7059,6 @@ packages: chokidar: 3.6.0 immutable: 4.3.5 source-map-js: 1.0.2 - dev: false /satori-html@0.3.2: resolution: {integrity: sha512-wjTh14iqADFKDK80e51/98MplTGfxz2RmIzh0GqShlf4a67+BooLywF17TvJPD6phO0Hxm7Mf1N5LtRYvdkYRA==} @@ -7986,11 +7542,6 @@ packages: - ts-node dev: false - /tapable@2.2.1: - resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} - engines: {node: '>=6'} - dev: true - /tar-fs@2.1.1: resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==} requiresBuild: true @@ -8127,15 +7678,6 @@ packages: dependencies: typescript: 5.3.3 - /tsconfig-paths@3.15.0: - resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} - dependencies: - '@types/json5': 0.0.29 - json5: 1.0.2 - minimist: 1.2.8 - strip-bom: 3.0.0 - dev: true - /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: true @@ -8423,7 +7965,7 @@ packages: '@unocss/transformer-directives': 0.58.5 '@unocss/transformer-variant-group': 0.58.5 '@unocss/vite': 0.58.5(vite@5.1.4) - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - postcss - rollup @@ -8509,7 +8051,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - '@types/node' - less @@ -8521,8 +8063,8 @@ packages: - terser dev: true - /vite-node@1.3.0(@types/node@20.11.19): - resolution: {integrity: sha512-D/oiDVBw75XMnjAXne/4feCkCEwcbr2SU1bjAhCcfI5Bq3VoOHji8/wCPAfUkDIeohJ5nSZ39fNxM3dNZ6OBOA==} + /vite-node@1.3.1: + resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true dependencies: @@ -8530,7 +8072,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - '@types/node' - less @@ -8542,21 +8084,26 @@ packages: - terser dev: true - /vite-tsconfig-paths@4.3.1(typescript@5.3.3)(vite@5.1.3): - resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} - peerDependencies: - vite: '*' - peerDependenciesMeta: - vite: - optional: true + /vite-node@1.3.1(@types/node@20.11.24): + resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true dependencies: + cac: 6.7.14 debug: 4.3.4 - globrex: 0.1.2 - tsconfck: 3.0.2(typescript@5.3.3) - vite: 5.1.3(@types/node@20.11.19) + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.1.4(@types/node@20.11.24) transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss - supports-color - - typescript + - terser + dev: true /vite-tsconfig-paths@4.3.1(typescript@5.3.3)(vite@5.1.4): resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} @@ -8569,13 +8116,30 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 3.0.2(typescript@5.3.3) - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) transitivePeerDependencies: - supports-color - typescript dev: false - /vite@5.1.3(@types/node@20.11.19): + /vite-tsconfig-paths@4.3.1(vite@5.1.3): + resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} + peerDependencies: + vite: '*' + peerDependenciesMeta: + vite: + optional: true + dependencies: + debug: 4.3.4 + globrex: 0.1.2 + tsconfck: 3.0.2(typescript@5.3.3) + vite: 5.1.3 + transitivePeerDependencies: + - supports-color + - typescript + dev: false + + /vite@5.1.3: resolution: {integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -8603,14 +8167,14 @@ packages: terser: optional: true dependencies: - '@types/node': 20.11.19 esbuild: 0.19.12 postcss: 8.4.35 rollup: 4.11.0 optionalDependencies: fsevents: 2.3.3 + dev: false - /vite@5.1.4(@types/node@20.11.19): + /vite@5.1.4(@types/node@20.11.24): resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -8638,7 +8202,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.11.19 + '@types/node': 20.11.24 esbuild: 0.19.12 postcss: 8.4.35 rollup: 4.11.0 @@ -8679,7 +8243,6 @@ packages: sass: 1.71.0 optionalDependencies: fsevents: 2.3.3 - dev: false /vitefu@0.2.5(vite@5.1.4): resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} @@ -8689,7 +8252,7 @@ packages: vite: optional: true dependencies: - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.24) /vitest-fetch-mock@0.2.2(vitest@1.2.2): resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} @@ -8698,24 +8261,24 @@ packages: vitest: '>=0.16.0' dependencies: cross-fetch: 3.1.8 - vitest: 1.2.2(@vitest/ui@1.3.0) + vitest: 1.2.2(@vitest/ui@1.3.1) transitivePeerDependencies: - encoding dev: true - /vitest-fetch-mock@0.2.2(vitest@1.3.0): + /vitest-fetch-mock@0.2.2(vitest@1.3.1): resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} engines: {node: '>=14.14.0'} peerDependencies: vitest: '>=0.16.0' dependencies: cross-fetch: 3.1.8 - vitest: 1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0) + vitest: 1.3.1(@vitest/ui@1.3.1) transitivePeerDependencies: - encoding dev: true - /vitest@1.2.2(@vitest/ui@1.3.0): + /vitest@1.2.2(@vitest/ui@1.3.1): resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -8744,7 +8307,7 @@ packages: '@vitest/runner': 1.2.2 '@vitest/snapshot': 1.2.2 '@vitest/spy': 1.2.2 - '@vitest/ui': 1.3.0(vitest@1.3.0) + '@vitest/ui': 1.3.1(vitest@1.3.1) '@vitest/utils': 1.2.2 acorn-walk: 8.3.2 cac: 6.7.14 @@ -8759,7 +8322,7 @@ packages: strip-literal: 1.3.0 tinybench: 2.6.0 tinypool: 0.8.2 - vite: 5.1.4(@types/node@20.11.19) + vite: 5.1.4(sass@1.71.0) vite-node: 1.2.2 why-is-node-running: 2.2.2 transitivePeerDependencies: @@ -8772,15 +8335,15 @@ packages: - terser dev: true - /vitest@1.3.0(@types/node@20.11.19)(@vitest/ui@1.3.0): - resolution: {integrity: sha512-V9qb276J1jjSx9xb75T2VoYXdO1UKi+qfflY7V7w93jzX7oA/+RtYE6TcifxksxsZvygSSMwu2Uw6di7yqDMwg==} + /vitest@1.3.1(@types/node@20.11.24)(@vitest/ui@1.3.1): + resolution: {integrity: sha512-/1QJqXs8YbCrfv/GPQ05wAZf2eakUPLPa18vkJAKE7RXOKfVHqMZZ1WlTjiwl6Gcn65M5vpNUB6EFLnEdRdEXQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 1.3.0 - '@vitest/ui': 1.3.0 + '@vitest/browser': 1.3.1 + '@vitest/ui': 1.3.1 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -8797,13 +8360,13 @@ packages: jsdom: optional: true dependencies: - '@types/node': 20.11.19 - '@vitest/expect': 1.3.0 - '@vitest/runner': 1.3.0 - '@vitest/snapshot': 1.3.0 - '@vitest/spy': 1.3.0 - '@vitest/ui': 1.3.0(vitest@1.3.0) - '@vitest/utils': 1.3.0 + '@types/node': 20.11.24 + '@vitest/expect': 1.3.1 + '@vitest/runner': 1.3.1 + '@vitest/snapshot': 1.3.1 + '@vitest/spy': 1.3.1 + '@vitest/ui': 1.3.1(vitest@1.3.1) + '@vitest/utils': 1.3.1 acorn-walk: 8.3.2 chai: 4.4.1 debug: 4.3.4 @@ -8816,8 +8379,64 @@ packages: strip-literal: 2.0.0 tinybench: 2.6.0 tinypool: 0.8.2 - vite: 5.1.4(@types/node@20.11.19) - vite-node: 1.3.0(@types/node@20.11.19) + vite: 5.1.4(@types/node@20.11.24) + vite-node: 1.3.1(@types/node@20.11.24) + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /vitest@1.3.1(@vitest/ui@1.3.1): + resolution: {integrity: sha512-/1QJqXs8YbCrfv/GPQ05wAZf2eakUPLPa18vkJAKE7RXOKfVHqMZZ1WlTjiwl6Gcn65M5vpNUB6EFLnEdRdEXQ==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': 1.3.1 + '@vitest/ui': 1.3.1 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@vitest/expect': 1.3.1 + '@vitest/runner': 1.3.1 + '@vitest/snapshot': 1.3.1 + '@vitest/spy': 1.3.1 + '@vitest/ui': 1.3.1(vitest@1.3.1) + '@vitest/utils': 1.3.1 + acorn-walk: 8.3.2 + chai: 4.4.1 + debug: 4.3.4 + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.7 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 2.0.0 + tinybench: 2.6.0 + tinypool: 0.8.2 + vite: 5.1.4(sass@1.71.0) + vite-node: 1.3.1 why-is-node-running: 2.2.2 transitivePeerDependencies: - less From 2901524b8ae3e70ba57759d8e9bb41e6a5b13a3f Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 08:17:27 -0800 Subject: [PATCH 04/46] move import --- packages/astro-ghostcms/src/astro-ghostcms.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index e4a5f4db..e310ff4c 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -7,6 +7,7 @@ import c from "picocolors"; import path from "node:path"; import { fileURLToPath } from "node:url"; import fse from "fs-extra"; +import latestVersion from "./utils/latestVersion"; // Import External Integrations import sitemap from "@astrojs/sitemap"; @@ -16,7 +17,6 @@ import robotsTxt from "astro-robots-txt"; import ghostOGImages from "./integrations/satoriog" import ghostRSS from "./integrations/rssfeed" import ghostThemeProvider from "./integrations/themeprovider" -import latestVersion from "./utils/latestVersion"; // Load environment variables const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); From 319271435517cca57d8c659e5f3909180fc9e8fc Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 08:43:44 -0800 Subject: [PATCH 05/46] code cleanup and fixes --- packages/astro-ghostcms/package.json | 4 +++- packages/astro-ghostcms/src/api/ghostAPI.ts | 18 +++++++++++------- packages/astro-ghostcms/src/astro-ghostcms.ts | 3 +-- packages/astro-ghostcms/tsconfig.json | 6 ++++++ packages/astro-ghostcms/virtual.d.ts | 4 ++++ 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 packages/astro-ghostcms/tsconfig.json create mode 100644 packages/astro-ghostcms/virtual.d.ts diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 7c74ea7e..e1834af9 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -38,7 +38,9 @@ }, "files": [ "src", - "index.ts" + "CHANGELOG.md", + "LICENSE", + "README.md" ], "exports": { ".": "./src/index.ts", diff --git a/packages/astro-ghostcms/src/api/ghostAPI.ts b/packages/astro-ghostcms/src/api/ghostAPI.ts index 0d031775..a0803513 100644 --- a/packages/astro-ghostcms/src/api/ghostAPI.ts +++ b/packages/astro-ghostcms/src/api/ghostAPI.ts @@ -4,18 +4,22 @@ import type { Page, Post } from "../schemas/api"; // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; -import config from "virtual:@matthiesenxyz/astro-ghostcms/config"; - -const CONF_URL = config.ghostURL; - -const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( +const { + CONTENT_API_KEY, + CONTENT_API_URL +} = loadEnv( "all", process.cwd(), "CONTENT_", ); -const ghostApiKey = CONTENT_API_KEY; -const ghostUrl = CONF_URL ? CONF_URL : CONTENT_API_URL; +// LOAD CONFIG +import config from "virtual:@matthiesenxyz/astro-ghostcms/config"; +const CONF_URL = config.ghostURL; + +// SETUP GHOST API +const ghostApiKey = CONTENT_API_KEY || ""; +const ghostUrl = CONF_URL || CONTENT_API_URL || ""; const version = "v5.0"; const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version); diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index e310ff4c..5f2888e7 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -75,7 +75,7 @@ export default defineIntegration({ if ( !options.disableThemeProvider ) { addIntegration( ghostThemeProvider({ - theme: options.ThemeProvider.theme, + theme: options.ThemeProvider?.theme, verbose }) ) @@ -164,7 +164,6 @@ export default defineIntegration({ "astro:server:start": async ({ logger }) => { const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('DEV'))}`); const GhostUpdateLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('VERSION CHECK'))}`); - const verbose = options.fullConsoleLogs; // Start the DEV server GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Deveopment mode 🚀'))) diff --git a/packages/astro-ghostcms/tsconfig.json b/packages/astro-ghostcms/tsconfig.json new file mode 100644 index 00000000..0ce5c9fc --- /dev/null +++ b/packages/astro-ghostcms/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "astro/tsconfigs/strictest", + "compilerOptions": { + "jsx": "preserve" + } + } \ No newline at end of file diff --git a/packages/astro-ghostcms/virtual.d.ts b/packages/astro-ghostcms/virtual.d.ts new file mode 100644 index 00000000..6695d996 --- /dev/null +++ b/packages/astro-ghostcms/virtual.d.ts @@ -0,0 +1,4 @@ +declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { + const Config: import("./src/schemas/userconfig").GhostUserConfig; + export default Config; +} \ No newline at end of file From 5f7ac8e4a67693a697b87ee453b05f88320c1c8a Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 08:49:15 -0800 Subject: [PATCH 06/46] massive lint --- .changeset/config.json | 2 +- .../astro-ghostcms/src/api/ghostAPI.test.ts | 12 +- packages/astro-ghostcms/src/api/ghostAPI.ts | 7 +- packages/astro-ghostcms/src/api/index.ts | 2 +- packages/astro-ghostcms/src/api/invariant.ts | 2 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 423 +++++++++++------- packages/astro-ghostcms/src/index.ts | 2 +- .../rssfeed/astro-ghostcms-rss.ts | 59 +-- .../rssfeed/routes/rss-style.xsl.ts | 2 +- .../integrations/rssfeed/routes/rss.xml.ts | 2 +- .../satoriog/astro-ghostcms-satoriog.ts | 70 +-- .../satoriog/routes/[slug].png.ts | 9 +- .../satoriog/routes/author/[slug].png.ts | 2 +- .../satoriog/routes/authors.png.ts | 9 +- .../integrations/satoriog/routes/index.png.ts | 9 +- .../satoriog/routes/tag/[slug].png.ts | 2 +- .../integrations/satoriog/routes/tags.png.ts | 9 +- .../src/integrations/satoriog/satori.ts | 2 +- .../src/integrations/satoriog/types.d.ts | 2 +- .../astro-ghostcms-themeprovider.ts | 78 ++-- .../src/schemas/api/authors.test.ts | 276 ++++++------ .../astro-ghostcms/src/schemas/api/authors.ts | 2 +- .../astro-ghostcms/src/schemas/api/index.ts | 2 +- .../astro-ghostcms/src/schemas/api/pages.ts | 2 +- .../src/schemas/api/posts.test.ts | 96 ++-- .../astro-ghostcms/src/schemas/api/posts.ts | 2 +- .../src/schemas/api/settings.test.ts | 61 +-- .../src/schemas/api/settings.ts | 2 +- .../astro-ghostcms/src/schemas/api/socials.ts | 2 +- .../astro-ghostcms/src/schemas/api/tags.ts | 2 +- .../astro-ghostcms/src/schemas/api/tiers.ts | 2 +- .../src/schemas/userconfig.test.ts | 92 ++-- .../astro-ghostcms/src/schemas/userconfig.ts | 17 +- .../astro-ghostcms/src/utils/latestVersion.ts | 2 +- packages/astro-ghostcms/virtual.d.ts | 6 +- packages/astro-ghostcms/vitest.config.ts | 4 +- .../src/templates/brutal/astro.config.mjs | 8 +- .../src/templates/brutal/src/env.d.ts | 8 +- .../src/templates/brutal/uno.config.ts | 6 +- packages/starlight-ghostcms/index.ts | 199 ++++---- .../src/integrations/vite.ts | 34 +- .../src/overrides/sidebartypes.ts | 26 +- .../starlight-ghostcms/src/routes/rss.xml.ts | 8 +- .../starlight-ghostcms/src/schemas/config.ts | 78 ++-- .../src/utils/api/api-functions.ts | 62 ++- packages/starlight-ghostcms/src/utils/page.ts | 26 +- packages/starlight-ghostcms/starlight.d.ts | 6 +- packages/starlight-ghostcms/virtual.d.ts | 6 +- playgrounds/astro-playground/astro.config.mjs | 2 +- .../.vscode/extensions.json | 6 +- .../starlight-playground/.vscode/launch.json | 20 +- .../starlight-playground/astro.config.mjs | 24 +- .../src/content/config.ts | 6 +- playgrounds/starlight-playground/src/env.d.ts | 2 +- 54 files changed, 1005 insertions(+), 797 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index db35bc78..23dc2706 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["playground","starlight-playground"] + "ignore": ["playground", "starlight-playground"] } diff --git a/packages/astro-ghostcms/src/api/ghostAPI.test.ts b/packages/astro-ghostcms/src/api/ghostAPI.test.ts index c4599fc1..a7b190f8 100644 --- a/packages/astro-ghostcms/src/api/ghostAPI.test.ts +++ b/packages/astro-ghostcms/src/api/ghostAPI.test.ts @@ -5,7 +5,11 @@ import { TSGhostContentAPI } from "@ts-ghost/content-api"; describe("content-api", () => { let api: TSGhostContentAPI; beforeEach(() => { - api = new TSGhostContentAPI("https://ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + api = new TSGhostContentAPI( + "https://ghost.org", + "59d4bf56c73c04a18c867dc3ba", + "v5.0", + ); }); test("content-api", () => { @@ -14,7 +18,11 @@ describe("content-api", () => { test("content-api shouldn't instantiate with an incorrect url", () => { assert.throws(() => { - const api = new TSGhostContentAPI("ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + const api = new TSGhostContentAPI( + "ghost.org", + "59d4bf56c73c04a18c867dc3ba", + "v5.0", + ); api.settings; }); }); diff --git a/packages/astro-ghostcms/src/api/ghostAPI.ts b/packages/astro-ghostcms/src/api/ghostAPI.ts index a0803513..ce46cecc 100644 --- a/packages/astro-ghostcms/src/api/ghostAPI.ts +++ b/packages/astro-ghostcms/src/api/ghostAPI.ts @@ -4,10 +4,7 @@ import type { Page, Post } from "../schemas/api"; // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; -const { - CONTENT_API_KEY, - CONTENT_API_URL -} = loadEnv( +const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "all", process.cwd(), "CONTENT_", @@ -125,4 +122,4 @@ export const getFeaturedPosts = async () => { posts: results.data, meta: results.meta, }; -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/api/index.ts b/packages/astro-ghostcms/src/api/index.ts index 808a2451..b229791e 100644 --- a/packages/astro-ghostcms/src/api/index.ts +++ b/packages/astro-ghostcms/src/api/index.ts @@ -1,2 +1,2 @@ export * from "./ghostAPI"; -export * from "./invariant"; \ No newline at end of file +export * from "./invariant"; diff --git a/packages/astro-ghostcms/src/api/invariant.ts b/packages/astro-ghostcms/src/api/invariant.ts index d17d926a..8d37a1ba 100644 --- a/packages/astro-ghostcms/src/api/invariant.ts +++ b/packages/astro-ghostcms/src/api/invariant.ts @@ -44,4 +44,4 @@ export function invariant( const value: string = provided ? `${prefix}: ${provided}` : prefix; throw new Error(value); -} \ No newline at end of file +} diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 5f2888e7..c976ca1f 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,22 +1,22 @@ -import { createResolver, defineIntegration } from "astro-integration-kit"; -import { corePlugins } from "astro-integration-kit/plugins"; -import { GhostUserConfigSchema } from "./schemas/userconfig"; -import { loadEnv } from "vite"; -import { AstroError } from "astro/errors"; -import c from "picocolors"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import { createResolver, defineIntegration } from "astro-integration-kit"; +import { corePlugins } from "astro-integration-kit/plugins"; +import { AstroError } from "astro/errors"; import fse from "fs-extra"; +import c from "picocolors"; +import { loadEnv } from "vite"; +import { GhostUserConfigSchema } from "./schemas/userconfig"; import latestVersion from "./utils/latestVersion"; // Import External Integrations import sitemap from "@astrojs/sitemap"; import robotsTxt from "astro-robots-txt"; +import ghostRSS from "./integrations/rssfeed"; // Import Internal Integrations -import ghostOGImages from "./integrations/satoriog" -import ghostRSS from "./integrations/rssfeed" -import ghostThemeProvider from "./integrations/themeprovider" +import ghostOGImages from "./integrations/satoriog"; +import ghostThemeProvider from "./integrations/themeprovider"; // Load environment variables const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); @@ -24,166 +24,283 @@ const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project * @see https://astro-ghostcms.xyz for the most up-to-date documentation! -*/ + */ export default defineIntegration({ - name: "@matthiesenxyz/astro-ghostcms", - optionsSchema: GhostUserConfigSchema, - plugins: [...corePlugins], - setup({ options, name }) { - const { resolve } = createResolver(import.meta.url); + name: "@matthiesenxyz/astro-ghostcms", + optionsSchema: GhostUserConfigSchema, + plugins: [...corePlugins], + setup({ options, name }) { + const { resolve } = createResolver(import.meta.url); - return { - "astro:config:setup": ({ - watchIntegration, - hasIntegration, - addIntegration, - addVirtualImports, - addDts, - injectRoute, - logger - }) => { - const GhostLogger = logger.fork(c.bold(c.blue('👻 Astro-GhostCMS'))); - const GhostENVLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('ENV Check')}`); - const GhostIntegrationLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Integrations')}`); - const GhostRouteLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Router')}`); + return { + "astro:config:setup": ({ + watchIntegration, + hasIntegration, + addIntegration, + addVirtualImports, + addDts, + injectRoute, + logger, + }) => { + const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); + const GhostENVLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "ENV Check", + )}`, + ); + const GhostIntegrationLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "Integrations", + )}`, + ); + const GhostRouteLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "Router", + )}`, + ); - watchIntegration(resolve()) - GhostLogger.info('Initializing @matthiesenxyz/astro-ghostcms...') + watchIntegration(resolve()); + GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms..."); - const verbose = options.fullConsoleLogs; + const verbose = options.fullConsoleLogs; - // Check for GhostCMS environment variables - GhostENVLogger.info(c.bold(c.yellow('Checking for GhostCMS environment variables & user configuration'))) - if (ENV.CONTENT_API_KEY === undefined) { - GhostENVLogger.error(c.bgRed(c.bold(c.white('CONTENT_API_KEY is not set in environment variables')))) - throw new AstroError(`${name} CONTENT_API_KEY is not set in environment variables`) - } + // Check for GhostCMS environment variables + GhostENVLogger.info( + c.bold( + c.yellow( + "Checking for GhostCMS environment variables & user configuration", + ), + ), + ); + if (ENV.CONTENT_API_KEY === undefined) { + GhostENVLogger.error( + c.bgRed( + c.bold( + c.white("CONTENT_API_KEY is not set in environment variables"), + ), + ), + ); + throw new AstroError( + `${name} CONTENT_API_KEY is not set in environment variables`, + ); + } - if (options.ghostURL === undefined) { - GhostENVLogger.warn(c.bgYellow(c.bold(c.black('ghostURL is not set in user configuration falling back to environment variable')))) - if (ENV.CONTENT_API_URL === undefined) { - GhostENVLogger.error(c.bgRed(c.bold(c.white('CONTENT_API_URL is not set in environment variables')))) - throw new AstroError(`${name} CONTENT_API_URL is not set in environment variables`) - } - } - GhostENVLogger.info(c.bold(c.green('GhostCMS environment variables are set'))) + if (options.ghostURL === undefined) { + GhostENVLogger.warn( + c.bgYellow( + c.bold( + c.black( + "ghostURL is not set in user configuration falling back to environment variable", + ), + ), + ), + ); + if (ENV.CONTENT_API_URL === undefined) { + GhostENVLogger.error( + c.bgRed( + c.bold( + c.white( + "CONTENT_API_URL is not set in environment variables", + ), + ), + ), + ); + throw new AstroError( + `${name} CONTENT_API_URL is not set in environment variables`, + ); + } + } + GhostENVLogger.info( + c.bold(c.green("GhostCMS environment variables are set")), + ); - // Set up Astro-GhostCMS Integrations - GhostIntegrationLogger.info(c.bold(c.magenta('Configuring Enabled Integrations'))) + // Set up Astro-GhostCMS Integrations + GhostIntegrationLogger.info( + c.bold(c.magenta("Configuring Enabled Integrations")), + ); - // Theme Provider - if ( !options.disableThemeProvider ) { - addIntegration( - ghostThemeProvider({ - theme: options.ThemeProvider?.theme, - verbose - }) - ) - } else { - if (verbose) { - GhostIntegrationLogger.info(c.gray('Theme Provider is disabled')) - } - } + // Theme Provider + if (!options.disableThemeProvider) { + addIntegration( + ghostThemeProvider({ + theme: options.ThemeProvider?.theme, + verbose, + }), + ); + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray("Theme Provider is disabled")); + } + } - // Satori OG Images - if ( options.enableOGImages ) { - addIntegration(ghostOGImages({ verbose })) - } else { - if (verbose) { - GhostIntegrationLogger.info(c.gray('OG Image Provider is disabled')) - } - } + // Satori OG Images + if (options.enableOGImages) { + addIntegration(ghostOGImages({ verbose })); + } else { + if (verbose) { + GhostIntegrationLogger.info( + c.gray("OG Image Provider is disabled"), + ); + } + } - // RSS Feed - if ( options.enableRSSFeed ) { - addIntegration(ghostRSS({ verbose })) - } else { - if (verbose) { - GhostIntegrationLogger.info(c.gray('RSS Feed is disabled')) - } - } + // RSS Feed + if (options.enableRSSFeed) { + addIntegration(ghostRSS({ verbose })); + } else { + if (verbose) { + GhostIntegrationLogger.info(c.gray("RSS Feed is disabled")); + } + } - // @ASTROJS/SITEMAP - if ( !hasIntegration("@astrojs/sitemap") ) { - if (verbose) { - GhostIntegrationLogger.info(c.bold(c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`))) - } - addIntegration(sitemap()) - } else { - if (verbose) { - GhostIntegrationLogger.info(c.gray('@astrojs/sitemap integration already exists, skipping...')) - } - } - // ASTRO-ROBOTS-TXT - if ( !hasIntegration("@astro-robots-txt") ) { - if (verbose) { - GhostIntegrationLogger.info(c.bold(c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`))) - } - addIntegration(robotsTxt()) - } else { - if (verbose) { - GhostIntegrationLogger.info(c.gray('astro-robots-txt integration already exists, skipping...')) - } - } + // @ASTROJS/SITEMAP + if (!hasIntegration("@astrojs/sitemap")) { + if (verbose) { + GhostIntegrationLogger.info( + c.bold( + c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`), + ), + ); + } + addIntegration(sitemap()); + } else { + if (verbose) { + GhostIntegrationLogger.info( + c.gray( + "@astrojs/sitemap integration already exists, skipping...", + ), + ); + } + } + // ASTRO-ROBOTS-TXT + if (!hasIntegration("@astro-robots-txt")) { + if (verbose) { + GhostIntegrationLogger.info( + c.bold( + c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`), + ), + ); + } + addIntegration(robotsTxt()); + } else { + if (verbose) { + GhostIntegrationLogger.info( + c.gray( + "astro-robots-txt integration already exists, skipping...", + ), + ); + } + } - // Set up default 404 page - if ( !options.disableDefault404 ) { - if (verbose) { - GhostRouteLogger.info(c.bold(c.cyan('Setting up default 404 page'))) - } - injectRoute({ - pattern: "/404", - entrypoint: `${name}/404.astro`, - prerender: true - }) - } else { - if (verbose) { - GhostRouteLogger.info(c.gray('Default 404 page is disabled, Skipping...')) - } - } + // Set up default 404 page + if (!options.disableDefault404) { + if (verbose) { + GhostRouteLogger.info( + c.bold(c.cyan("Setting up default 404 page")), + ); + } + injectRoute({ + pattern: "/404", + entrypoint: `${name}/404.astro`, + prerender: true, + }); + } else { + if (verbose) { + GhostRouteLogger.info( + c.gray("Default 404 page is disabled, Skipping..."), + ); + } + } - // Add virtual imports for user configuration - addVirtualImports({ - 'virtual:@matthiesenxyz/astro-ghostcms/config': `export default ${JSON.stringify(options)}`, - }) + // Add virtual imports for user configuration + addVirtualImports({ + "virtual:@matthiesenxyz/astro-ghostcms/config": `export default ${JSON.stringify( + options, + )}`, + }); - // Add types for user configuration - addDts({ - name: "@matthiesenxyz/astro-ghostcms/config", - content: `declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { + // Add types for user configuration + addDts({ + name: "@matthiesenxyz/astro-ghostcms/config", + content: `declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { const Config: import("../schemas/userconfig").GhostUserConfig; export default Config; - }` - }) + }`, + }); + }, + "astro:config:done": ({ logger }) => { + const GhostLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green( + "CONFIG", + )}`, + ); + GhostLogger.info( + c.bold(c.green("Integration Setup & Configuration Complete")), + ); + }, + "astro:server:start": async ({ logger }) => { + const GhostLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( + c.green("DEV"), + )}`, + ); + const GhostUpdateLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( + c.green("VERSION CHECK"), + )}`, + ); - }, - "astro:config:done": ({ logger }) => { - const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.green('CONFIG')}`); - GhostLogger.info(c.bold(c.green('Integration Setup & Configuration Complete'))) - }, - "astro:server:start": async ({ logger }) => { - const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('DEV'))}`); - const GhostUpdateLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('VERSION CHECK'))}`); + // Start the DEV server + GhostLogger.info( + c.bold(c.magenta("Running Astro-GhostCMS in Deveopment mode 🚀")), + ); - // Start the DEV server - GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Deveopment mode 🚀'))) + // Check for updates + const currentNPMVersion = await latestVersion( + "@matthiesenxyz/astro-ghostcms", + ); + const packageJson = await fse.readJson( + path.resolve(fileURLToPath(import.meta.url), "../../package.json"), + ); + const localVersion = packageJson.version; - // Check for updates - const currentNPMVersion = await latestVersion("@matthiesenxyz/astro-ghostcms"); - const packageJson = await fse.readJson(path.resolve(fileURLToPath(import.meta.url), "../../package.json")); - const localVersion = packageJson.version; - - if (currentNPMVersion !== localVersion) { - GhostUpdateLogger.warn(`\n${c.bgYellow(c.bold(c.black(" There is a new version of Astro-GhostCMS available! ")))}\n${c.bold(c.white(" Current Installed Version: ")) + c.bold(c.red(`${localVersion} `))} \n ${c.bold(c.white("New Available Version: "))} ${c.green(currentNPMVersion)} \n ${c.bold(c.white("Please consider updating to the latest version by running: "))} ${c.bold(c.green("npm i @matthiesenxyz/astro-ghostcms@latest"))} \n`) - } else { - GhostUpdateLogger.info(c.bold(c.green(`Astro-GhostCMS is up to date! v${localVersion}`))) - } - - }, - "astro:build:done": ({ logger }) => { - const GhostLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.bold(c.green('BUILD'))}`); - GhostLogger.info(c.bold(c.magenta('Running Astro-GhostCMS in Production mode 🚀'))) - } - } - } -}) \ No newline at end of file + if (currentNPMVersion !== localVersion) { + GhostUpdateLogger.warn( + `\n${c.bgYellow( + c.bold( + c.black( + " There is a new version of Astro-GhostCMS available! ", + ), + ), + )}\n${ + c.bold(c.white(" Current Installed Version: ")) + + c.bold(c.red(`${localVersion} `)) + } \n ${c.bold(c.white("New Available Version: "))} ${c.green( + currentNPMVersion, + )} \n ${c.bold( + c.white( + "Please consider updating to the latest version by running: ", + ), + )} ${c.bold( + c.green("npm i @matthiesenxyz/astro-ghostcms@latest"), + )} \n`, + ); + } else { + GhostUpdateLogger.info( + c.bold(c.green(`Astro-GhostCMS is up to date! v${localVersion}`)), + ); + } + }, + "astro:build:done": ({ logger }) => { + const GhostLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( + c.green("BUILD"), + )}`, + ); + GhostLogger.info( + c.bold(c.magenta("Running Astro-GhostCMS in Production mode 🚀")), + ); + }, + }; + }, +}); diff --git a/packages/astro-ghostcms/src/index.ts b/packages/astro-ghostcms/src/index.ts index 58acee04..99bd4e64 100644 --- a/packages/astro-ghostcms/src/index.ts +++ b/packages/astro-ghostcms/src/index.ts @@ -1,3 +1,3 @@ -import astroghostcms from './astro-ghostcms.js'; +import astroghostcms from "./astro-ghostcms.js"; export default astroghostcms; diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts index d64cd556..476d9bba 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -1,29 +1,29 @@ import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; -import c from "picocolors"; import { z } from "astro/zod"; +import c from "picocolors"; export default defineIntegration({ - name: "@matthiesenxyz/astro-ghostcms-rss", - optionsSchema: z.object({ + name: "@matthiesenxyz/astro-ghostcms-rss", + optionsSchema: z.object({ verbose: z.boolean().optional().default(false), - }), - plugins: [...corePlugins], - setup({ options }) { - const { resolve } = createResolver(import.meta.url); + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); - return { - "astro:config:setup": ({ - watchIntegration, - injectRoute, - logger - }) => { - watchIntegration(resolve()) - const RSSLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('RSSGenerator')}`); + return { + "astro:config:setup": ({ watchIntegration, injectRoute, logger }) => { + watchIntegration(resolve()); + const RSSLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "RSSGenerator", + )}`, + ); - RSSLogger.info(c.bold(c.magenta('RSS Feed Enabled. Setting up...'))) + RSSLogger.info(c.bold(c.magenta("RSS Feed Enabled. Setting up..."))); - const rssRoute = "@matthiesenxyz/astro-ghostcms/rss-routes" + const rssRoute = "@matthiesenxyz/astro-ghostcms/rss-routes"; injectRoute({ pattern: "/rss-style.xsl", @@ -34,15 +34,18 @@ export default defineIntegration({ pattern: "/rss.xml", entrypoint: `${rssRoute}/rss.xml.ts`, }); + }, + "astro:config:done": ({ logger }) => { + const RSSLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "RSSGenerator", + )}`, + ); - }, - "astro:config:done": ({ logger }) => { - const RSSLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('RSSGenerator')}`); - - if (options.verbose) { - RSSLogger.info(c.bold(c.green('RSS Feed Setup Complete'))) - } - } - } - } -}) \ No newline at end of file + if (options.verbose) { + RSSLogger.info(c.bold(c.green("RSS Feed Setup Complete"))); + } + }, + }; + }, +}); diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts index 61dd87ed..f5282760 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss-style.xsl.ts @@ -78,4 +78,4 @@ export async function GET() { }, }, ); -} \ No newline at end of file +} diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts index 81c7df11..860f5e2c 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/routes/rss.xml.ts @@ -24,4 +24,4 @@ export async function GET({ site }: APIContext) { author: post.primary_author?.name, })), }); -} \ No newline at end of file +} diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts index ded0418e..a3981ca7 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -1,31 +1,37 @@ import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; -import c from "picocolors"; import { z } from "astro/zod"; +import c from "picocolors"; export default defineIntegration({ - name: "@matthiesenxyz/astro-ghostcms-satoriog", - optionsSchema: z.object({ + name: "@matthiesenxyz/astro-ghostcms-satoriog", + optionsSchema: z.object({ verbose: z.boolean().optional().default(false), - }), - plugins: [...corePlugins], - setup({ options }) { - const { resolve } = createResolver(import.meta.url); + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); - return { - "astro:config:setup": ({ - watchIntegration, - updateConfig, - injectRoute, - logger - }) => { - watchIntegration(resolve()) + return { + "astro:config:setup": ({ + watchIntegration, + updateConfig, + injectRoute, + logger, + }) => { + watchIntegration(resolve()); - const SatoriLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('SatoriOG')}`); + const SatoriLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "SatoriOG", + )}`, + ); - SatoriLogger.info(c.bold(c.magenta('OG Image Integration Enabled. Setting up...'))) + SatoriLogger.info( + c.bold(c.magenta("OG Image Integration Enabled. Setting up...")), + ); - const pkgname = "@matthiesenxyz/astro-ghostcms/open-graph" + const pkgname = "@matthiesenxyz/astro-ghostcms/open-graph"; injectRoute({ pattern: "/open-graph/[slug].png", @@ -57,17 +63,23 @@ export default defineIntegration({ entrypoint: `${pkgname}/tag/[slug].png.ts`, }); - updateConfig({ - vite: { optimizeDeps: { exclude: ["@resvg/resvg-js"] } } - }) - }, - "astro:config:done": ({ logger }) => { - const SatoriLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('SatoriOG')}`); + updateConfig({ + vite: { optimizeDeps: { exclude: ["@resvg/resvg-js"] } }, + }); + }, + "astro:config:done": ({ logger }) => { + const SatoriLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "SatoriOG", + )}`, + ); if (options.verbose) { - SatoriLogger.info(c.bold(c.green('OG Image Integration Setup Complete'))) + SatoriLogger.info( + c.bold(c.green("OG Image Integration Setup Complete")), + ); } - } - } - } -}) \ No newline at end of file + }, + }; + }, +}); diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts index f0bf0d9f..fdc1c53c 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/[slug].png.ts @@ -5,12 +5,7 @@ import type { InferGetStaticPropsType, } from "astro"; import { html } from "satori-html"; -import { - getAllPages, - getAllPosts, - getSettings, - invariant, -} from "../../../api"; +import { getAllPages, getAllPosts, getSettings, invariant } from "../../../api"; import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { @@ -67,4 +62,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts index 142b8f27..2853b8ea 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/author/[slug].png.ts @@ -61,4 +61,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts index 3eb0d239..36166085 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/authors.png.ts @@ -5,12 +5,7 @@ import type { InferGetStaticPropsType, } from "astro"; import { html } from "satori-html"; -import { - getAllPages, - getAllPosts, - getSettings, - invariant, -} from "../../../api"; +import { getAllPages, getAllPosts, getSettings, invariant } from "../../../api"; import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { @@ -65,4 +60,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts index 01dd5dc7..8574fd49 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/index.png.ts @@ -5,12 +5,7 @@ import type { InferGetStaticPropsType, } from "astro"; import { html } from "satori-html"; -import { - getAllPages, - getAllPosts, - getSettings, - invariant, -} from "../../../api"; +import { getAllPages, getAllPosts, getSettings, invariant } from "../../../api"; import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { @@ -65,4 +60,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts index 26176c25..9076f235 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts @@ -68,4 +68,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts index 6d562052..5123a0c9 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/tags.png.ts @@ -5,12 +5,7 @@ import type { InferGetStaticPropsType, } from "astro"; import { html } from "satori-html"; -import { - getAllPages, - getAllPosts, - getSettings, - invariant, -} from "../../../api"; +import { getAllPages, getAllPosts, getSettings, invariant } from "../../../api"; import satoriOG from "../satori"; export const getStaticPaths: GetStaticPaths = async () => { @@ -65,4 +60,4 @@ export const GET: APIRoute = async ({ props, site }) => { ], }, }); -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/integrations/satoriog/satori.ts b/packages/astro-ghostcms/src/integrations/satoriog/satori.ts index 6b38a1a7..80ced69d 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/satori.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/satori.ts @@ -52,4 +52,4 @@ export function getOgImagePath(inputFilename = "index"): string { filename = "index"; } return `./open-graph/${filename}.png`; -} \ No newline at end of file +} diff --git a/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts b/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts index b4c24795..9e613b6f 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/types.d.ts @@ -17,4 +17,4 @@ export type ToImageOptions = { | ResvgOptions | ((params: { width: number; height: number }) => ResvgOptions); }; -export type ToResponseOptions = ToImageOptions & { response?: ResponseInit }; \ No newline at end of file +export type ToResponseOptions = ToImageOptions & { response?: ResponseInit }; diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts index 17cfc5a3..0712cc3c 100644 --- a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts +++ b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts @@ -4,32 +4,43 @@ import { z } from "astro/zod"; import c from "picocolors"; export default defineIntegration({ - name: "@matthiesenxyz/astro-ghostcms-themeprovider", - optionsSchema: z.object({ - theme: z.string().optional().default("@matthiesenxyz/astro-ghostcms-theme-default"), + name: "@matthiesenxyz/astro-ghostcms-themeprovider", + optionsSchema: z.object({ + theme: z + .string() + .optional() + .default("@matthiesenxyz/astro-ghostcms-theme-default"), verbose: z.boolean().optional().default(false), - }), - plugins: [...corePlugins], - setup({ options }) { - const { resolve } = createResolver(import.meta.url); + }), + plugins: [...corePlugins], + setup({ options }) { + const { resolve } = createResolver(import.meta.url); - return { - "astro:config:setup": ({ - watchIntegration, - injectRoute, - logger - }) => { - watchIntegration(resolve()) + return { + "astro:config:setup": ({ watchIntegration, injectRoute, logger }) => { + watchIntegration(resolve()); - const themeLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Theme Provider')}`); + const themeLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "Theme Provider", + )}`, + ); - themeLogger.info(c.bold(c.magenta('Theme Provider enabled. Setting up...'))) + themeLogger.info( + c.bold(c.magenta("Theme Provider enabled. Setting up...")), + ); - if ( options.verbose) { - if ( options.theme === "@matthiesenxyz/astro-ghostcms-theme-default" ) { - themeLogger.info(c.blue('No theme is set, injecting default theme')) + if (options.verbose) { + if (options.theme === "@matthiesenxyz/astro-ghostcms-theme-default") { + themeLogger.info( + c.blue("No theme is set, injecting default theme"), + ); } else { - themeLogger.info(`${c.bold(c.cyan("Injecting Theme:"))} ${c.bold(c.underline(c.magenta(options.theme)))}`) + themeLogger.info( + `${c.bold(c.cyan("Injecting Theme:"))} ${c.bold( + c.underline(c.magenta(options.theme)), + )}`, + ); } } @@ -38,7 +49,7 @@ export default defineIntegration({ entrypoint: `${options.theme}/index.astro`, }); - injectRoute({ + injectRoute({ pattern: "/[slug]", entrypoint: `${options.theme}/[slug].astro`, }); @@ -66,16 +77,19 @@ export default defineIntegration({ injectRoute({ pattern: "/archives/[...page]", entrypoint: `${options.theme}/archives/[...page].astro`, - }); + }); + }, + "astro:config:done": ({ logger }) => { + const themeLogger = logger.fork( + `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( + "Theme Provider", + )}`, + ); - }, - "astro:config:done": ({ logger }) => { - const themeLogger = logger.fork(`${c.bold(c.blue('👻 Astro-GhostCMS'))}${c.gray("/")}${c.blue('Theme Provider')}`); - - if ( options.verbose ) { - themeLogger.info(c.bold(c.green('Provider Setup Complete'))) + if (options.verbose) { + themeLogger.info(c.bold(c.green("Provider Setup Complete"))); } - } - } - } -}) \ No newline at end of file + }, + }; + }, +}); diff --git a/packages/astro-ghostcms/src/schemas/api/authors.test.ts b/packages/astro-ghostcms/src/schemas/api/authors.test.ts index 9cee527b..7cd4b54e 100644 --- a/packages/astro-ghostcms/src/schemas/api/authors.test.ts +++ b/packages/astro-ghostcms/src/schemas/api/authors.test.ts @@ -1,146 +1,164 @@ -import createFetchMock from "vitest-fetch-mock"; import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; +import createFetchMock from "vitest-fetch-mock"; import { TSGhostContentAPI } from "@ts-ghost/content-api"; const fetchMocker = createFetchMock(vi); describe("authors api .browse() Args Type-safety", () => { - const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; - const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; - const api = new TSGhostContentAPI(url, key, "v5.0"); - test(".browse() params shouldnt accept invalid params", () => { - // @ts-expect-error - shouldnt accept invalid params - const browse = api.authors.browse({ pp: 2 }); - expect(browse.getParams().browseParams).toStrictEqual({}); - }); + const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; + const key = + process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; + const api = new TSGhostContentAPI(url, key, "v5.0"); + test(".browse() params shouldnt accept invalid params", () => { + // @ts-expect-error - shouldnt accept invalid params + const browse = api.authors.browse({ pp: 2 }); + expect(browse.getParams().browseParams).toStrictEqual({}); + }); - test(".browse() 'order' params should ony accept fields values", () => { - // @ts-expect-error - order should ony contain field - expect(() => api.authors.browse({ order: "foo ASC" })).toThrow(); - // valid - expect(api.authors.browse({ order: "name ASC" }).getParams().browseParams).toStrictEqual({ - order: "name ASC", - }); - expect(api.authors.browse({ order: "name ASC,slug DESC" }).getParams().browseParams).toStrictEqual({ - order: "name ASC,slug DESC", - }); - expect( - api.authors.browse({ order: "name ASC,slug DESC,location ASC" }).getParams().browseParams - ).toStrictEqual({ - order: "name ASC,slug DESC,location ASC", - }); - // @ts-expect-error - order should ony contain field (There is a typo in location) - expect(() => api.authors.browse({ order: "name ASC,slug DESC,locaton ASC" })).toThrow(); - }); + test(".browse() 'order' params should ony accept fields values", () => { + // @ts-expect-error - order should ony contain field + expect(() => api.authors.browse({ order: "foo ASC" })).toThrow(); + // valid + expect( + api.authors.browse({ order: "name ASC" }).getParams().browseParams, + ).toStrictEqual({ + order: "name ASC", + }); + expect( + api.authors.browse({ order: "name ASC,slug DESC" }).getParams() + .browseParams, + ).toStrictEqual({ + order: "name ASC,slug DESC", + }); + expect( + api.authors + .browse({ order: "name ASC,slug DESC,location ASC" }) + .getParams().browseParams, + ).toStrictEqual({ + order: "name ASC,slug DESC,location ASC", + }); + // @ts-expect-error - order should ony contain field (There is a typo in location) + expect(() => + api.authors.browse({ order: "name ASC,slug DESC,locaton ASC" }), + ).toThrow(); + }); - test(".browse() 'filter' params should ony accept valid field", () => { - expect(() => - api.authors.browse({ - // @ts-expect-error - order should ony contain field - filter: "foo:bar", - }) - ).toThrow(); - expect( - api.authors - .browse({ - filter: "name:bar", - }) - .getParams().browseParams - ).toStrictEqual({ - filter: "name:bar", - }); - expect( - api.authors - .browse({ - filter: "name:bar+slug:-test", - }) - .getParams().browseParams - ).toStrictEqual({ - filter: "name:bar+slug:-test", - }); - }); + test(".browse() 'filter' params should ony accept valid field", () => { + expect(() => + api.authors.browse({ + // @ts-expect-error - order should ony contain field + filter: "foo:bar", + }), + ).toThrow(); + expect( + api.authors + .browse({ + filter: "name:bar", + }) + .getParams().browseParams, + ).toStrictEqual({ + filter: "name:bar", + }); + expect( + api.authors + .browse({ + filter: "name:bar+slug:-test", + }) + .getParams().browseParams, + ).toStrictEqual({ + filter: "name:bar+slug:-test", + }); + }); - test(".browse 'fields' argument should ony accept valid fields", () => { - expect( - api.authors - .browse() - .fields({ - // @ts-expect-error - order should ony contain field - foo: true, - }) - .getOutputFields() - ).toEqual([]); + test(".browse 'fields' argument should ony accept valid fields", () => { + expect( + api.authors + .browse() + .fields({ + // @ts-expect-error - order should ony contain field + foo: true, + }) + .getOutputFields(), + ).toEqual([]); - expect(api.authors.browse().fields({ location: true }).getOutputFields()).toEqual(["location"]); - expect(api.authors.browse().fields({ name: true, website: true }).getOutputFields()).toEqual([ - "name", - "website", - ]); - }); + expect( + api.authors.browse().fields({ location: true }).getOutputFields(), + ).toEqual(["location"]); + expect( + api.authors + .browse() + .fields({ name: true, website: true }) + .getOutputFields(), + ).toEqual(["name", "website"]); + }); }); describe("authors resource mocked", () => { - let api: TSGhostContentAPI; + let api: TSGhostContentAPI; - beforeEach(() => { - api = new TSGhostContentAPI("https://my-ghost-blog.com", "59d4bf56c73c04a18c867dc3ba", "v5.0"); - fetchMocker.enableMocks(); - }); - afterEach(() => { - vi.restoreAllMocks(); - }); + beforeEach(() => { + api = new TSGhostContentAPI( + "https://my-ghost-blog.com", + "59d4bf56c73c04a18c867dc3ba", + "v5.0", + ); + fetchMocker.enableMocks(); + }); + afterEach(() => { + vi.restoreAllMocks(); + }); - test("aouthors should be fetched correctly", async () => { - const authors = api.authors; - expect(authors).not.toBeUndefined(); - const browseQuery = authors - .browse({ - page: 2, - }) - .fields({ - name: true, - id: true, - }); - expect(browseQuery).not.toBeUndefined(); - expect(browseQuery.getOutputFields()).toStrictEqual(["name", "id"]); + test("aouthors should be fetched correctly", async () => { + const authors = api.authors; + expect(authors).not.toBeUndefined(); + const browseQuery = authors + .browse({ + page: 2, + }) + .fields({ + name: true, + id: true, + }); + expect(browseQuery).not.toBeUndefined(); + expect(browseQuery.getOutputFields()).toStrictEqual(["name", "id"]); - fetchMocker.doMockOnce( - JSON.stringify({ - authors: [ - { - name: "foo", - id: "eaoizdjoa1321123", - }, - ], - meta: { - pagination: { - page: 1, - limit: 15, - pages: 1, - total: 1, - next: null, - prev: null, - }, - }, - }) - ); - const result = await browseQuery.fetch(); - expect(fetchMocker).toHaveBeenCalledTimes(1); - expect(fetchMocker).toHaveBeenCalledWith( - "https://my-ghost-blog.com/ghost/api/content/authors/?page=2&fields=name%2Cid&key=59d4bf56c73c04a18c867dc3ba", - { - headers: { - "Content-Type": "application/json", - "Accept-Version": "v5.0", - }, - } - ); - expect(result).not.toBeUndefined(); - if (result.success) { - expect(result.data.length).toBe(1); - expect(result.data[0].name).toBe("foo"); - expect(result.data[0].id).toBe("eaoizdjoa1321123"); - } - }); -}); \ No newline at end of file + fetchMocker.doMockOnce( + JSON.stringify({ + authors: [ + { + name: "foo", + id: "eaoizdjoa1321123", + }, + ], + meta: { + pagination: { + page: 1, + limit: 15, + pages: 1, + total: 1, + next: null, + prev: null, + }, + }, + }), + ); + const result = await browseQuery.fetch(); + expect(fetchMocker).toHaveBeenCalledTimes(1); + expect(fetchMocker).toHaveBeenCalledWith( + "https://my-ghost-blog.com/ghost/api/content/authors/?page=2&fields=name%2Cid&key=59d4bf56c73c04a18c867dc3ba", + { + headers: { + "Content-Type": "application/json", + "Accept-Version": "v5.0", + }, + }, + ); + expect(result).not.toBeUndefined(); + if (result.success) { + expect(result.data.length).toBe(1); + expect(result.data[0].name).toBe("foo"); + expect(result.data[0].id).toBe("eaoizdjoa1321123"); + } + }); +}); diff --git a/packages/astro-ghostcms/src/schemas/api/authors.ts b/packages/astro-ghostcms/src/schemas/api/authors.ts index ea02b3dc..c5df9eba 100644 --- a/packages/astro-ghostcms/src/schemas/api/authors.ts +++ b/packages/astro-ghostcms/src/schemas/api/authors.ts @@ -34,4 +34,4 @@ export const ghostFetchAuthorsSchema = z.object({ export const authorsIncludeSchema = z.object({ "count.posts": z.literal(true).optional(), }); -export type AuthorsIncludeSchema = z.infer; \ No newline at end of file +export type AuthorsIncludeSchema = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/api/index.ts b/packages/astro-ghostcms/src/schemas/api/index.ts index 09360d62..43c252a2 100644 --- a/packages/astro-ghostcms/src/schemas/api/index.ts +++ b/packages/astro-ghostcms/src/schemas/api/index.ts @@ -4,4 +4,4 @@ export * from "./posts"; export * from "./settings"; export * from "./socials"; export * from "./tags"; -export * from "./tiers"; \ No newline at end of file +export * from "./tiers"; diff --git a/packages/astro-ghostcms/src/schemas/api/pages.ts b/packages/astro-ghostcms/src/schemas/api/pages.ts index ac002aae..c688d91f 100644 --- a/packages/astro-ghostcms/src/schemas/api/pages.ts +++ b/packages/astro-ghostcms/src/schemas/api/pages.ts @@ -52,4 +52,4 @@ export const pagesIncludeSchema = z.object({ authors: z.literal(true).optional(), tags: z.literal(true).optional(), }); -export type PagesIncludeSchema = z.infer; \ No newline at end of file +export type PagesIncludeSchema = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/api/posts.test.ts b/packages/astro-ghostcms/src/schemas/api/posts.test.ts index f682720b..35427607 100644 --- a/packages/astro-ghostcms/src/schemas/api/posts.test.ts +++ b/packages/astro-ghostcms/src/schemas/api/posts.test.ts @@ -4,52 +4,64 @@ import { TSGhostContentAPI } from "@ts-ghost/content-api"; import type { Post } from "./index"; const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; -const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; +const key = + process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; describe("posts api .browse() Args Type-safety", () => { - const api = new TSGhostContentAPI(url, key, "v5.0"); - test(".browse() params shouldnt accept invalid params", () => { - // @ts-expect-error - shouldnt accept invalid params - const browse = api.posts.browse({ pp: 2 }); - expect(browse.getParams().browseParams).toStrictEqual({}); + const api = new TSGhostContentAPI(url, key, "v5.0"); + test(".browse() params shouldnt accept invalid params", () => { + // @ts-expect-error - shouldnt accept invalid params + const browse = api.posts.browse({ pp: 2 }); + expect(browse.getParams().browseParams).toStrictEqual({}); - const outputFields = { - slug: true, - title: true, - // @ts-expect-error - shouldnt accept invalid params - foo: true, - } satisfies { [k in keyof Post]?: true | undefined }; + const outputFields = { + slug: true, + title: true, + // @ts-expect-error - shouldnt accept invalid params + foo: true, + } satisfies { [k in keyof Post]?: true | undefined }; - const test = api.posts - .browse() - // @ts-expect-error - shouldnt accept invalid params - .fields(outputFields); - expect(test.getOutputFields()).toEqual(["slug", "title"]); + const test = api.posts + .browse() + // @ts-expect-error - shouldnt accept invalid params + .fields(outputFields); + expect(test.getOutputFields()).toEqual(["slug", "title"]); - const fields = ["slug", "title", "foo"] as const; - const unknownOriginFields = fields.reduce((acc, k) => { - acc[k as keyof Post] = true; - return acc; - }, {} as { [k in keyof Post]?: true | undefined }); - const result = api.posts.browse().fields(unknownOriginFields); - expect(result.getOutputFields()).toEqual(["slug", "title"]); - }); - test(".browse() params, output fields declare const", () => { - const outputFields = { - slug: true, - title: true, - } satisfies { [k in keyof Post]?: true | undefined }; + const fields = ["slug", "title", "foo"] as const; + const unknownOriginFields = fields.reduce( + (acc, k) => { + acc[k as keyof Post] = true; + return acc; + }, + {} as { [k in keyof Post]?: true | undefined }, + ); + const result = api.posts.browse().fields(unknownOriginFields); + expect(result.getOutputFields()).toEqual(["slug", "title"]); + }); + test(".browse() params, output fields declare const", () => { + const outputFields = { + slug: true, + title: true, + } satisfies { [k in keyof Post]?: true | undefined }; - const test = api.posts.browse().fields(outputFields); - expect(test.getOutputFields()).toEqual(["slug", "title"]); + const test = api.posts.browse().fields(outputFields); + expect(test.getOutputFields()).toEqual(["slug", "title"]); - // @ts-expect-error - shouldnt accept invalid params - expect(() => api.posts.browse({ filter: "slugg:test" })).toThrow(); - // @ts-expect-error - shouldnt accept invalid params - expect(() => api.posts.browse({ filter: "slug:test,foo:-[bar,baz]" })).toThrow(); - expect(api.posts.browse({ filter: "slug:test,tags:-[bar,baz]" })).toBeDefined(); - expect(api.posts.browse({ filter: "slug:test,tags:[bar,baz]" })).toBeDefined(); - // @ts-expect-error - shouldnt accept invalid params - expect(() => api.posts.browse({ filter: "slug:test,food:-[bar,baz]" })).toThrow(); - }); -}); \ No newline at end of file + // @ts-expect-error - shouldnt accept invalid params + expect(() => api.posts.browse({ filter: "slugg:test" })).toThrow(); + // @ts-expect-error - shouldnt accept invalid params + expect(() => + api.posts.browse({ filter: "slug:test,foo:-[bar,baz]" }), + ).toThrow(); + expect( + api.posts.browse({ filter: "slug:test,tags:-[bar,baz]" }), + ).toBeDefined(); + expect( + api.posts.browse({ filter: "slug:test,tags:[bar,baz]" }), + ).toBeDefined(); + // @ts-expect-error - shouldnt accept invalid params + expect(() => + api.posts.browse({ filter: "slug:test,food:-[bar,baz]" }), + ).toThrow(); + }); +}); diff --git a/packages/astro-ghostcms/src/schemas/api/posts.ts b/packages/astro-ghostcms/src/schemas/api/posts.ts index 18b1aa5e..cb514ed8 100644 --- a/packages/astro-ghostcms/src/schemas/api/posts.ts +++ b/packages/astro-ghostcms/src/schemas/api/posts.ts @@ -51,4 +51,4 @@ export const postsIncludeSchema = z.object({ authors: z.literal(true).optional(), tags: z.literal(true).optional(), }); -export type PostsIncludeSchema = z.infer; \ No newline at end of file +export type PostsIncludeSchema = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/api/settings.test.ts b/packages/astro-ghostcms/src/schemas/api/settings.test.ts index e5da99da..02d9f403 100644 --- a/packages/astro-ghostcms/src/schemas/api/settings.test.ts +++ b/packages/astro-ghostcms/src/schemas/api/settings.test.ts @@ -3,34 +3,37 @@ import { beforeEach, describe, expect, test } from "vitest"; import { TSGhostContentAPI } from "@ts-ghost/content-api"; const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; -const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; +const key = + process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; describe("settings integration tests browse", () => { - let api: TSGhostContentAPI; - beforeEach(() => { - api = new TSGhostContentAPI(url, key, "v5.0"); - }); - test("settings.fetch()", async () => { - const result = await api.settings.fetch(); - expect(result).not.toBeUndefined(); - expect(result).not.toBeNull(); - if (!result.success) { - expect(result.errors).toBeDefined(); - expect(result.errors).toHaveLength(1); - } else { - expect(result.data).toBeDefined(); - const settings = result.data; - expect(settings).toBeDefined(); - expect(settings.title).toBe("Astro Starter"); - expect(settings.description).toBe("Thoughts, stories and ideas."); - expect(settings.logo).toBeNull(); - expect(settings.cover_image).toBe("https://static.ghost.org/v4.0.0/images/publication-cover.jpg"); - expect(settings.icon).toBeNull(); - expect(settings.lang).toBe("en"); - expect(settings.timezone).toBe("Etc/UTC"); - expect(settings.codeinjection_head).toBeNull(); - expect(settings.codeinjection_foot).toBeNull(); - expect(settings.members_support_address).toBe("noreply"); - } - }); -}); \ No newline at end of file + let api: TSGhostContentAPI; + beforeEach(() => { + api = new TSGhostContentAPI(url, key, "v5.0"); + }); + test("settings.fetch()", async () => { + const result = await api.settings.fetch(); + expect(result).not.toBeUndefined(); + expect(result).not.toBeNull(); + if (!result.success) { + expect(result.errors).toBeDefined(); + expect(result.errors).toHaveLength(1); + } else { + expect(result.data).toBeDefined(); + const settings = result.data; + expect(settings).toBeDefined(); + expect(settings.title).toBe("Astro Starter"); + expect(settings.description).toBe("Thoughts, stories and ideas."); + expect(settings.logo).toBeNull(); + expect(settings.cover_image).toBe( + "https://static.ghost.org/v4.0.0/images/publication-cover.jpg", + ); + expect(settings.icon).toBeNull(); + expect(settings.lang).toBe("en"); + expect(settings.timezone).toBe("Etc/UTC"); + expect(settings.codeinjection_head).toBeNull(); + expect(settings.codeinjection_foot).toBeNull(); + expect(settings.members_support_address).toBe("noreply"); + } + }); +}); diff --git a/packages/astro-ghostcms/src/schemas/api/settings.ts b/packages/astro-ghostcms/src/schemas/api/settings.ts index 240aa74b..4417b8ae 100644 --- a/packages/astro-ghostcms/src/schemas/api/settings.ts +++ b/packages/astro-ghostcms/src/schemas/api/settings.ts @@ -37,4 +37,4 @@ export const settingsSchema = z.object({ url: z.string(), }); -export type Settings = z.infer; \ No newline at end of file +export type Settings = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/api/socials.ts b/packages/astro-ghostcms/src/schemas/api/socials.ts index 9d07e4a1..95dc9a9b 100644 --- a/packages/astro-ghostcms/src/schemas/api/socials.ts +++ b/packages/astro-ghostcms/src/schemas/api/socials.ts @@ -29,4 +29,4 @@ export const twitter = (username: string) => { export const facebook = (username: string) => { // Handles a starting slash, this shouldn't happen, but just in case return `https://www.facebook.com/${username.replace(/^\//, "")}`; -}; \ No newline at end of file +}; diff --git a/packages/astro-ghostcms/src/schemas/api/tags.ts b/packages/astro-ghostcms/src/schemas/api/tags.ts index ef805c49..9344112d 100644 --- a/packages/astro-ghostcms/src/schemas/api/tags.ts +++ b/packages/astro-ghostcms/src/schemas/api/tags.ts @@ -31,4 +31,4 @@ export type Tag = z.infer; export const tagsIncludeSchema = z.object({ "count.posts": z.literal(true).optional(), }); -export type TagsIncludeSchema = z.infer; \ No newline at end of file +export type TagsIncludeSchema = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/api/tiers.ts b/packages/astro-ghostcms/src/schemas/api/tiers.ts index 7c6e8ef3..1dff9462 100644 --- a/packages/astro-ghostcms/src/schemas/api/tiers.ts +++ b/packages/astro-ghostcms/src/schemas/api/tiers.ts @@ -37,4 +37,4 @@ export const tiersIncludeSchema = z.object({ yearly_price: z.literal(true).optional(), benefits: z.literal(true).optional(), }); -export type TiersIncludeSchema = z.infer; \ No newline at end of file +export type TiersIncludeSchema = z.infer; diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts index 8c1274bb..c7c5e6ad 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.test.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -1,54 +1,54 @@ -import { expect, describe, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { GhostUserConfigSchema } from "./userconfig"; describe("GhostUserConfigSchema", () => { - it("should validate a valid user config", () => { - const validConfig = { - ghostURL: "https://ghostdemo.matthiesen.xyz", - disableThemeProvider: true, - ThemeProvider: { - theme: "@matthiesenxyz/astro-ghostcms-theme-default", - }, - disableDefault404: false, - enableRSSFeed: true, - enableOGImages: true, - sitemap: { - // sitemap configuration - }, - robotstxt: { - // robotstxt configuration - }, - fullConsoleLogs: false, - }; + it("should validate a valid user config", () => { + const validConfig = { + ghostURL: "https://ghostdemo.matthiesen.xyz", + disableThemeProvider: true, + ThemeProvider: { + theme: "@matthiesenxyz/astro-ghostcms-theme-default", + }, + disableDefault404: false, + enableRSSFeed: true, + enableOGImages: true, + sitemap: { + // sitemap configuration + }, + robotstxt: { + // robotstxt configuration + }, + fullConsoleLogs: false, + }; - const result = GhostUserConfigSchema.safeParse(validConfig); + const result = GhostUserConfigSchema.safeParse(validConfig); - expect(result.success).to.be.true; - expect(result.data).to.deep.equal(validConfig); - }); + expect(result.success).to.be.true; + expect(result.data).to.deep.equal(validConfig); + }); - it("should invalidate an invalid user config", () => { - const invalidConfig = { - ghostURL: "invalid-url", - disableThemeProvider: "true", - ThemeProvider: { - theme: 123, - }, - disableDefault404: "false", - enableRSSFeed: "true", - enableOGImages: "true", - sitemap: { - // invalid sitemap configuration - }, - robotstxt: { - // invalid robotstxt configuration - }, - fullConsoleLogs: "false", - }; + it("should invalidate an invalid user config", () => { + const invalidConfig = { + ghostURL: "invalid-url", + disableThemeProvider: "true", + ThemeProvider: { + theme: 123, + }, + disableDefault404: "false", + enableRSSFeed: "true", + enableOGImages: "true", + sitemap: { + // invalid sitemap configuration + }, + robotstxt: { + // invalid robotstxt configuration + }, + fullConsoleLogs: "false", + }; - const result = GhostUserConfigSchema.safeParse(invalidConfig); + const result = GhostUserConfigSchema.safeParse(invalidConfig); - expect(result.success).to.be.false; - expect(!result.success).to.exist; - }); -}); \ No newline at end of file + expect(result.success).to.be.false; + expect(!result.success).to.exist; + }); +}); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index 3b281af7..ea5f5a9d 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -18,12 +18,17 @@ export const GhostUserConfigSchema = z.object({ * @default false */ disableThemeProvider: z.boolean().optional().default(false), - ThemeProvider: z.object({ - /** OPTIONAL - Set the theme you want to use - * @default "@matthiesenxyz/astro-ghostcms-theme-default" - */ - theme: z.string().optional().default("@matthiesenxyz/astro-ghostcms-theme-default"), - }).optional(), + ThemeProvider: z + .object({ + /** OPTIONAL - Set the theme you want to use + * @default "@matthiesenxyz/astro-ghostcms-theme-default" + */ + theme: z + .string() + .optional() + .default("@matthiesenxyz/astro-ghostcms-theme-default"), + }) + .optional(), /** Allows the user to disable the provided 404 page */ disableDefault404: z.boolean().optional().default(false), /** Allows the user to disable the provided RSS Feed */ diff --git a/packages/astro-ghostcms/src/utils/latestVersion.ts b/packages/astro-ghostcms/src/utils/latestVersion.ts index f117b9b1..b41085af 100644 --- a/packages/astro-ghostcms/src/utils/latestVersion.ts +++ b/packages/astro-ghostcms/src/utils/latestVersion.ts @@ -23,4 +23,4 @@ export default async function latestVersion( const { version } = await packageJson(packageName.toLowerCase(), options); return version; -} \ No newline at end of file +} diff --git a/packages/astro-ghostcms/virtual.d.ts b/packages/astro-ghostcms/virtual.d.ts index 6695d996..bfef5ddb 100644 --- a/packages/astro-ghostcms/virtual.d.ts +++ b/packages/astro-ghostcms/virtual.d.ts @@ -1,4 +1,4 @@ declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { - const Config: import("./src/schemas/userconfig").GhostUserConfig; - export default Config; -} \ No newline at end of file + const Config: import("./src/schemas/userconfig").GhostUserConfig; + export default Config; +} diff --git a/packages/astro-ghostcms/vitest.config.ts b/packages/astro-ghostcms/vitest.config.ts index f19e0d02..6a723a68 100644 --- a/packages/astro-ghostcms/vitest.config.ts +++ b/packages/astro-ghostcms/vitest.config.ts @@ -1,6 +1,6 @@ /// /// -import { defineProject } from 'vitest/config' +import { defineProject } from "vitest/config"; export default defineProject({ test: { @@ -9,4 +9,4 @@ export default defineProject({ watchExclude: [".*\\/node_modules\\/.*", ".*\\/build\\/.*"], exclude: ["node_modules", "dist", ".idea", ".git", ".cache"], }, -}) +}); diff --git a/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs b/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs index 7eeba2bd..a96a01f0 100644 --- a/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs +++ b/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs @@ -1,16 +1,16 @@ -import { defineConfig } from "astro/config"; import ghostcms from "@matthiesenxyz/astro-ghostcms"; -import UnoCSS from 'unocss/astro'; +import { defineConfig } from "astro/config"; +import UnoCSS from "unocss/astro"; // https://astro.build/config export default defineConfig({ site: "https://example.xyz/", - trailingSlash: 'ignore', + trailingSlash: "ignore", integrations: [ UnoCSS({ injectReset: true }), ghostcms({ theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", ghostURL: "https://ghostdemo.matthiesen.xyz", - }) + }), ], }); diff --git a/packages/create-astro-ghostcms/src/templates/brutal/src/env.d.ts b/packages/create-astro-ghostcms/src/templates/brutal/src/env.d.ts index e8c8b171..b05f2dcb 100644 --- a/packages/create-astro-ghostcms/src/templates/brutal/src/env.d.ts +++ b/packages/create-astro-ghostcms/src/templates/brutal/src/env.d.ts @@ -1,9 +1,9 @@ /// interface ImportMetaEnv { - readonly CONTENT_API_KEY: string - readonly CONTENT_API_URL: string + readonly CONTENT_API_KEY: string; + readonly CONTENT_API_URL: string; } interface ImportMeta { - readonly env: ImportMetaEnv; -} \ No newline at end of file + readonly env: ImportMetaEnv; +} diff --git a/packages/create-astro-ghostcms/src/templates/brutal/uno.config.ts b/packages/create-astro-ghostcms/src/templates/brutal/uno.config.ts index d056c836..e3f5c156 100644 --- a/packages/create-astro-ghostcms/src/templates/brutal/uno.config.ts +++ b/packages/create-astro-ghostcms/src/templates/brutal/uno.config.ts @@ -1,6 +1,6 @@ -import brutalTheme from '@matthiesenxyz/astro-ghostcms-brutalbyelian'; -import { defineConfig } from 'unocss'; +import brutalTheme from "@matthiesenxyz/astro-ghostcms-brutalbyelian"; +import { defineConfig } from "unocss"; export default defineConfig({ - presets: [ brutalTheme() ], + presets: [brutalTheme()], }); diff --git a/packages/starlight-ghostcms/index.ts b/packages/starlight-ghostcms/index.ts index 0c018270..66d719f2 100644 --- a/packages/starlight-ghostcms/index.ts +++ b/packages/starlight-ghostcms/index.ts @@ -1,91 +1,126 @@ -import type { StarlightPlugin, StarlightUserConfig } from '@astrojs/starlight/types' -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' +import type { + StarlightPlugin, + StarlightUserConfig, +} from "@astrojs/starlight/types"; +import type { AstroIntegrationLogger } from "astro"; +import { vitePluginStarlightGhostConfig } from "./src/integrations/vite"; +import { + type StarlightGhostConfig, + validateConfig, +} from "./src/schemas/config"; +import { facebook, getSettings, invariant, twitter } from "./src/utils/api"; -const settings = await getSettings() +const settings = await getSettings(); -export type { StarlightGhostConfig } +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") +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: { - setup({ astroConfig, addIntegration, config: starlightConfig, logger, updateConfig: updateStarlightConfig }) { - updateStarlightConfig({ - social: { - ...starlightConfig.social, - rss: `${astroConfig.site}/rss.xml`, - twitter: twitter(settings.twitter?settings.twitter:""), - facebook: facebook(settings.facebook?settings.facebook:""), - }, - components: { - ...starlightConfig.components, - ...overrideStarlightComponent(starlightConfig.components, logger, 'MarkdownContent'), - ...overrideStarlightComponent(starlightConfig.components, logger, 'Sidebar'), - ...overrideStarlightComponent(starlightConfig.components, logger, "SiteTitle"), - } - }) + return { + name: "@matthiesenxyz/starlight-ghostcms-plugin", + hooks: { + setup({ + astroConfig, + addIntegration, + config: starlightConfig, + logger, + updateConfig: updateStarlightConfig, + }) { + updateStarlightConfig({ + social: { + ...starlightConfig.social, + rss: `${astroConfig.site}/rss.xml`, + twitter: twitter(settings.twitter ? settings.twitter : ""), + facebook: facebook(settings.facebook ? settings.facebook : ""), + }, + components: { + ...starlightConfig.components, + ...overrideStarlightComponent( + starlightConfig.components, + logger, + "MarkdownContent", + ), + ...overrideStarlightComponent( + starlightConfig.components, + logger, + "Sidebar", + ), + ...overrideStarlightComponent( + starlightConfig.components, + logger, + "SiteTitle", + ), + }, + }); - addIntegration({ - name: '@matthiesenxyz/starlight-ghostcms', - hooks: { - 'astro:config:setup': ({ injectRoute, updateConfig }) => { - injectRoute({ - pattern: '/blog', - entrypoint: '@matthiesenxyz/starlight-ghostcms/routes/index.astro', - prerender: true, - }) - injectRoute({ - pattern: '/blog/[slug]', - 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' - }) + addIntegration({ + name: "@matthiesenxyz/starlight-ghostcms", + hooks: { + "astro:config:setup": ({ injectRoute, updateConfig }) => { + injectRoute({ + pattern: "/blog", + entrypoint: + "@matthiesenxyz/starlight-ghostcms/routes/index.astro", + prerender: true, + }); + injectRoute({ + pattern: "/blog/[slug]", + 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", + }); - updateConfig({ - vite: { - plugins: [vitePluginStarlightGhostConfig(config)], - }, - }) - } - } - }) - } - }, - } + updateConfig({ + vite: { + plugins: [vitePluginStarlightGhostConfig(config)], + }, + }); + }, + }, + }); + }, + }, + }; } function overrideStarlightComponent( - components: StarlightUserConfig['components'], - logger: AstroIntegrationLogger, - component: keyof NonNullable, - ) { - if (components?.[component]) { - logger.warn(`It looks like you already have a \`${component}\` component override in your Starlight configuration.`) - logger.warn(`To use \`starlight-ghostcms\`, remove the override for the \`${component}\` component.\n`) - logger.warn("This Warning can be ignored if you know what your doing ;)") - - return {} - } - - return { - [component]: `@matthiesenxyz/starlight-ghostcms/overrides/${component}.astro`, - } - } \ No newline at end of file + components: StarlightUserConfig["components"], + logger: AstroIntegrationLogger, + component: keyof NonNullable, +) { + if (components?.[component]) { + logger.warn( + `It looks like you already have a \`${component}\` component override in your Starlight configuration.`, + ); + logger.warn( + `To use \`starlight-ghostcms\`, remove the override for the \`${component}\` component.\n`, + ); + logger.warn("This Warning can be ignored if you know what your doing ;)"); + + return {}; + } + + return { + [component]: `@matthiesenxyz/starlight-ghostcms/overrides/${component}.astro`, + }; +} diff --git a/packages/starlight-ghostcms/src/integrations/vite.ts b/packages/starlight-ghostcms/src/integrations/vite.ts index 7ccb3d43..eff6ca08 100644 --- a/packages/starlight-ghostcms/src/integrations/vite.ts +++ b/packages/starlight-ghostcms/src/integrations/vite.ts @@ -1,22 +1,24 @@ -import type { ViteUserConfig } from 'astro' +import type { ViteUserConfig } from "astro"; -import type { StarlightGhostConfig } from '../schemas/config.ts' +import type { StarlightGhostConfig } from "../schemas/config.ts"; // Expose the starlight-blog plugin configuration. -export function vitePluginStarlightGhostConfig(config: StarlightGhostConfig): VitePlugin { - const moduleId = 'virtual:starlight-ghost-config' - const resolvedModuleId = `\0${moduleId}` - const moduleContent = `export default ${JSON.stringify(config)}` +export function vitePluginStarlightGhostConfig( + config: StarlightGhostConfig, +): VitePlugin { + const moduleId = "virtual:starlight-ghost-config"; + const resolvedModuleId = `\0${moduleId}`; + const moduleContent = `export default ${JSON.stringify(config)}`; - return { - name: 'vite-plugin-starlight-ghost-config', - load(id) { - return id === resolvedModuleId ? moduleContent : undefined - }, - resolveId(id) { - return id === moduleId ? resolvedModuleId : undefined - }, - } + return { + name: "vite-plugin-starlight-ghost-config", + load(id) { + return id === resolvedModuleId ? moduleContent : undefined; + }, + resolveId(id) { + return id === moduleId ? resolvedModuleId : undefined; + }, + }; } -type VitePlugin = NonNullable[number] +type VitePlugin = NonNullable[number]; diff --git a/packages/starlight-ghostcms/src/overrides/sidebartypes.ts b/packages/starlight-ghostcms/src/overrides/sidebartypes.ts index 8a043368..587fa01c 100644 --- a/packages/starlight-ghostcms/src/overrides/sidebartypes.ts +++ b/packages/starlight-ghostcms/src/overrides/sidebartypes.ts @@ -1,15 +1,19 @@ -import { z } from 'astro/zod'; -import type { AstroBuiltinAttributes } from 'astro'; -import type { HTMLAttributes } from 'astro/types'; +import type { AstroBuiltinAttributes } from "astro"; +import type { HTMLAttributes } from "astro/types"; +import { z } from "astro/zod"; const linkHTMLAttributesSchema = z.record( - z.union([z.string(), z.number(), z.boolean(), z.undefined()]) -) as z.Schema, keyof AstroBuiltinAttributes | 'children'>>; + z.union([z.string(), z.number(), z.boolean(), z.undefined()]), +) as z.Schema< + Omit, keyof AstroBuiltinAttributes | "children"> +>; export type LinkHTMLAttributes = z.infer; const badgeSchema = () => z.object({ - variant: z.enum(['note', 'danger', 'success', 'caution', 'tip', 'default']).default('default'), + variant: z + .enum(["note", "danger", "success", "caution", "tip", "default"]) + .default("default"), text: z.string(), }); @@ -17,8 +21,8 @@ export const BadgeConfigSchema = () => z .union([z.string(), badgeSchema()]) .transform((badge) => { - if (typeof badge === 'string') { - return { variant: 'default' as const, text: badge }; + if (typeof badge === "string") { + return { variant: "default" as const, text: badge }; } return badge; }) @@ -27,7 +31,7 @@ export const BadgeConfigSchema = () => export type Badge = z.output>; export interface Link { - type: 'link'; + type: "link"; label: string; href: string; isCurrent: boolean; @@ -36,11 +40,11 @@ export interface Link { } interface Group { - type: 'group'; + type: "group"; label: string; entries: (Link | Group)[]; collapsed: boolean; badge: Badge | undefined; } -export type SidebarEntry = Link | Group; \ No newline at end of file +export type SidebarEntry = Link | Group; diff --git a/packages/starlight-ghostcms/src/routes/rss.xml.ts b/packages/starlight-ghostcms/src/routes/rss.xml.ts index 9f558ddb..6781f1ae 100644 --- a/packages/starlight-ghostcms/src/routes/rss.xml.ts +++ b/packages/starlight-ghostcms/src/routes/rss.xml.ts @@ -5,17 +5,17 @@ import { getAllPosts, getSettings, invariant } from "../utils/api"; const posts = await getAllPosts(); const settings = await getSettings(); -import config from 'virtual:starlight-ghost-config'; +import config from "virtual:starlight-ghost-config"; export async function GET({ site }: APIContext) { - invariant(settings,"Settings is not defined") + invariant(settings, "Settings is not defined"); const title = config.title; const description = config.rssDescription; - const ghostSite = settings.url + const ghostSite = settings.url; return rss({ title: title, description: description, - site: site?site:ghostSite, + site: site ? site : ghostSite, items: posts.map((post) => ({ title: post.title, pubDate: new Date( diff --git a/packages/starlight-ghostcms/src/schemas/config.ts b/packages/starlight-ghostcms/src/schemas/config.ts index 435e794d..b2f617df 100644 --- a/packages/starlight-ghostcms/src/schemas/config.ts +++ b/packages/starlight-ghostcms/src/schemas/config.ts @@ -1,50 +1,52 @@ -import { AstroError } from 'astro/errors' -import { z } from 'astro/zod' +import { AstroError } from "astro/errors"; +import { z } from "astro/zod"; const configSchema = z - .object({ - /** - * The number of blog posts to display per page in the blog post list. - */ - postCount: z.number().min(1).default(5), - /** - * The number of recent blog posts to display in the sidebar. - */ - recentPostCount: z.number().min(1).default(10), - /** - * The title of the blog. - */ - title: z.string().default('Blog'), - /** - * The description of the blog on the RSS Feed. - */ - rssDescription: z.string().default('My Awesome Starlight-GhostCMS Blog'), - /** - * Turn on and off "Powered by Ghost" - */ - supportGhost: z.boolean().default(true), - }) - .default({}) + .object({ + /** + * The number of blog posts to display per page in the blog post list. + */ + postCount: z.number().min(1).default(5), + /** + * The number of recent blog posts to display in the sidebar. + */ + recentPostCount: z.number().min(1).default(10), + /** + * The title of the blog. + */ + title: z.string().default("Blog"), + /** + * The description of the blog on the RSS Feed. + */ + rssDescription: z.string().default("My Awesome Starlight-GhostCMS Blog"), + /** + * Turn on and off "Powered by Ghost" + */ + supportGhost: z.boolean().default(true), + }) + .default({}); export function validateConfig(userConfig: unknown): StarlightGhostConfig { - const config = configSchema.safeParse(userConfig) + const config = configSchema.safeParse(userConfig); - if (!config.success) { - const errors = config.error.flatten() + if (!config.success) { + const errors = config.error.flatten(); - throw new AstroError( - `Invalid starlight-GhostCMS configuration: + throw new AstroError( + `Invalid starlight-GhostCMS configuration: -${errors.formErrors.map((formError) => ` - ${formError}`).join('\n')} +${errors.formErrors.map((formError) => ` - ${formError}`).join("\n")} ${Object.entries(errors.fieldErrors) - .map(([fieldName, fieldErrors]) => ` - ${fieldName}: ${fieldErrors.join(' - ')}`) - .join('\n')} + .map( + ([fieldName, fieldErrors]) => ` - ${fieldName}: ${fieldErrors.join(" - ")}`, + ) + .join("\n")} `, - "See the error report above for more informations.\n\nIf you believe this is a bug, please file an issue at https://github.com/matthiesenxyz/astro-ghostcms/issues/new/choose", - ) - } + "See the error report above for more informations.\n\nIf you believe this is a bug, please file an issue at https://github.com/matthiesenxyz/astro-ghostcms/issues/new/choose", + ); + } - return config.data + return config.data; } -export type StarlightGhostConfig = z.infer +export type StarlightGhostConfig = z.infer; diff --git a/packages/starlight-ghostcms/src/utils/api/api-functions.ts b/packages/starlight-ghostcms/src/utils/api/api-functions.ts index e513b3ce..a784ebec 100644 --- a/packages/starlight-ghostcms/src/utils/api/api-functions.ts +++ b/packages/starlight-ghostcms/src/utils/api/api-functions.ts @@ -1,8 +1,8 @@ -import { TS_API } from "./content-api"; -import type { Page, Post } from "./content-api/schemas"; -import type { ContentAPICredentials } from './content-api/content-api' // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; +import { TS_API } from "./content-api"; +import type { ContentAPICredentials } from "./content-api/content-api"; +import type { Page, Post } from "./content-api/schemas"; import { invariant } from "./invariant.js"; const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( @@ -11,17 +11,11 @@ const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "CONTENT_", ); -invariant( - CONTENT_API_KEY, - "CONTENT_API_KEY Missing from .env" - ) -invariant( - CONTENT_API_URL, - "CONTENT_API_URL Missing from .env" - ) +invariant(CONTENT_API_KEY, "CONTENT_API_KEY Missing from .env"); +invariant(CONTENT_API_URL, "CONTENT_API_URL Missing from .env"); -const key:ContentAPICredentials["key"] = CONTENT_API_KEY; -const url:ContentAPICredentials["url"] = CONTENT_API_URL; +const key: ContentAPICredentials["key"] = CONTENT_API_KEY; +const url: ContentAPICredentials["url"] = CONTENT_API_URL; const version = "v5.0"; const api = new TS_API(url, key, version); @@ -73,20 +67,21 @@ export const getAllPosts = async () => { return posts; }; -export const getSluggedPost = async (slug:string) => { +export const getSluggedPost = async (slug: string) => { const results = await api.posts - .read({slug: slug}) + .read({ slug: slug }) .include({ authors: true, tags: true, - }).fetch() - - if (!results.success) { - throw new Error(results.errors.map((e) => e.message).join(", ")); - } - return { - post: results.data, - }; + }) + .fetch(); + + if (!results.success) { + throw new Error(results.errors.map((e) => e.message).join(", ")); + } + return { + post: results.data, + }; }; export const getAllPages = async () => { @@ -106,20 +101,21 @@ export const getAllPages = async () => { return pages; }; -export const getSluggedPage = async (slug:string) => { +export const getSluggedPage = async (slug: string) => { const results = await api.pages - .read({slug: slug}) + .read({ slug: slug }) .include({ authors: true, tags: true, - }).fetch() - - if (!results.success) { - throw new Error(results.errors.map((e) => e.message).join(", ")); - } - return { - post: results.data, - }; + }) + .fetch(); + + if (!results.success) { + throw new Error(results.errors.map((e) => e.message).join(", ")); + } + return { + post: results.data, + }; }; export const getSettings = async () => { diff --git a/packages/starlight-ghostcms/src/utils/page.ts b/packages/starlight-ghostcms/src/utils/page.ts index 472aa6d2..be67b776 100644 --- a/packages/starlight-ghostcms/src/utils/page.ts +++ b/packages/starlight-ghostcms/src/utils/page.ts @@ -1,33 +1,33 @@ export function isAnyBlogPage(slug: string) { - return slug.match(/^blog(\/?$|\/.+\/?$)/) !== null + return slug.match(/^blog(\/?$|\/.+\/?$)/) !== null; } export function isBlogRoot(slug: string) { - return slug === 'blog' + return slug === "blog"; } export function isAnyBlogPostPage(slug: string) { - return slug.match(/^blog\/(?!(\d+\/?|tags\/.+)$).+$/) !== null + return slug.match(/^blog\/(?!(\d+\/?|tags\/.+)$).+$/) !== null; } export function isBlogPostPage(slug: string, postSlug: string) { - return slug === postSlug + return slug === postSlug; } export function isBlogTagsPage(slug: string, tag: string) { - return slug === `blog/tags/${tag}` + return slug === `blog/tags/${tag}`; } export function getPageProps(title: string): StarlightPageProps { - return { - frontmatter: { - title, - }, - } + return { + frontmatter: { + title, + }, + }; } interface StarlightPageProps { - frontmatter: { - title: string - } + frontmatter: { + title: string; + }; } diff --git a/packages/starlight-ghostcms/starlight.d.ts b/packages/starlight-ghostcms/starlight.d.ts index 532e47fc..12da2a29 100644 --- a/packages/starlight-ghostcms/starlight.d.ts +++ b/packages/starlight-ghostcms/starlight.d.ts @@ -1,5 +1,5 @@ -declare module 'virtual:starlight/user-config' { - const Config: import('@astrojs/starlight/types').StarlightConfig +declare module "virtual:starlight/user-config" { + const Config: import("@astrojs/starlight/types").StarlightConfig; - export default Config + export default Config; } diff --git a/packages/starlight-ghostcms/virtual.d.ts b/packages/starlight-ghostcms/virtual.d.ts index d69104e9..5f5ef663 100644 --- a/packages/starlight-ghostcms/virtual.d.ts +++ b/packages/starlight-ghostcms/virtual.d.ts @@ -1,5 +1,5 @@ -declare module 'virtual:starlight-ghost-config' { - const StarlightGhostConfig: import('./src/schemas/config').StarlightGhostConfig +declare module "virtual:starlight-ghost-config" { + const StarlightGhostConfig: import("./src/schemas/config").StarlightGhostConfig; - export default StarlightGhostConfig + export default StarlightGhostConfig; } diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index 934e3c7a..7e2bd462 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -12,7 +12,7 @@ export default defineConfig({ ghostcms({ ghostURL: "https://ghostdemo.matthiesen.xyz", ThemeProvider: { - theme: '@matthiesenxyz/astro-ghostcms-brutalbyelian', + theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, }), ], diff --git a/playgrounds/starlight-playground/.vscode/extensions.json b/playgrounds/starlight-playground/.vscode/extensions.json index 8ce5285f..3a1c9ecd 100644 --- a/playgrounds/starlight-playground/.vscode/extensions.json +++ b/playgrounds/starlight-playground/.vscode/extensions.json @@ -1,4 +1,4 @@ { - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} \ No newline at end of file + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/playgrounds/starlight-playground/.vscode/launch.json b/playgrounds/starlight-playground/.vscode/launch.json index 42bfb220..230708db 100644 --- a/playgrounds/starlight-playground/.vscode/launch.json +++ b/playgrounds/starlight-playground/.vscode/launch.json @@ -1,11 +1,11 @@ { - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + "command": "./node_modules/.bin/astro dev", + "name": "Development server", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/playgrounds/starlight-playground/astro.config.mjs b/playgrounds/starlight-playground/astro.config.mjs index 30d5f7b5..391a2f20 100644 --- a/playgrounds/starlight-playground/astro.config.mjs +++ b/playgrounds/starlight-playground/astro.config.mjs @@ -1,35 +1,35 @@ -import { defineConfig } from 'astro/config'; -import starlight from '@astrojs/starlight'; -import starlightGhostCMS from '@matthiesenxyz/starlight-ghostcms'; +import starlight from "@astrojs/starlight"; +import starlightGhostCMS from "@matthiesenxyz/starlight-ghostcms"; +import { defineConfig } from "astro/config"; // https://astro.build/config export default defineConfig({ site: "http://localhost:4321", integrations: [ starlight({ - title: 'My Docs', + title: "My Docs", plugins: [ starlightGhostCMS({ title: "Demo Blog", - rssDescription: "Starlight Playground" - }) + rssDescription: "Starlight Playground", + }), ], social: { - github: 'https://github.com/withastro/starlight', + github: "https://github.com/withastro/starlight", }, sidebar: [ { - label: 'Guides', + label: "Guides", items: [ // Each item here is one entry in the navigation menu. - { label: 'Example Guide', link: '/guides/example/' }, + { label: "Example Guide", link: "/guides/example/" }, ], }, { - label: 'Reference', - autogenerate: { directory: 'reference' }, + label: "Reference", + autogenerate: { directory: "reference" }, }, ], }), ], -}); \ No newline at end of file +}); diff --git a/playgrounds/starlight-playground/src/content/config.ts b/playgrounds/starlight-playground/src/content/config.ts index 4c3d67cb..3c0e282d 100644 --- a/playgrounds/starlight-playground/src/content/config.ts +++ b/playgrounds/starlight-playground/src/content/config.ts @@ -1,6 +1,6 @@ -import { defineCollection } from 'astro:content'; -import { docsSchema } from '@astrojs/starlight/schema'; +import { docsSchema } from "@astrojs/starlight/schema"; +import { defineCollection } from "astro:content"; export const collections = { docs: defineCollection({ schema: docsSchema() }), -}; \ No newline at end of file +}; diff --git a/playgrounds/starlight-playground/src/env.d.ts b/playgrounds/starlight-playground/src/env.d.ts index c13bd73c..acef35f1 100644 --- a/playgrounds/starlight-playground/src/env.d.ts +++ b/playgrounds/starlight-playground/src/env.d.ts @@ -1,2 +1,2 @@ /// -/// \ No newline at end of file +/// From 657cfe756892a21a749e1e40b490207614aa8e0c Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 08:58:22 -0800 Subject: [PATCH 07/46] update readme --- packages/astro-ghostcms/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index b50af9a8..2d9f2644 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -59,7 +59,20 @@ import GhostCMS from '@matthiesenxyz/astro-ghostcms'; // https://astro.build/config export default defineConfig({ site: "https://YOUR-DOMAIN-HERE.com" - integrations: [GhostCMS()], + integrations: [ + GhostCMS({ + // Config Options + ghostURL: "http://example.com"; // Recommended to set here, Can also set in .env as CONTENT_API_URL + disableThemeProvider: false; // OPTIONAL - Default False + ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. + theme: "@matthiesenxyz/astro-ghostcms-theme-default"; // OPTIONAL - Default Theme shown. + }; + disableDefault404: false; // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. + enableRSSFeed: true; // Allows the user to Enable or disable RSS Feed Generation. Default: true + enableOGImages: true; // Allows the user to Enable or disable OG Image Generation. Default: true + fullConsoleLogs: false; // Show the full Log output from All parts of Astro-GhostCMS + }) + ], }); ``` From 017e641afdf2a5fe27d9ed1689fb139d4f753a25 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 09:51:00 -0800 Subject: [PATCH 08/46] Woo Better config options! --- packages/astro-ghostcms/README.md | 10 ++++- packages/astro-ghostcms/src/astro-ghostcms.ts | 8 ++-- packages/astro-ghostcms/src/schemas/robots.ts | 37 ------------------ .../astro-ghostcms/src/schemas/sitemap.ts | 38 ------------------- .../astro-ghostcms/src/schemas/userconfig.ts | 36 +++++++++--------- playgrounds/astro-playground/astro.config.mjs | 1 + 6 files changed, 32 insertions(+), 98 deletions(-) delete mode 100644 packages/astro-ghostcms/src/schemas/robots.ts delete mode 100644 packages/astro-ghostcms/src/schemas/sitemap.ts diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index 2d9f2644..f38c63e3 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -63,14 +63,22 @@ export default defineConfig({ GhostCMS({ // Config Options ghostURL: "http://example.com"; // Recommended to set here, Can also set in .env as CONTENT_API_URL - disableThemeProvider: false; // OPTIONAL - Default False ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. + disableThemeProvider: false; // OPTIONAL - Default False theme: "@matthiesenxyz/astro-ghostcms-theme-default"; // OPTIONAL - Default Theme shown. }; disableDefault404: false; // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. enableRSSFeed: true; // Allows the user to Enable or disable RSS Feed Generation. Default: true enableOGImages: true; // Allows the user to Enable or disable OG Image Generation. Default: true fullConsoleLogs: false; // Show the full Log output from All parts of Astro-GhostCMS + robotsTxt: { + // OPTIONAL + // ADVANCED USAGE - https://www.npmjs.com/package/astro-robots-txt#configuration + } + sitemap: { + // OPTIONAL + // ADVANCED USAGE - https://docs.astro.build/en/guides/integrations-guide/sitemap + } }) ], }); diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index c976ca1f..0579439c 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -120,7 +120,7 @@ export default defineIntegration({ ); // Theme Provider - if (!options.disableThemeProvider) { + if (!options.ThemeProvider?.disableThemeProvider) { addIntegration( ghostThemeProvider({ theme: options.ThemeProvider?.theme, @@ -162,7 +162,7 @@ export default defineIntegration({ ), ); } - addIntegration(sitemap()); + addIntegration(sitemap(options.sitemap)); } else { if (verbose) { GhostIntegrationLogger.info( @@ -173,7 +173,7 @@ export default defineIntegration({ } } // ASTRO-ROBOTS-TXT - if (!hasIntegration("@astro-robots-txt")) { + if (!hasIntegration("astro-robots-txt")) { if (verbose) { GhostIntegrationLogger.info( c.bold( @@ -181,7 +181,7 @@ export default defineIntegration({ ), ); } - addIntegration(robotsTxt()); + addIntegration(robotsTxt(options.robotsTxt)); } else { if (verbose) { GhostIntegrationLogger.info( diff --git a/packages/astro-ghostcms/src/schemas/robots.ts b/packages/astro-ghostcms/src/schemas/robots.ts deleted file mode 100644 index dd3c2da1..00000000 --- a/packages/astro-ghostcms/src/schemas/robots.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { z } from "astro/zod"; - -const RobotsPolicySchema = z.object({ - /** You must provide a name of the automatic client (search engine crawler). - * Wildcards are allowed. - */ - userAgent: z.string(), - /** Allowed paths for crawling */ - allow: z.string().optional(), - /** Disallowed paths for crawling */ - disallow: z.string().optional(), - /** Indicates that the page's URL contains parameters that should be ignored during crawling. - * Maximum string length is limited to 500. - */ - cleanParam: z.string().optional(), - /** Minimum interval (in secs) for the crawler to wait after loading one page, before starting other */ - crawlDelay: z.number().optional(), -}); - -export const RobotsTxtSchema = z.object({ - /** @example host: true - * // Automatically resolve using the site option from Astro config - * @example host: 'example.com' - */ - host: z.string().optional(), - /** @example sitemap: "https://example.com/sitemap-0.xml" - * @example sitemap: ['https://example.com/sitemap-0.xml','https://example.com/sitemap-1.xml'] - * @example sitemap: false - If you want to get the robots.txt file without the Sitemap: ... entry, set the sitemap parameter to false. - */ - sitemap: z.union([z.string(), z.string().array(), z.boolean()]).optional(), - /** astrojs/sitemap and astro-robots-txt integrations have the sitemap-index.xml as their primary output. That is why the default value of sitemapBaseFileName is set to sitemap-index. - * @example sitemapBaseFileName: 'custom-sitemap' - */ - sitemapBaseFileName: z.string().optional(), - /** SET POLICY RULES */ - policy: RobotsPolicySchema.array().optional(), -}); diff --git a/packages/astro-ghostcms/src/schemas/sitemap.ts b/packages/astro-ghostcms/src/schemas/sitemap.ts deleted file mode 100644 index f94789e9..00000000 --- a/packages/astro-ghostcms/src/schemas/sitemap.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { z } from "astro/zod"; - -const localeKeySchema = z.string().min(1); -enum EnumChangefreq { - DAILY = "daily", - MONTHLY = "monthly", - ALWAYS = "always", - HOURLY = "hourly", - WEEKLY = "weekly", - YEARLY = "yearly", - NEVER = "never", -} -export const SitemapSchema = z.object({ - filter: z.function().args(z.string()).returns(z.boolean()).optional(), - customPages: z.string().url().array().optional(), - i18n: z - .object({ - defaultLocale: localeKeySchema, - locales: z.record( - localeKeySchema, - z - .string() - .min(2) - .regex(/^[a-zA-Z\-]+$/gm, { - message: "Only English alphabet symbols and hyphen allowed", - }), - ), - }) - .refine((val) => !val || val.locales[val.defaultLocale], { - message: "`defaultLocale` must exist in `locales` keys", - }) - .optional(), - entryLimit: z.number().nonnegative().optional(), - serialize: z.function().args(z.any()).returns(z.any()).optional(), - changefreq: z.nativeEnum(EnumChangefreq).optional(), - lastmod: z.date().optional(), - priority: z.number().min(0).max(1).optional(), -}); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index ea5f5a9d..c501cbd2 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -1,6 +1,6 @@ import { z } from "astro/zod"; -import { RobotsTxtSchema } from "./robots.ts"; -import { SitemapSchema } from "./sitemap.ts"; +import type { RobotsTxtOptions } from "astro-robots-txt"; +import type { SitemapOptions } from "@astrojs/sitemap"; export const GhostUserConfigSchema = z.object({ /** OPTIONAL - Either set the URL in your .env or put it here @@ -14,12 +14,12 @@ export const GhostUserConfigSchema = z.object({ * ], * }); */ ghostURL: z.string().url().optional(), - /** OPTIONAL - Disable the theme provider - * @default false - */ - disableThemeProvider: z.boolean().optional().default(false), ThemeProvider: z .object({ + /** OPTIONAL - Disable the theme provider + * @default false + */ + disableThemeProvider: z.boolean().optional().default(false), /** OPTIONAL - Set the theme you want to use * @default "@matthiesenxyz/astro-ghostcms-theme-default" */ @@ -37,22 +37,22 @@ export const GhostUserConfigSchema = z.object({ * @default true */ enableOGImages: z.boolean().optional().default(true), - /** OPTIONAL - astrojs/sitemap - * This option allows the user to configure the included integration - * Options shown are the availble options - * REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap - */ - sitemap: SitemapSchema.optional(), - /** OPTIONAL - astro-robots-txt - * This option allows the user to configure the included integration - * Options shown are the availble options - * REFERENCE https://www.npmjs.com/package/astro-robots-txt#configuration - */ - robotstxt: RobotsTxtSchema.optional(), /** Allows the user to turn on/off Full Console Logs * @default true */ fullConsoleLogs: z.boolean().optional().default(false), + /** Optional - astro-robots-txt + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://www.npmjs.com/package/astro-robots-txt#configuration + */ + robotsTxt: z.custom().optional(), + /** OPTIONAL - astrojs/sitemap + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://docs.astro.build/en/guides/integrations-guide/sitemap + */ + sitemap: z.custom().optional(), }); /** USER CONFIGURATION SCHEMA */ diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index 7e2bd462..f889c932 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,6 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, + fullConsoleLogs: true, }), ], }); From 65f3f2b019be789c84ddb54d58b8ab055f28417e Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 10:25:51 -0800 Subject: [PATCH 09/46] Some cleanup, and change to how config options are --- packages/astro-ghostcms/README.md | 33 ++++++++++--------- packages/astro-ghostcms/src/astro-ghostcms.ts | 4 +-- .../astro-ghostcms/src/schemas/userconfig.ts | 26 +++++++++------ 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index f38c63e3..fb9eb08c 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -62,23 +62,26 @@ export default defineConfig({ integrations: [ GhostCMS({ // Config Options - ghostURL: "http://example.com"; // Recommended to set here, Can also set in .env as CONTENT_API_URL + ghostURL: "http://example.com", // Recommended to set here, Can also set in .env as CONTENT_API_URL ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. - disableThemeProvider: false; // OPTIONAL - Default False - theme: "@matthiesenxyz/astro-ghostcms-theme-default"; // OPTIONAL - Default Theme shown. + disableThemeProvider: false, // OPTIONAL - Default False + theme: "@matthiesenxyz/astro-ghostcms-theme-default", // OPTIONAL - Default Theme shown. }; - disableDefault404: false; // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. - enableRSSFeed: true; // Allows the user to Enable or disable RSS Feed Generation. Default: true - enableOGImages: true; // Allows the user to Enable or disable OG Image Generation. Default: true - fullConsoleLogs: false; // Show the full Log output from All parts of Astro-GhostCMS - robotsTxt: { - // OPTIONAL - // ADVANCED USAGE - https://www.npmjs.com/package/astro-robots-txt#configuration - } - sitemap: { - // OPTIONAL - // ADVANCED USAGE - https://docs.astro.build/en/guides/integrations-guide/sitemap - } + disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. + enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true + enableOGImages: true, // Allows the user to Enable or disable OG Image Generation. Default: true + fullConsoleLogs: false, // Show the full Log output from All parts of Astro-GhostCMS + Integrations: { + // This allows user config passthrough from Astro-GhostCMS to the Included Integrations + robotsTxt: { + // OPTIONAL + // ADVANCED USAGE - https://www.npmjs.com/package/astro-robots-txt#configuration + }, + sitemap: { + // OPTIONAL + // ADVANCED USAGE - https://docs.astro.build/en/guides/integrations-guide/sitemap + }, + }, }) ], }); diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 0579439c..f7a5f2fc 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -162,7 +162,7 @@ export default defineIntegration({ ), ); } - addIntegration(sitemap(options.sitemap)); + addIntegration(sitemap(options.Integrations?.sitemap)); } else { if (verbose) { GhostIntegrationLogger.info( @@ -181,7 +181,7 @@ export default defineIntegration({ ), ); } - addIntegration(robotsTxt(options.robotsTxt)); + addIntegration(robotsTxt(options.Integrations?.robotsTxt)); } else { if (verbose) { GhostIntegrationLogger.info( diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index c501cbd2..a475684b 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -41,18 +41,24 @@ export const GhostUserConfigSchema = z.object({ * @default true */ fullConsoleLogs: z.boolean().optional().default(false), - /** Optional - astro-robots-txt - * This option allows the user to configure the included integration + /** OPTIONAL - Integrations Configuration + * This option allows the user to configure the included integrations * Options shown are the availble options - * @see https://www.npmjs.com/package/astro-robots-txt#configuration */ - robotsTxt: z.custom().optional(), - /** OPTIONAL - astrojs/sitemap - * This option allows the user to configure the included integration - * Options shown are the availble options - * @see https://docs.astro.build/en/guides/integrations-guide/sitemap - */ - sitemap: z.custom().optional(), + Integrations: z.object({ + /** Optional - astro-robots-txt + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://www.npmjs.com/package/astro-robots-txt#configuration + */ + robotsTxt: z.custom().optional(), + /** OPTIONAL - astrojs/sitemap + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://docs.astro.build/en/guides/integrations-guide/sitemap + */ + sitemap: z.custom().optional(), + }).optional(), }); /** USER CONFIGURATION SCHEMA */ From 302af0f7b6fd8b9118da7cfd22e560c4cc44d751 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 10:37:18 -0800 Subject: [PATCH 10/46] update --- packages/astro-ghostcms/src/astro-ghostcms.ts | 43 +++++++++++++------ packages/astro-ghostcms/src/index.ts | 2 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index f7a5f2fc..a135c8fb 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,26 +1,31 @@ +// Node Modules import path from "node:path"; import { fileURLToPath } from "node:url"; +import fse from "fs-extra"; + +// Utils import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; import { AstroError } from "astro/errors"; -import fse from "fs-extra"; -import c from "picocolors"; import { loadEnv } from "vite"; -import { GhostUserConfigSchema } from "./schemas/userconfig"; import latestVersion from "./utils/latestVersion"; +import c from "picocolors"; -// Import External Integrations +// External Integrations import sitemap from "@astrojs/sitemap"; import robotsTxt from "astro-robots-txt"; -import ghostRSS from "./integrations/rssfeed"; -// Import Internal Integrations +// Internal Integrations import ghostOGImages from "./integrations/satoriog"; +import ghostRSS from "./integrations/rssfeed"; import ghostThemeProvider from "./integrations/themeprovider"; // Load environment variables const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); +// Import User Configuration Zod Schema +import { GhostUserConfigSchema } from "./schemas/userconfig"; + /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project * @see https://astro-ghostcms.xyz for the most up-to-date documentation! @@ -34,14 +39,11 @@ export default defineIntegration({ return { "astro:config:setup": ({ - watchIntegration, - hasIntegration, - addIntegration, - addVirtualImports, - addDts, - injectRoute, - logger, + watchIntegration, hasIntegration, addIntegration, + addVirtualImports, addDts, + injectRoute, logger, }) => { + // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); const GhostENVLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( @@ -59,9 +61,11 @@ export default defineIntegration({ )}`, ); + // Setup Watch Integration for Hot Reload during DEV watchIntegration(resolve()); GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms..."); + // Set up verbose logging const verbose = options.fullConsoleLogs; // Check for GhostCMS environment variables @@ -72,6 +76,7 @@ export default defineIntegration({ ), ), ); + if (ENV.CONTENT_API_KEY === undefined) { GhostENVLogger.error( c.bgRed( @@ -229,16 +234,20 @@ export default defineIntegration({ }); }, "astro:config:done": ({ logger }) => { + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green( "CONFIG", )}`, ); + + // Log Configuration Complete GhostLogger.info( c.bold(c.green("Integration Setup & Configuration Complete")), ); }, "astro:server:start": async ({ logger }) => { + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( c.green("DEV"), @@ -256,14 +265,19 @@ export default defineIntegration({ ); // Check for updates + + // Get the latest version of Astro-GhostCMS const currentNPMVersion = await latestVersion( "@matthiesenxyz/astro-ghostcms", ); + + // Get the local version of Astro-GhostCMS const packageJson = await fse.readJson( path.resolve(fileURLToPath(import.meta.url), "../../package.json"), ); const localVersion = packageJson.version; + // Log the version check if (currentNPMVersion !== localVersion) { GhostUpdateLogger.warn( `\n${c.bgYellow( @@ -292,11 +306,14 @@ export default defineIntegration({ } }, "astro:build:done": ({ logger }) => { + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( c.green("BUILD"), )}`, ); + + // Log Build Complete GhostLogger.info( c.bold(c.magenta("Running Astro-GhostCMS in Production mode 🚀")), ); diff --git a/packages/astro-ghostcms/src/index.ts b/packages/astro-ghostcms/src/index.ts index 99bd4e64..b7e3d1eb 100644 --- a/packages/astro-ghostcms/src/index.ts +++ b/packages/astro-ghostcms/src/index.ts @@ -1,3 +1,3 @@ -import astroghostcms from "./astro-ghostcms.js"; +import astroghostcms from "./astro-ghostcms"; export default astroghostcms; From 4288cbe1ac990095b35c554ac3ebc28834108db4 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 10:41:41 -0800 Subject: [PATCH 11/46] update. More progress and nothing has broken --- packages/astro-ghostcms/package.json | 2 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 4 +++- playgrounds/astro-playground/astro.config.mjs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index e1834af9..c5758ba4 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -1,7 +1,7 @@ { "name": "@matthiesenxyz/astro-ghostcms", "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", - "version": "3.3.0-dev.1", + "version": "3.3.0", "homepage": "https://astro-ghostcms.xyz/", "type": "module", "license": "MIT", diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index a135c8fb..4187c9a6 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -44,7 +44,9 @@ export default defineIntegration({ injectRoute, logger, }) => { // Configure Loggers - const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); + const GhostLogger = logger.fork( + c.bold(c.blue("👻 Astro-GhostCMS")) + ); const GhostENVLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "ENV Check", diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index f889c932..faf7fac6 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - fullConsoleLogs: true, + fullConsoleLogs: false, }), ], }); From eebcd365833c4a15fd64146aa94051db29b5e6fc Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 11:11:28 -0800 Subject: [PATCH 12/46] add changeset to prep for PR --- .changeset/config.json | 2 +- .changeset/lucky-plants-burn.md | 13 +++++++++++++ .changeset/ninety-apricots-dream.md | 6 ++++++ packages/astro-ghostcms/package.json | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changeset/lucky-plants-burn.md create mode 100644 .changeset/ninety-apricots-dream.md diff --git a/.changeset/config.json b/.changeset/config.json index 23dc2706..45a822c3 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["playground", "starlight-playground"] + "ignore": ["astro-playground", "starlight-playground"] } diff --git a/.changeset/lucky-plants-burn.md b/.changeset/lucky-plants-burn.md new file mode 100644 index 00000000..c2549ee6 --- /dev/null +++ b/.changeset/lucky-plants-burn.md @@ -0,0 +1,13 @@ +--- +"@matthiesenxyz/astro-ghostcms": minor +--- + +This is a HUGE internal update, Our integration is now built on [`Astro-Integration-Kit`](https://github.com/florian-lefebvre/astro-integration-kit) to give better control over the entire `Astro-GhostCMS` Eco-System. + +# Breaking Changes: +- NEW USER CONFIG! Some of the options have changed! Please check the Readme for a current version of the available options! +- Thats it! Some how even though this is almost an entire rebuild, There is no other USER breaking changes aside from the new more advanced config! + +# Updates: +- Moved from `@ts-ghost/core-api` to `@ts-ghost/content-api` as it provides the same functions as the standard core-api but pre-wrapped with a nice `HTTPClientFactory` instead of `HTTPClient`. +- Updated a ton of Dependencies that Dependabot was reporting as needed updated. diff --git a/.changeset/ninety-apricots-dream.md b/.changeset/ninety-apricots-dream.md new file mode 100644 index 00000000..4518e0a0 --- /dev/null +++ b/.changeset/ninety-apricots-dream.md @@ -0,0 +1,6 @@ +--- +"@matthiesenxyz/create-astro-ghostcms": patch +"@matthiesenxyz/starlight-ghostcms": patch +--- + +Code Linted diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index c5758ba4..15fd2c96 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -1,7 +1,7 @@ { "name": "@matthiesenxyz/astro-ghostcms", "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", - "version": "3.3.0", + "version": "3.2.9", "homepage": "https://astro-ghostcms.xyz/", "type": "module", "license": "MIT", From 078b1c4088552ca51c16c816068b0e2cf35fac46 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 11:12:48 -0800 Subject: [PATCH 13/46] Change Version of Starlight GhostCMS TS-coreAPI to be stuck and prevent updating to v6.0.0 as that would be a breaking change --- packages/starlight-ghostcms/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/starlight-ghostcms/package.json b/packages/starlight-ghostcms/package.json index dab3be89..716f8eb5 100644 --- a/packages/starlight-ghostcms/package.json +++ b/packages/starlight-ghostcms/package.json @@ -67,7 +67,7 @@ }, "dependencies": { "@astrojs/rss": "^4.0.5", - "@ts-ghost/core-api": "^5.1.2", + "@ts-ghost/core-api": "5.1.2", "vite": "^5.1.2", "vite-tsconfig-paths": "^4.2.2" }, From 1350532de4f95741c104e68a69df9f26314a2ba5 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 3 Mar 2024 11:42:34 -0800 Subject: [PATCH 14/46] last check to make sure things are working.... AND LINT! --- packages/astro-ghostcms/package.json | 14 +- packages/astro-ghostcms/src/api/index.ts | 1 + packages/astro-ghostcms/src/astro-ghostcms.ts | 42 ++-- .../src/schemas/userconfig.test.ts | 11 +- .../astro-ghostcms/src/schemas/userconfig.ts | 34 +-- pnpm-lock.yaml | 223 ++---------------- 6 files changed, 73 insertions(+), 252 deletions(-) diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 15fd2c96..0a2c4e0d 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -57,11 +57,11 @@ "test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'" }, "peerDependencies": { - "astro": "^4.4.1" + "astro": ">=4.4.1" }, "devDependencies": { - "@types/fs-extra": "11.0.4", - "@types/node": "20.11.24", + "@types/fs-extra": "^11.0.4", + "@types/node": "^20.11.24", "vitest": "^1.3.1", "vitest-fetch-mock": "^0.2.2" }, @@ -74,11 +74,11 @@ "@ts-ghost/content-api": "^4.0.12", "astro-integration-kit": "^0.5.0", "astro-robots-txt": "^1.0.0", - "fs-extra": "11.2.0", - "package-json": "10.0.0", - "picocolors": "1.0.0", + "fs-extra": "^11.2.0", + "package-json": "^10.0.0", + "picocolors": "^1.0.0", "satori": "^0.10.13", - "satori-html": "0.3.2", + "satori-html": "^0.3.2", "vite": "^5.1.4" } } diff --git a/packages/astro-ghostcms/src/api/index.ts b/packages/astro-ghostcms/src/api/index.ts index b229791e..595a15a8 100644 --- a/packages/astro-ghostcms/src/api/index.ts +++ b/packages/astro-ghostcms/src/api/index.ts @@ -1,2 +1,3 @@ export * from "./ghostAPI"; export * from "./invariant"; +export * from "../schemas/api/index"; diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 4187c9a6..4ba0d5f1 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -7,17 +7,17 @@ import fse from "fs-extra"; import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; import { AstroError } from "astro/errors"; +import c from "picocolors"; import { loadEnv } from "vite"; import latestVersion from "./utils/latestVersion"; -import c from "picocolors"; // External Integrations import sitemap from "@astrojs/sitemap"; import robotsTxt from "astro-robots-txt"; +import ghostRSS from "./integrations/rssfeed"; // Internal Integrations import ghostOGImages from "./integrations/satoriog"; -import ghostRSS from "./integrations/rssfeed"; import ghostThemeProvider from "./integrations/themeprovider"; // Load environment variables @@ -39,14 +39,16 @@ export default defineIntegration({ return { "astro:config:setup": ({ - watchIntegration, hasIntegration, addIntegration, - addVirtualImports, addDts, - injectRoute, logger, + watchIntegration, + hasIntegration, + addIntegration, + addVirtualImports, + addDts, + injectRoute, + logger, }) => { - // Configure Loggers - const GhostLogger = logger.fork( - c.bold(c.blue("👻 Astro-GhostCMS")) - ); + // Configure Loggers + const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); const GhostENVLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "ENV Check", @@ -63,11 +65,11 @@ export default defineIntegration({ )}`, ); - // Setup Watch Integration for Hot Reload during DEV + // Setup Watch Integration for Hot Reload during DEV watchIntegration(resolve()); GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms..."); - // Set up verbose logging + // Set up verbose logging const verbose = options.fullConsoleLogs; // Check for GhostCMS environment variables @@ -78,7 +80,7 @@ export default defineIntegration({ ), ), ); - + if (ENV.CONTENT_API_KEY === undefined) { GhostENVLogger.error( c.bgRed( @@ -236,20 +238,20 @@ export default defineIntegration({ }); }, "astro:config:done": ({ logger }) => { - // Configure Loggers + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green( "CONFIG", )}`, ); - // Log Configuration Complete + // Log Configuration Complete GhostLogger.info( c.bold(c.green("Integration Setup & Configuration Complete")), ); }, "astro:server:start": async ({ logger }) => { - // Configure Loggers + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( c.green("DEV"), @@ -268,18 +270,18 @@ export default defineIntegration({ // Check for updates - // Get the latest version of Astro-GhostCMS + // Get the latest version of Astro-GhostCMS const currentNPMVersion = await latestVersion( "@matthiesenxyz/astro-ghostcms", ); - // Get the local version of Astro-GhostCMS + // Get the local version of Astro-GhostCMS const packageJson = await fse.readJson( path.resolve(fileURLToPath(import.meta.url), "../../package.json"), ); const localVersion = packageJson.version; - // Log the version check + // Log the version check if (currentNPMVersion !== localVersion) { GhostUpdateLogger.warn( `\n${c.bgYellow( @@ -308,14 +310,14 @@ export default defineIntegration({ } }, "astro:build:done": ({ logger }) => { - // Configure Loggers + // Configure Loggers const GhostLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( c.green("BUILD"), )}`, ); - // Log Build Complete + // Log Build Complete GhostLogger.info( c.bold(c.magenta("Running Astro-GhostCMS in Production mode 🚀")), ); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts index c7c5e6ad..2f7a503d 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.test.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -5,33 +5,28 @@ describe("GhostUserConfigSchema", () => { it("should validate a valid user config", () => { const validConfig = { ghostURL: "https://ghostdemo.matthiesen.xyz", - disableThemeProvider: true, ThemeProvider: { + disableThemeProvider: true, theme: "@matthiesenxyz/astro-ghostcms-theme-default", }, disableDefault404: false, enableRSSFeed: true, enableOGImages: true, - sitemap: { - // sitemap configuration - }, - robotstxt: { - // robotstxt configuration - }, fullConsoleLogs: false, }; const result = GhostUserConfigSchema.safeParse(validConfig); expect(result.success).to.be.true; + // @ts-expect-error expect(result.data).to.deep.equal(validConfig); }); it("should invalidate an invalid user config", () => { const invalidConfig = { ghostURL: "invalid-url", - disableThemeProvider: "true", ThemeProvider: { + disableThemeProvider: "true", theme: 123, }, disableDefault404: "false", diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index a475684b..d3f59944 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -1,6 +1,6 @@ -import { z } from "astro/zod"; -import type { RobotsTxtOptions } from "astro-robots-txt"; import type { SitemapOptions } from "@astrojs/sitemap"; +import type { RobotsTxtOptions } from "astro-robots-txt"; +import { z } from "astro/zod"; export const GhostUserConfigSchema = z.object({ /** OPTIONAL - Either set the URL in your .env or put it here @@ -45,20 +45,22 @@ export const GhostUserConfigSchema = z.object({ * This option allows the user to configure the included integrations * Options shown are the availble options */ - Integrations: z.object({ - /** Optional - astro-robots-txt - * This option allows the user to configure the included integration - * Options shown are the availble options - * @see https://www.npmjs.com/package/astro-robots-txt#configuration - */ - robotsTxt: z.custom().optional(), - /** OPTIONAL - astrojs/sitemap - * This option allows the user to configure the included integration - * Options shown are the availble options - * @see https://docs.astro.build/en/guides/integrations-guide/sitemap - */ - sitemap: z.custom().optional(), - }).optional(), + Integrations: z + .object({ + /** Optional - astro-robots-txt + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://www.npmjs.com/package/astro-robots-txt#configuration + */ + robotsTxt: z.custom().optional(), + /** OPTIONAL - astrojs/sitemap + * This option allows the user to configure the included integration + * Options shown are the availble options + * @see https://docs.astro.build/en/guides/integrations-guide/sitemap + */ + sitemap: z.custom().optional(), + }) + .optional(), }); /** USER CONFIGURATION SCHEMA */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 650bc7de..7308e6f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,7 +45,7 @@ importers: specifier: ^6.0.0 version: 6.0.0 astro: - specifier: ^4.4.1 + specifier: '>=4.4.1' version: 4.4.9(@types/node@20.11.24) astro-integration-kit: specifier: ^0.5.0 @@ -54,29 +54,29 @@ importers: specifier: ^1.0.0 version: 1.0.0 fs-extra: - specifier: 11.2.0 + specifier: ^11.2.0 version: 11.2.0 package-json: - specifier: 10.0.0 + specifier: ^10.0.0 version: 10.0.0 picocolors: - specifier: 1.0.0 + specifier: ^1.0.0 version: 1.0.0 satori: specifier: ^0.10.13 version: 0.10.13 satori-html: - specifier: 0.3.2 + specifier: ^0.3.2 version: 0.3.2 vite: specifier: ^5.1.4 version: 5.1.4(@types/node@20.11.24) devDependencies: '@types/fs-extra': - specifier: 11.0.4 + specifier: ^11.0.4 version: 11.0.4 '@types/node': - specifier: 20.11.24 + specifier: ^20.11.24 version: 20.11.24 vitest: specifier: ^1.3.1 @@ -98,7 +98,7 @@ importers: version: 1.1.8 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: 3.2.9(sass@1.71.0)(typescript@5.3.3) + version: link:../astro-ghostcms '@matthiesenxyz/astro-ghostcms-rendercontent': specifier: ^0.0.7 version: link:../astro-ghostcms-rendercontent @@ -156,7 +156,7 @@ importers: version: 5.0.16 '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: 3.2.9(sass@1.71.0)(typescript@5.3.3) + version: link:../astro-ghostcms '@tailwindcss/typography': specifier: ^0.5.10 version: 0.5.10(tailwindcss@3.4.1) @@ -184,13 +184,13 @@ importers: devDependencies: astro: specifier: 4.4.0 - version: 4.4.0(sass@1.71.0)(typescript@5.3.3) + version: 4.4.0(typescript@5.3.3) packages/astro-ghostcms-theme-default: dependencies: '@matthiesenxyz/astro-ghostcms': specifier: ^3.2.9 - version: 3.2.9(sass@1.71.0)(typescript@5.3.3) + version: link:../astro-ghostcms astro: specifier: ^4.2.1 version: 4.3.7(sass@1.71.0)(typescript@5.3.3) @@ -248,7 +248,7 @@ importers: specifier: ^4.0.5 version: 4.0.5 '@ts-ghost/core-api': - specifier: ^5.1.2 + specifier: 5.1.2 version: 5.1.2 vite: specifier: ^5.1.2 @@ -265,7 +265,7 @@ importers: version: link:../tsconfig astro: specifier: ^4.4.0 - version: 4.4.0(sass@1.71.0)(typescript@5.3.3) + version: 4.4.0(typescript@5.3.3) vitest: specifier: ^1.2.2 version: 1.2.2(@vitest/ui@1.3.1) @@ -291,7 +291,7 @@ importers: version: 0.58.5(vite@5.1.4) astro: specifier: ^4.4.0 - version: 4.4.0(sass@1.71.0)(typescript@5.3.3) + version: 4.4.0(typescript@5.3.3) tailwindcss: specifier: ^3.3.5 version: 3.4.1 @@ -316,7 +316,7 @@ importers: version: link:../../packages/starlight-ghostcms astro: specifier: ^4.4.0 - version: 4.4.0(sass@1.71.0)(typescript@5.3.3) + version: 4.4.0(typescript@5.3.3) sharp: specifier: ^0.32.5 version: 0.32.6 @@ -435,7 +435,7 @@ packages: '@astrojs/markdown-remark': 4.2.1 '@mdx-js/mdx': 3.0.1 acorn: 8.11.3 - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) + astro: 4.4.0(typescript@5.3.3) es-module-lexer: 1.4.1 estree-util-visit: 2.0.0 github-slugger: 2.0.0 @@ -480,7 +480,7 @@ packages: '@pagefind/default-ui': 1.0.4 '@types/hast': 3.0.4 '@types/mdast': 4.0.3 - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) + astro: 4.4.0(typescript@5.3.3) astro-expressive-code: 0.32.4(astro@4.4.0) bcp-47: 2.1.0 hast-util-select: 6.0.2 @@ -518,7 +518,7 @@ packages: astro: ^3.0.0 || ^4.0.0 tailwindcss: ^3.0.24 dependencies: - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) + astro: 4.4.0(typescript@5.3.3) autoprefixer: 10.4.17(postcss@8.4.35) postcss: 8.4.35 postcss-load-config: 4.0.2(postcss@8.4.35) @@ -1505,55 +1505,6 @@ packages: globby: 11.1.0 read-yaml-file: 1.1.0 - /@matthiesenxyz/astro-ghostcms-theme-default@0.1.13(astro@4.4.0)(typescript@5.3.3): - resolution: {integrity: sha512-W3zMuu+lJNkO+ccCsjCuGDwe/j8U08WAOowDy2fmwb5vkMu5QWYlCv8tR4Gh3VKfWodRTYoJsSkxETIQ7pXKxQ==} - peerDependencies: - astro: ^4.2.1 - dependencies: - '@matthiesenxyz/astro-ghostcms': 3.2.9(sass@1.71.0)(typescript@5.3.3) - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) - astro-font: 0.0.77 - sass: 1.71.0 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - stylus - - sugarss - - supports-color - - terser - - typescript - dev: false - - /@matthiesenxyz/astro-ghostcms@3.2.9(sass@1.71.0)(typescript@5.3.3): - resolution: {integrity: sha512-LuMXWwo8/AozHKLuu9okjmDqZWSRuJ+Pt2ggZv/gMQrfD4CLIucS4UMl2YQviU1QpguY46j7SP9x0BoIAhFBeA==} - dependencies: - '@astrojs/rss': 4.0.5 - '@astrojs/sitemap': 3.0.5 - '@matthiesenxyz/astro-ghostcms-theme-default': 0.1.13(astro@4.4.0)(typescript@5.3.3) - '@resvg/resvg-js': 2.6.0 - '@ts-ghost/core-api': 5.1.2 - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) - astro-robots-txt: 1.0.0 - fs-extra: 11.2.0 - package-json: 9.0.0 - satori: 0.10.13 - satori-html: 0.3.2 - vite: 5.1.4(sass@1.71.0) - vite-tsconfig-paths: 4.3.1(typescript@5.3.3)(vite@5.1.4) - zod: 3.22.4 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - typescript - dev: false - /@mdx-js/mdx@3.0.1: resolution: {integrity: sha512-eIQ4QTrOWyL3LWEe/bu6Taqzq2HQvHcyTMaOrI95P2/LmJE7AsfPfgJGuFLPVqBUE1BC1rik3VIhU+s9u72arA==} dependencies: @@ -1921,18 +1872,6 @@ packages: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true - /@sindresorhus/is@5.6.0: - resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==} - engines: {node: '>=14.16'} - dev: false - - /@szmarczak/http-timer@5.0.1: - resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==} - engines: {node: '>=14.16'} - dependencies: - defer-to-connect: 2.0.1 - dev: false - /@tailwindcss/typography@0.5.10(tailwindcss@3.4.1): resolution: {integrity: sha512-Pe8BuPJQJd3FfRnm6H0ulKIGoMEQS+Vq01R6M5aCrFB/ccR/shT+0kXLjouGC1gFLm9hopTFN+DMP0pfwRWzPw==} peerDependencies: @@ -2032,10 +1971,6 @@ packages: dependencies: '@types/unist': 3.0.2 - /@types/http-cache-semantics@4.0.4: - resolution: {integrity: sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==} - dev: false - /@types/jsonfile@6.1.4: resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} dependencies: @@ -2740,7 +2675,7 @@ packages: peerDependencies: astro: ^3.3.0 || ^4.0.0-beta dependencies: - astro: 4.4.0(sass@1.71.0)(typescript@5.3.3) + astro: 4.4.0(typescript@5.3.3) hast-util-to-html: 8.0.4 remark-expressive-code: 0.32.4 @@ -2881,7 +2816,7 @@ packages: - typescript dev: false - /astro@4.4.0(sass@1.71.0)(typescript@5.3.3): + /astro@4.4.0(typescript@5.3.3): resolution: {integrity: sha512-JAsMrm1Z6W4Iqg9Q7LW/6lCXrqa4jndEOlR/yu7NGNP0BrPwSM8i4+yzya6hxgsNvyyVK8ywthaNhFmqd8Z+cg==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} hasBin: true @@ -3248,24 +3183,6 @@ packages: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} - /cacheable-lookup@7.0.0: - resolution: {integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==} - engines: {node: '>=14.16'} - dev: false - - /cacheable-request@10.2.14: - resolution: {integrity: sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ==} - engines: {node: '>=14.16'} - dependencies: - '@types/http-cache-semantics': 4.0.4 - get-stream: 6.0.1 - http-cache-semantics: 4.1.1 - keyv: 4.5.4 - mimic-response: 4.0.0 - normalize-url: 8.0.0 - responselike: 3.0.0 - dev: false - /call-bind@1.0.7: resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} engines: {node: '>= 0.4'} @@ -3655,11 +3572,6 @@ packages: dependencies: clone: 1.0.4 - /defer-to-connect@2.0.1: - resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} - engines: {node: '>=10'} - dev: false - /define-data-property@1.1.4: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} @@ -4310,11 +4222,6 @@ packages: signal-exit: 4.1.0 dev: false - /form-data-encoder@2.1.4: - resolution: {integrity: sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==} - engines: {node: '>= 14.17'} - dev: false - /fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} dev: false @@ -4495,23 +4402,6 @@ packages: dependencies: get-intrinsic: 1.2.4 - /got@13.0.0: - resolution: {integrity: sha512-XfBk1CxOOScDcMr9O1yKkNaQyy865NbYs+F7dr4H0LZMVgCj2Le59k6PqbNHoL5ToeaEQUYh6c6yMfVcc6SJxA==} - engines: {node: '>=16'} - dependencies: - '@sindresorhus/is': 5.6.0 - '@szmarczak/http-timer': 5.0.1 - cacheable-lookup: 7.0.0 - cacheable-request: 10.2.14 - decompress-response: 6.0.0 - form-data-encoder: 2.1.4 - get-stream: 6.0.1 - http2-wrapper: 2.2.1 - lowercase-keys: 3.0.0 - p-cancelable: 3.0.0 - responselike: 3.0.0 - dev: false - /graceful-fs@4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: false @@ -4827,14 +4717,6 @@ packages: /http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} - /http2-wrapper@2.2.1: - resolution: {integrity: sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==} - engines: {node: '>=10.19.0'} - dependencies: - quick-lru: 5.1.1 - resolve-alpn: 1.2.1 - dev: false - /human-id@1.0.2: resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} @@ -5203,6 +5085,7 @@ packages: /json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + dev: true /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} @@ -5253,6 +5136,7 @@ packages: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} dependencies: json-buffer: 3.0.1 + dev: true /kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} @@ -5372,11 +5256,6 @@ packages: get-func-name: 2.0.2 dev: true - /lowercase-keys@3.0.0: - resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: false - /lru-cache@10.2.0: resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==} engines: {node: 14 || >=16.14} @@ -5979,11 +5858,6 @@ packages: resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} engines: {node: '>=10'} - /mimic-response@4.0.0: - resolution: {integrity: sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: false - /min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -6134,11 +6008,6 @@ packages: engines: {node: '>=0.10.0'} dev: false - /normalize-url@8.0.0: - resolution: {integrity: sha512-uVFpKhj5MheNBJRTiMZ9pE/7hD1QTeEvugSJW/OmLzAp78PB5O6adfMNTvmfKhXBkvCzC+rqifWcVYpGFwTjnw==} - engines: {node: '>=14.16'} - dev: false - /not@0.1.0: resolution: {integrity: sha512-5PDmaAsVfnWUgTUbJ3ERwn7u79Z0dYxN9ErxCpVJJqe2RK0PJ3z+iFUxuqjwtlDDegXvtWoxD/3Fzxox7tFGWA==} @@ -6269,11 +6138,6 @@ packages: /outdent@0.5.0: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} - /p-cancelable@3.0.0: - resolution: {integrity: sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==} - engines: {node: '>=12.20'} - dev: false - /p-filter@2.1.0: resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} engines: {node: '>=8'} @@ -6339,16 +6203,6 @@ packages: semver: 7.6.0 dev: false - /package-json@9.0.0: - resolution: {integrity: sha512-vGgkl6BR8SJUcOdhj49/17fqYpBYr4fAlbBA3we5j548q114UAafKBEVck85Kk2HKhVzWGIAVybFpJ9LesJY6w==} - engines: {node: '>=18'} - dependencies: - got: 13.0.0 - registry-auth-token: 5.0.2 - registry-url: 6.0.1 - semver: 7.6.0 - dev: false - /pagefind@1.0.4: resolution: {integrity: sha512-oRIizYe+zSI2Jw4zcMU0ebDZm27751hRFiSOBLwc1OIYMrsZKk+3m8p9EVaOmc6zZdtqwwdilNUNxXvBeHcP9w==} hasBin: true @@ -6693,11 +6547,6 @@ packages: resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} engines: {node: '>=8'} - /quick-lru@5.1.1: - resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==} - engines: {node: '>=10'} - dev: false - /rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true @@ -6913,10 +6762,6 @@ packages: /require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - /resolve-alpn@1.2.1: - resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==} - dev: false - /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -6934,13 +6779,6 @@ packages: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - /responselike@3.0.0: - resolution: {integrity: sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg==} - engines: {node: '>=14.16'} - dependencies: - lowercase-keys: 3.0.0 - dev: false - /restore-cursor@4.0.0: resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -8105,23 +7943,6 @@ packages: - terser dev: true - /vite-tsconfig-paths@4.3.1(typescript@5.3.3)(vite@5.1.4): - resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} - peerDependencies: - vite: '*' - peerDependenciesMeta: - vite: - optional: true - dependencies: - debug: 4.3.4 - globrex: 0.1.2 - tsconfck: 3.0.2(typescript@5.3.3) - vite: 5.1.4(sass@1.71.0) - transitivePeerDependencies: - - supports-color - - typescript - dev: false - /vite-tsconfig-paths@4.3.1(vite@5.1.3): resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} peerDependencies: From 03c1de559132c4b2c53152142fd3c40ba2f4f28c Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 09:09:09 -0800 Subject: [PATCH 15/46] change `else { if() ` to `else if` --- packages/astro-ghostcms/src/astro-ghostcms.ts | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 4ba0d5f1..44c1b8c3 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -136,30 +136,24 @@ export default defineIntegration({ verbose, }), ); - } else { - if (verbose) { + } else if (verbose) { GhostIntegrationLogger.info(c.gray("Theme Provider is disabled")); - } } // Satori OG Images if (options.enableOGImages) { addIntegration(ghostOGImages({ verbose })); - } else { - if (verbose) { + } else if (verbose) { GhostIntegrationLogger.info( c.gray("OG Image Provider is disabled"), ); - } } // RSS Feed if (options.enableRSSFeed) { addIntegration(ghostRSS({ verbose })); - } else { - if (verbose) { + } else if (verbose) { GhostIntegrationLogger.info(c.gray("RSS Feed is disabled")); - } } // @ASTROJS/SITEMAP @@ -172,14 +166,12 @@ export default defineIntegration({ ); } addIntegration(sitemap(options.Integrations?.sitemap)); - } else { - if (verbose) { + } else if (verbose) { GhostIntegrationLogger.info( c.gray( "@astrojs/sitemap integration already exists, skipping...", ), ); - } } // ASTRO-ROBOTS-TXT if (!hasIntegration("astro-robots-txt")) { @@ -191,14 +183,12 @@ export default defineIntegration({ ); } addIntegration(robotsTxt(options.Integrations?.robotsTxt)); - } else { - if (verbose) { + } else if (verbose) { GhostIntegrationLogger.info( c.gray( "astro-robots-txt integration already exists, skipping...", ), ); - } } // Set up default 404 page @@ -213,12 +203,10 @@ export default defineIntegration({ entrypoint: `${name}/404.astro`, prerender: true, }); - } else { - if (verbose) { + } else if (verbose) { GhostRouteLogger.info( c.gray("Default 404 page is disabled, Skipping..."), ); - } } // Add virtual imports for user configuration From 3a9ee8aa0bac86d8a99f9c737fdff62b35b24d0a Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 10:25:19 -0800 Subject: [PATCH 16/46] add verbose helper function --- packages/astro-ghostcms/README.md | 2 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 77 ++++++++----------- .../astro-ghostcms/src/schemas/userconfig.ts | 2 +- playgrounds/astro-playground/astro.config.mjs | 2 +- 4 files changed, 35 insertions(+), 48 deletions(-) diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index fb9eb08c..cba98a86 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -70,7 +70,7 @@ export default defineConfig({ disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true enableOGImages: true, // Allows the user to Enable or disable OG Image Generation. Default: true - fullConsoleLogs: false, // Show the full Log output from All parts of Astro-GhostCMS + verbose: false, // Show the full Log output from All parts of Astro-GhostCMS Integrations: { // This allows user config passthrough from Astro-GhostCMS to the Included Integrations robotsTxt: { diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 44c1b8c3..d9e6f5b3 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -25,6 +25,7 @@ const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); // Import User Configuration Zod Schema import { GhostUserConfigSchema } from "./schemas/userconfig"; +import type { string } from "astro/zod"; /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project @@ -47,6 +48,8 @@ export default defineIntegration({ injectRoute, logger, }) => { + // Set up verbose logging + const verbose = options.verbose; // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); const GhostENVLogger = logger.fork( @@ -54,23 +57,35 @@ export default defineIntegration({ "ENV Check", )}`, ); + // Configure Integration Loggers & verbose logging const GhostIntegrationLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "Integrations", )}`, ); + const intLogInfo = (message:string) => { + if (verbose) { + GhostIntegrationLogger.info(message); + } + }; + + // Configure Route Logger & verbose logging const GhostRouteLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "Router", )}`, ); + const routeLogInfo = (message:string) => { + if (verbose) { + GhostRouteLogger.info(message); + } + }; + // Setup Watch Integration for Hot Reload during DEV watchIntegration(resolve()); GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms..."); - // Set up verbose logging - const verbose = options.fullConsoleLogs; // Check for GhostCMS environment variables GhostENVLogger.info( @@ -136,77 +151,49 @@ export default defineIntegration({ verbose, }), ); - } else if (verbose) { - GhostIntegrationLogger.info(c.gray("Theme Provider is disabled")); + } else { + intLogInfo(c.gray("Theme Provider is disabled")); } // Satori OG Images if (options.enableOGImages) { addIntegration(ghostOGImages({ verbose })); - } else if (verbose) { - GhostIntegrationLogger.info( - c.gray("OG Image Provider is disabled"), - ); + } else { + intLogInfo(c.gray("OG Image Provider is disabled")); } // RSS Feed if (options.enableRSSFeed) { addIntegration(ghostRSS({ verbose })); - } else if (verbose) { - GhostIntegrationLogger.info(c.gray("RSS Feed is disabled")); + } else { + intLogInfo(c.gray("RSS Feed is disabled")); } // @ASTROJS/SITEMAP if (!hasIntegration("@astrojs/sitemap")) { - if (verbose) { - GhostIntegrationLogger.info( - c.bold( - c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`), - ), - ); - } + intLogInfo(c.bold(c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`))); addIntegration(sitemap(options.Integrations?.sitemap)); - } else if (verbose) { - GhostIntegrationLogger.info( - c.gray( - "@astrojs/sitemap integration already exists, skipping...", - ), - ); + } else { + intLogInfo(c.gray("@astrojs/sitemap integration already exists, skipping...")); } // ASTRO-ROBOTS-TXT if (!hasIntegration("astro-robots-txt")) { - if (verbose) { - GhostIntegrationLogger.info( - c.bold( - c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`), - ), - ); - } + intLogInfo(c.bold(c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`))); addIntegration(robotsTxt(options.Integrations?.robotsTxt)); - } else if (verbose) { - GhostIntegrationLogger.info( - c.gray( - "astro-robots-txt integration already exists, skipping...", - ), - ); + } else { + intLogInfo(c.gray("astro-robots-txt integration already exists, skipping...")); } // Set up default 404 page if (!options.disableDefault404) { - if (verbose) { - GhostRouteLogger.info( - c.bold(c.cyan("Setting up default 404 page")), - ); - } + routeLogInfo(c.bold(c.cyan("Setting up default 404 page"))); injectRoute({ pattern: "/404", entrypoint: `${name}/404.astro`, prerender: true, }); - } else if (verbose) { - GhostRouteLogger.info( - c.gray("Default 404 page is disabled, Skipping..."), - ); + } else { + routeLogInfo(c.gray("Default 404 page is disabled, Skipping...")); } // Add virtual imports for user configuration diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index d3f59944..23455f06 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -40,7 +40,7 @@ export const GhostUserConfigSchema = z.object({ /** Allows the user to turn on/off Full Console Logs * @default true */ - fullConsoleLogs: z.boolean().optional().default(false), + verbose: z.boolean().optional().default(false), /** OPTIONAL - Integrations Configuration * This option allows the user to configure the included integrations * Options shown are the availble options diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index faf7fac6..a24919e3 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - fullConsoleLogs: false, + verbose: false, }), ], }); From 5f1f157152575c385333592a592138ff55effb7c Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 10:27:26 -0800 Subject: [PATCH 17/46] remove unused import --- packages/astro-ghostcms/src/astro-ghostcms.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index d9e6f5b3..74d68892 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -25,7 +25,6 @@ const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); // Import User Configuration Zod Schema import { GhostUserConfigSchema } from "./schemas/userconfig"; -import type { string } from "astro/zod"; /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project From 41b0ce75d34386dd165c0c12319cbfde42d093f1 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 10:36:00 -0800 Subject: [PATCH 18/46] Verbose log helper function added to all the others now --- .../rssfeed/astro-ghostcms-rss.ts | 9 ++++-- .../satoriog/astro-ghostcms-satoriog.ts | 11 ++++--- .../astro-ghostcms-themeprovider.ts | 31 +++++++++++-------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts index 476d9bba..d55dd18f 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -41,10 +41,13 @@ export default defineIntegration({ "RSSGenerator", )}`, ); + const verboseLogsInfo = (message:string) => { + if (options.verbose) { + RSSLogger.info(message); + } + }; - if (options.verbose) { - RSSLogger.info(c.bold(c.green("RSS Feed Setup Complete"))); - } + verboseLogsInfo(c.bold(c.green("RSS Feed Setup Complete"))); }, }; }, diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts index a3981ca7..7b2ec601 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -73,12 +73,13 @@ export default defineIntegration({ "SatoriOG", )}`, ); + const verboseLogsInfo = (message:string) => { + if (options.verbose) { + SatoriLogger.info(message); + } + }; - if (options.verbose) { - SatoriLogger.info( - c.bold(c.green("OG Image Integration Setup Complete")), - ); - } + verboseLogsInfo(c.bold(c.green("OG Image Integration Setup Complete"))); }, }; }, diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts index 0712cc3c..c43fe756 100644 --- a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts +++ b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts @@ -25,24 +25,26 @@ export default defineIntegration({ "Theme Provider", )}`, ); + const verboseLogsInfo = (message:string) => { + if (options.verbose) { + themeLogger.info(message); + } + }; + themeLogger.info( c.bold(c.magenta("Theme Provider enabled. Setting up...")), ); - if (options.verbose) { - if (options.theme === "@matthiesenxyz/astro-ghostcms-theme-default") { - themeLogger.info( + + if (options.theme === "@matthiesenxyz/astro-ghostcms-theme-default") { + verboseLogsInfo( c.blue("No theme is set, injecting default theme"), ); - } else { - themeLogger.info( - `${c.bold(c.cyan("Injecting Theme:"))} ${c.bold( - c.underline(c.magenta(options.theme)), - )}`, - ); - } + } else { + verboseLogsInfo(`${c.bold(c.cyan("Injecting Theme:"))} ${c.bold(c.underline(c.magenta(options.theme)))}`); } + injectRoute({ pattern: "/", @@ -85,10 +87,13 @@ export default defineIntegration({ "Theme Provider", )}`, ); + const verboseLogsInfo = (message:string) => { + if (options.verbose) { + themeLogger.info(message); + } + }; - if (options.verbose) { - themeLogger.info(c.bold(c.green("Provider Setup Complete"))); - } + verboseLogsInfo(c.bold(c.green("Provider Setup Complete"))); }, }; }, From aea8305ac031964317a6e6c4c4ea0c9e947999ad Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 11:11:15 -0800 Subject: [PATCH 19/46] add checkIntegration helper for sitemap and astro-robots-txt --- packages/astro-ghostcms/src/astro-ghostcms.ts | 33 +++++++++++-------- playgrounds/astro-playground/astro.config.mjs | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 74d68892..65de8314 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -15,8 +15,8 @@ import latestVersion from "./utils/latestVersion"; import sitemap from "@astrojs/sitemap"; import robotsTxt from "astro-robots-txt"; -import ghostRSS from "./integrations/rssfeed"; // Internal Integrations +import ghostRSS from "./integrations/rssfeed"; import ghostOGImages from "./integrations/satoriog"; import ghostThemeProvider from "./integrations/themeprovider"; @@ -25,6 +25,7 @@ const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); // Import User Configuration Zod Schema import { GhostUserConfigSchema } from "./schemas/userconfig"; +import type { AstroIntegration } from "astro"; /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project @@ -168,21 +169,25 @@ export default defineIntegration({ intLogInfo(c.gray("RSS Feed is disabled")); } - // @ASTROJS/SITEMAP - if (!hasIntegration("@astrojs/sitemap")) { - intLogInfo(c.bold(c.magenta(`Adding ${c.blue("@astrojs/sitemap")} integration`))); - addIntegration(sitemap(options.Integrations?.sitemap)); - } else { - intLogInfo(c.gray("@astrojs/sitemap integration already exists, skipping...")); - } - // ASTRO-ROBOTS-TXT - if (!hasIntegration("astro-robots-txt")) { - intLogInfo(c.bold(c.magenta(`Adding ${c.blue("astro-robots-txt")} integration`))); - addIntegration(robotsTxt(options.Integrations?.robotsTxt)); - } else { - intLogInfo(c.gray("astro-robots-txt integration already exists, skipping...")); + const checkIntegration = (name: string, integration: AstroIntegration) => { + if (!hasIntegration(name)) { + intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`))); + addIntegration(integration); + } else { + intLogInfo(c.gray(`${name} integration already exists, skipping...`)); + } } + checkIntegration( + "@astrojs/sitemap", + sitemap(options.Integrations?.sitemap) + ); + checkIntegration( + "astro-robots-txt", + robotsTxt(options.Integrations?.robotsTxt) + ); + + // Set up default 404 page if (!options.disableDefault404) { routeLogInfo(c.bold(c.cyan("Setting up default 404 page"))); diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index a24919e3..56707f73 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: false, + verbose: true, }), ], }); From e0372288edc988a2aabc03ce891e095563633d03 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 11:54:40 -0800 Subject: [PATCH 20/46] more helpers.... --- packages/astro-ghostcms/src/astro-ghostcms.ts | 87 +++++++++++-------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 65de8314..e2813800 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -143,32 +143,16 @@ export default defineIntegration({ c.bold(c.magenta("Configuring Enabled Integrations")), ); - // Theme Provider - if (!options.ThemeProvider?.disableThemeProvider) { - addIntegration( - ghostThemeProvider({ - theme: options.ThemeProvider?.theme, - verbose, - }), - ); - } else { - intLogInfo(c.gray("Theme Provider is disabled")); + // Local Integration Helper + const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => { + if (enabled) { + addIntegration(integration); + } else { + intLogInfo(c.gray(`${name} integration is disabled`)); + } } - - // Satori OG Images - if (options.enableOGImages) { - addIntegration(ghostOGImages({ verbose })); - } else { - intLogInfo(c.gray("OG Image Provider is disabled")); - } - - // RSS Feed - if (options.enableRSSFeed) { - addIntegration(ghostRSS({ verbose })); - } else { - intLogInfo(c.gray("RSS Feed is disabled")); - } - + + // Check External Integration Helper const checkIntegration = (name: string, integration: AstroIntegration) => { if (!hasIntegration(name)) { intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`))); @@ -178,6 +162,41 @@ export default defineIntegration({ } } + // Inject Route Helper + const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => { + if (enabled) { + routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`))); + injectRoute({ + pattern: pattern, + entrypoint: `${name}${entrypoint}`, + prerender: true, + }); + } else { + routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`)); + } + } + + localIntegration( + !options.ThemeProvider?.disableThemeProvider, + "Theme Provider", + ghostThemeProvider({ + theme: options.ThemeProvider?.theme, + verbose, + }) + ); + + localIntegration( + options.enableOGImages, + "Satori OG Images", + ghostOGImages({ verbose }) + ); + + localIntegration( + options.enableRSSFeed, + "RSS Feed", + ghostRSS({ verbose }) + ); + checkIntegration( "@astrojs/sitemap", sitemap(options.Integrations?.sitemap) @@ -186,19 +205,13 @@ export default defineIntegration({ "astro-robots-txt", robotsTxt(options.Integrations?.robotsTxt) ); - - // Set up default 404 page - if (!options.disableDefault404) { - routeLogInfo(c.bold(c.cyan("Setting up default 404 page"))); - injectRoute({ - pattern: "/404", - entrypoint: `${name}/404.astro`, - prerender: true, - }); - } else { - routeLogInfo(c.gray("Default 404 page is disabled, Skipping...")); - } + routeHelper( + "Default 404 Page", + !options.disableDefault404, + "/404", + "/404.astro" + ); // Add virtual imports for user configuration addVirtualImports({ From 5b4c3e32681f25cc9f3018574bdf427963a70b18 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:02:55 -0800 Subject: [PATCH 21/46] cleanup and OCD some code... --- packages/astro-ghostcms/package.json | 3 + packages/astro-ghostcms/src/astro-ghostcms.ts | 73 ++++++++++--------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 0a2c4e0d..31f6a096 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -56,6 +56,9 @@ "test:coverage": "vitest run --coverage", "test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'" }, + "enginesStrict": { + "node": ">=18.19.0" + }, "peerDependencies": { "astro": ">=4.4.1" }, diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index e2813800..bcc955f1 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -50,19 +50,25 @@ export default defineIntegration({ }) => { // Set up verbose logging const verbose = options.verbose; + // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); + + // Configure ENV Logger const GhostENVLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "ENV Check", )}`, ); + // Configure Integration Loggers & verbose logging const GhostIntegrationLogger = logger.fork( `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( "Integrations", )}`, ); + + // Log Info Helper const intLogInfo = (message:string) => { if (verbose) { GhostIntegrationLogger.info(message); @@ -75,12 +81,46 @@ export default defineIntegration({ "Router", )}`, ); + + // Log Route Info Helper const routeLogInfo = (message:string) => { if (verbose) { GhostRouteLogger.info(message); } }; + // Local Integration Helper + const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => { + if (enabled) { + addIntegration(integration); + } else { + intLogInfo(c.gray(`${name} integration is disabled`)); + } + } + + // Check External Integration Helper + const checkIntegration = (name: string, integration: AstroIntegration) => { + if (!hasIntegration(name)) { + intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`))); + addIntegration(integration); + } else { + intLogInfo(c.gray(`${name} integration already exists, skipping...`)); + } + } + + // Inject Route Helper + const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => { + if (enabled) { + routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`))); + injectRoute({ + pattern: pattern, + entrypoint: `${name}${entrypoint}`, + prerender: true, + }); + } else { + routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`)); + } + } // Setup Watch Integration for Hot Reload during DEV watchIntegration(resolve()); @@ -143,39 +183,6 @@ export default defineIntegration({ c.bold(c.magenta("Configuring Enabled Integrations")), ); - // Local Integration Helper - const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => { - if (enabled) { - addIntegration(integration); - } else { - intLogInfo(c.gray(`${name} integration is disabled`)); - } - } - - // Check External Integration Helper - const checkIntegration = (name: string, integration: AstroIntegration) => { - if (!hasIntegration(name)) { - intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`))); - addIntegration(integration); - } else { - intLogInfo(c.gray(`${name} integration already exists, skipping...`)); - } - } - - // Inject Route Helper - const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => { - if (enabled) { - routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`))); - injectRoute({ - pattern: pattern, - entrypoint: `${name}${entrypoint}`, - prerender: true, - }); - } else { - routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`)); - } - } - localIntegration( !options.ThemeProvider?.disableThemeProvider, "Theme Provider", From 6f78923d9201db30e58ea9c8eaab2d62937394d4 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:15:28 -0800 Subject: [PATCH 22/46] cleanup imports --- packages/astro-ghostcms/src/astro-ghostcms.ts | 15 ++++----------- playgrounds/astro-playground/astro.config.mjs | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index bcc955f1..c908340d 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,32 +1,25 @@ -// Node Modules import path from "node:path"; import { fileURLToPath } from "node:url"; import fse from "fs-extra"; - -// Utils import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; import { AstroError } from "astro/errors"; +import type { AstroIntegration } from "astro"; import c from "picocolors"; import { loadEnv } from "vite"; -import latestVersion from "./utils/latestVersion"; - -// External Integrations import sitemap from "@astrojs/sitemap"; import robotsTxt from "astro-robots-txt"; -// Internal Integrations +// Internal Imports +import { GhostUserConfigSchema } from "./schemas/userconfig"; import ghostRSS from "./integrations/rssfeed"; import ghostOGImages from "./integrations/satoriog"; import ghostThemeProvider from "./integrations/themeprovider"; +import latestVersion from "./utils/latestVersion"; // Load environment variables const ENV = loadEnv("all", process.cwd(), "CONTENT_API"); -// Import User Configuration Zod Schema -import { GhostUserConfigSchema } from "./schemas/userconfig"; -import type { AstroIntegration } from "astro"; - /** Astro-GhostCMS Integration * @description This integration allows you to use GhostCMS as a headless CMS for your Astro project * @see https://astro-ghostcms.xyz for the most up-to-date documentation! diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index 56707f73..a24919e3 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: true, + verbose: false, }), ], }); From e3080d763c89e99362a33917821afcda14a76bc3 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:31:09 -0800 Subject: [PATCH 23/46] removed unused function... i dont need to create a dts for this virtual module within the user scope --- packages/astro-ghostcms/src/astro-ghostcms.ts | 10 +--------- .../{virtual.d.ts => virtual-config.d.ts} | 0 playgrounds/astro-playground/src/env.d.ts | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) rename packages/astro-ghostcms/{virtual.d.ts => virtual-config.d.ts} (100%) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index c908340d..ec5d8ef3 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,5 +1,6 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; +import { readFileSync } from "node:fs"; import fse from "fs-extra"; import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; @@ -37,7 +38,6 @@ export default defineIntegration({ hasIntegration, addIntegration, addVirtualImports, - addDts, injectRoute, logger, }) => { @@ -220,14 +220,6 @@ export default defineIntegration({ )}`, }); - // Add types for user configuration - addDts({ - name: "@matthiesenxyz/astro-ghostcms/config", - content: `declare module "virtual:@matthiesenxyz/astro-ghostcms/config" { - const Config: import("../schemas/userconfig").GhostUserConfig; - export default Config; - }`, - }); }, "astro:config:done": ({ logger }) => { // Configure Loggers diff --git a/packages/astro-ghostcms/virtual.d.ts b/packages/astro-ghostcms/virtual-config.d.ts similarity index 100% rename from packages/astro-ghostcms/virtual.d.ts rename to packages/astro-ghostcms/virtual-config.d.ts diff --git a/playgrounds/astro-playground/src/env.d.ts b/playgrounds/astro-playground/src/env.d.ts index e49580d9..87fde0f4 100644 --- a/playgrounds/astro-playground/src/env.d.ts +++ b/playgrounds/astro-playground/src/env.d.ts @@ -1,3 +1,3 @@ /// /// -/// +/// \ No newline at end of file From 5cfea0a0a7ec93b2e0e1dca79aaff422d0066041 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:32:42 -0800 Subject: [PATCH 24/46] remove unused import --- packages/astro-ghostcms/src/astro-ghostcms.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index ec5d8ef3..a704028f 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,6 +1,5 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; -import { readFileSync } from "node:fs"; import fse from "fs-extra"; import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; From 621bafbd61f2bb1c4ca2e6596b797ae2dc7dea19 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:39:42 -0800 Subject: [PATCH 25/46] update deps --- packages/astro-ghostcms/package.json | 4 +- packages/astro-ghostcms/src/astro-ghostcms.ts | 1 + pnpm-lock.yaml | 47 +++++++++++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 31f6a096..6e38ac4d 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -70,12 +70,12 @@ }, "dependencies": { "@astrojs/rss": "^4.0.5", - "@astrojs/sitemap": "^3.0.5", + "@astrojs/sitemap": "^3.1.1", "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.13", "@resvg/resvg-js": "^2.6.0", "@ts-ghost/core-api": "^6.0.0", "@ts-ghost/content-api": "^4.0.12", - "astro-integration-kit": "^0.5.0", + "astro-integration-kit": "^0.5.1", "astro-robots-txt": "^1.0.0", "fs-extra": "^11.2.0", "package-json": "^10.0.0", diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index a704028f..7a4f5a17 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -200,6 +200,7 @@ export default defineIntegration({ "@astrojs/sitemap", sitemap(options.Integrations?.sitemap) ); + checkIntegration( "astro-robots-txt", robotsTxt(options.Integrations?.robotsTxt) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7308e6f2..1093d096 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,8 +30,8 @@ importers: specifier: ^4.0.5 version: 4.0.5 '@astrojs/sitemap': - specifier: ^3.0.5 - version: 3.0.5 + specifier: ^3.1.1 + version: 3.1.1 '@matthiesenxyz/astro-ghostcms-theme-default': specifier: ^0.1.13 version: link:../astro-ghostcms-theme-default @@ -48,8 +48,8 @@ importers: specifier: '>=4.4.1' version: 4.4.9(@types/node@20.11.24) astro-integration-kit: - specifier: ^0.5.0 - version: 0.5.0(astro@4.4.9) + specifier: ^0.5.1 + version: 0.5.1(astro@4.4.9) astro-robots-txt: specifier: ^1.0.0 version: 1.0.0 @@ -464,8 +464,8 @@ packages: kleur: 4.1.5 dev: false - /@astrojs/sitemap@3.0.5: - resolution: {integrity: sha512-60eLzNjMza3ABypiQPUC6ElOSZNZeY5CwSwgJ03hfeonl+Db9x12CCzBFdTw7A5Mq+O54xEZVUrR0tB+yWgX8w==} + /@astrojs/sitemap@3.1.1: + resolution: {integrity: sha512-qPgdBIcDUaea98mTtLfi5z9oXZpzSjEn/kes70/Ex8FOZZ+DIHVKRYOLOtvy8p+FTXr/9oc7BjmIbTYmYLLJVg==} dependencies: sitemap: 7.1.1 zod: 3.22.4 @@ -476,7 +476,7 @@ packages: astro: ^4.2.7 dependencies: '@astrojs/mdx': 2.1.1(astro@4.4.0) - '@astrojs/sitemap': 3.0.5 + '@astrojs/sitemap': 3.1.1 '@pagefind/default-ui': 1.0.4 '@types/hast': 3.0.4 '@types/mdast': 4.0.3 @@ -2649,6 +2649,13 @@ packages: resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} dev: true + /ast-types@0.16.1: + resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==} + engines: {node: '>=4'} + dependencies: + tslib: 2.6.2 + dev: false + /astring@1.8.6: resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} hasBin: true @@ -2683,8 +2690,8 @@ packages: resolution: {integrity: sha512-dh5TX2uxwqdFq15DF9cbRZgEdE9o8q522MP6xZYs+rnd3dexfDsIJMeEIDNVO7rkRxwJ7sphhCqTmdWvUJaiDg==} dev: false - /astro-integration-kit@0.5.0(astro@4.4.9): - resolution: {integrity: sha512-RbviqerotzLoVBGF8L1aFw5jIP40oWKScRXuzJNp399uDnPMPq7/cIh2x3MIS62U17h7o3d0S3kGt/Ael+tj1g==} + /astro-integration-kit@0.5.1(astro@4.4.9): + resolution: {integrity: sha512-ef309UUNOjxUe0jjsDP5O3p+jkt53HAcrKOsWJ2NIgdUTOp5P/YKnAjbatfyu3bAuLFDfj5xhXm/rrwSe9d/hw==} peerDependencies: '@vitejs/plugin-react': ^4.2.1 astro: ^4.4.1 @@ -2709,6 +2716,7 @@ packages: dependencies: astro: 4.4.9(@types/node@20.11.24) pathe: 1.1.2 + recast: 0.23.5 dev: false /astro-navbar@2.3.1: @@ -6606,6 +6614,17 @@ packages: dependencies: picomatch: 2.3.1 + /recast@0.23.5: + resolution: {integrity: sha512-M67zIddJiwXdfPQRYKJ0qZO1SLdH1I0hYeb0wzxA+pNOvAZiQHulWzuk+fYsEWRQ8VfZrgjyucqsCOtCyM01/A==} + engines: {node: '>= 4'} + dependencies: + ast-types: 0.16.1 + esprima: 4.0.1 + source-map: 0.6.1 + tiny-invariant: 1.3.3 + tslib: 2.6.2 + dev: false + /redent@3.0.0: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} @@ -7096,6 +7115,11 @@ packages: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} + /source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + dev: false + /source-map@0.7.4: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} engines: {node: '>= 8'} @@ -7443,6 +7467,10 @@ packages: resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} dev: false + /tiny-invariant@1.3.3: + resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} + dev: false + /tinybench@2.6.0: resolution: {integrity: sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==} dev: true @@ -7518,7 +7546,6 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - dev: true /tty-table@4.2.3: resolution: {integrity: sha512-Fs15mu0vGzCrj8fmJNP7Ynxt5J7praPXqFN0leZeZBXJwkMxv9cb2D454k1ltrtUSJbZ4yH4e0CynsHLxmUfFA==} From c0772052153de853ce7b2a76f8d8e42153784425 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:43:45 -0800 Subject: [PATCH 26/46] updated and verified tests are still working --- .../src/schemas/userconfig.test.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts index 2f7a503d..72705928 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.test.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -12,7 +12,7 @@ describe("GhostUserConfigSchema", () => { disableDefault404: false, enableRSSFeed: true, enableOGImages: true, - fullConsoleLogs: false, + verbose: false, }; const result = GhostUserConfigSchema.safeParse(validConfig); @@ -32,13 +32,15 @@ describe("GhostUserConfigSchema", () => { disableDefault404: "false", enableRSSFeed: "true", enableOGImages: "true", - sitemap: { - // invalid sitemap configuration + Integrations: { + sitemap: { + // invalid sitemap configuration + }, + robotstxt: { + // invalid robotstxt configuration + }, }, - robotstxt: { - // invalid robotstxt configuration - }, - fullConsoleLogs: "false", + verbose: "false", }; const result = GhostUserConfigSchema.safeParse(invalidConfig); From f881e4f2a6ad452a48f3c87b533d80102835ffe5 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:50:20 -0800 Subject: [PATCH 27/46] change path resolver to `AIK` resolve function now that i figured it out... XD --- packages/astro-ghostcms/src/astro-ghostcms.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 7a4f5a17..26a21dc7 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -1,5 +1,3 @@ -import path from "node:path"; -import { fileURLToPath } from "node:url"; import fse from "fs-extra"; import { createResolver, defineIntegration } from "astro-integration-kit"; import { corePlugins } from "astro-integration-kit/plugins"; @@ -200,7 +198,7 @@ export default defineIntegration({ "@astrojs/sitemap", sitemap(options.Integrations?.sitemap) ); - + checkIntegration( "astro-robots-txt", robotsTxt(options.Integrations?.robotsTxt) @@ -260,9 +258,7 @@ export default defineIntegration({ ); // Get the local version of Astro-GhostCMS - const packageJson = await fse.readJson( - path.resolve(fileURLToPath(import.meta.url), "../../package.json"), - ); + const packageJson = await fse.readJson(resolve("../package.json")); const localVersion = packageJson.version; // Log the version check From ee0d5b51474426aedc9a401a741b3a6f03ee3141 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 4 Mar 2024 12:58:42 -0800 Subject: [PATCH 28/46] more internal code notes! --- packages/astro-ghostcms/src/astro-ghostcms.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 26a21dc7..88a6dc94 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -126,6 +126,7 @@ export default defineIntegration({ ), ); + // Check for GhostCMS API Key if (ENV.CONTENT_API_KEY === undefined) { GhostENVLogger.error( c.bgRed( @@ -139,6 +140,7 @@ export default defineIntegration({ ); } + // Check for GhostCMS URL if (options.ghostURL === undefined) { GhostENVLogger.warn( c.bgYellow( @@ -173,6 +175,7 @@ export default defineIntegration({ c.bold(c.magenta("Configuring Enabled Integrations")), ); + // Setup GhostCMS Theme Provider localIntegration( !options.ThemeProvider?.disableThemeProvider, "Theme Provider", @@ -182,28 +185,33 @@ export default defineIntegration({ }) ); + // Setup GhostCMS OG Image Provider localIntegration( options.enableOGImages, "Satori OG Images", ghostOGImages({ verbose }) ); + // Setup GhostCMS RSS Feed Provider localIntegration( options.enableRSSFeed, "RSS Feed", ghostRSS({ verbose }) ); + // Setup @astrojs/sitemap Integration checkIntegration( "@astrojs/sitemap", sitemap(options.Integrations?.sitemap) ); + // Setup astro-robots-txt Integration checkIntegration( "astro-robots-txt", robotsTxt(options.Integrations?.robotsTxt) ); + // Setup Default 404 Page routeHelper( "Default 404 Page", !options.disableDefault404, From 0441bc0fad58169ad0db37419da4ec853a26f99e Mon Sep 17 00:00:00 2001 From: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:00:32 -0800 Subject: [PATCH 29/46] Update changeset-main.yml --- .github/workflows/changeset-main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changeset-main.yml b/.github/workflows/changeset-main.yml index 229b72ab..52f7b42f 100644 --- a/.github/workflows/changeset-main.yml +++ b/.github/workflows/changeset-main.yml @@ -29,7 +29,7 @@ jobs: with: version: pnpm ci:version commit: "chore: update versions" - title: "chore: update versions" + title: "Chore: Ready for Release" publish: pnpm ci:publish env: - GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e73131984b1552260d9da33983b8484a87d539ae Mon Sep 17 00:00:00 2001 From: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:18:29 -0800 Subject: [PATCH 30/46] Update changeset-main.yml --- .github/workflows/changeset-main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changeset-main.yml b/.github/workflows/changeset-main.yml index 52f7b42f..f3dc9849 100644 --- a/.github/workflows/changeset-main.yml +++ b/.github/workflows/changeset-main.yml @@ -3,6 +3,9 @@ on: push: branches: - main +permissions: + pull-requests: write + contents: write env: CI: true jobs: @@ -17,7 +20,7 @@ jobs: - name: setup node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: install pnpm run: npm i pnpm@latest -g - name: Setup npmrc @@ -25,7 +28,7 @@ jobs: - name: install dependencies run: pnpm install - name: create and publish versions - uses: matthiesenxyz/changeset-action@v1 + uses: changesets/action@v1 with: version: pnpm ci:version commit: "chore: update versions" From 30ad4ac35577f354e9eeaa2abde0bc042c8c5d55 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:48:29 -0800 Subject: [PATCH 31/46] Update changeset-main.yml --- .github/workflows/changeset-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/changeset-main.yml b/.github/workflows/changeset-main.yml index f3dc9849..b2337290 100644 --- a/.github/workflows/changeset-main.yml +++ b/.github/workflows/changeset-main.yml @@ -28,7 +28,7 @@ jobs: - name: install dependencies run: pnpm install - name: create and publish versions - uses: changesets/action@v1 + uses: matthiesenxyz/changeset@v1 with: version: pnpm ci:version commit: "chore: update versions" From b50e8882cc3c230448688b2bc4d2ce66c0e218eb Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 00:11:03 -0800 Subject: [PATCH 32/46] better config typings... made it way better XD --- packages/astro-ghostcms/src/astro-ghostcms.ts | 4 +-- .../rssfeed/astro-ghostcms-rss.ts | 2 +- .../satoriog/astro-ghostcms-satoriog.ts | 2 +- .../astro-ghostcms-themeprovider.ts | 11 ++++---- .../src/schemas/userconfig.test.ts | 1 + .../astro-ghostcms/src/schemas/userconfig.ts | 28 +++++++++++-------- playgrounds/astro-playground/astro.config.mjs | 2 +- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 88a6dc94..1ea43d48 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -177,10 +177,10 @@ export default defineIntegration({ // Setup GhostCMS Theme Provider localIntegration( - !options.ThemeProvider?.disableThemeProvider, + !options.ThemeProvider.disableThemeProvider, "Theme Provider", ghostThemeProvider({ - theme: options.ThemeProvider?.theme, + theme: options.ThemeProvider.theme, verbose, }) ); diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts index d55dd18f..e2100c3f 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -6,7 +6,7 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-rss", optionsSchema: z.object({ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts index 7b2ec601..d8cc56c3 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -6,7 +6,7 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-satoriog", optionsSchema: z.object({ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { diff --git a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts index c43fe756..4a463756 100644 --- a/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts +++ b/packages/astro-ghostcms/src/integrations/themeprovider/astro-ghostcms-themeprovider.ts @@ -6,16 +6,15 @@ import c from "picocolors"; export default defineIntegration({ name: "@matthiesenxyz/astro-ghostcms-themeprovider", optionsSchema: z.object({ - theme: z - .string() - .optional() - .default("@matthiesenxyz/astro-ghostcms-theme-default"), - verbose: z.boolean().optional().default(false), + theme: z.string(), + verbose: z.coerce.boolean().optional(), }), plugins: [...corePlugins], setup({ options }) { const { resolve } = createResolver(import.meta.url); + const DEFAULT_THEME = "@matthiesenxyz/astro-ghostcms-theme-default"; + return { "astro:config:setup": ({ watchIntegration, injectRoute, logger }) => { watchIntegration(resolve()); @@ -37,7 +36,7 @@ export default defineIntegration({ ); - if (options.theme === "@matthiesenxyz/astro-ghostcms-theme-default") { + if (options.theme === DEFAULT_THEME) { verboseLogsInfo( c.blue("No theme is set, injecting default theme"), ); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.test.ts b/packages/astro-ghostcms/src/schemas/userconfig.test.ts index 72705928..1c394da8 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.test.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.test.ts @@ -13,6 +13,7 @@ describe("GhostUserConfigSchema", () => { enableRSSFeed: true, enableOGImages: true, verbose: false, + Integrations: {}, }; const result = GhostUserConfigSchema.safeParse(validConfig); diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index 23455f06..10ad2a75 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -13,34 +13,38 @@ export const GhostUserConfigSchema = z.object({ * }) * ], * }); */ - ghostURL: z.string().url().optional(), + ghostURL: z.coerce.string().url("Must be a URL").optional(), + /** OPTIONAL - Configure the Theme Provider + * @ This option allows the user to configure the Theme Provider + */ ThemeProvider: z .object({ /** OPTIONAL - Disable the theme provider * @default false */ - disableThemeProvider: z.boolean().optional().default(false), + disableThemeProvider: z.coerce.boolean(), /** OPTIONAL - Set the theme you want to use * @default "@matthiesenxyz/astro-ghostcms-theme-default" */ - theme: z - .string() - .optional() - .default("@matthiesenxyz/astro-ghostcms-theme-default"), + theme: z.string(), }) - .optional(), + .optional() + .default({ + disableThemeProvider: false, + theme: "@matthiesenxyz/astro-ghostcms-theme-default" + }), /** Allows the user to disable the provided 404 page */ - disableDefault404: z.boolean().optional().default(false), + disableDefault404: z.coerce.boolean().optional(), /** Allows the user to disable the provided RSS Feed */ - enableRSSFeed: z.boolean().optional().default(true), + enableRSSFeed: z.coerce.boolean().optional().default(true), /** Allows the user to Enable or Disable the default Satori OG Image Generation * @default true */ - enableOGImages: z.boolean().optional().default(true), + enableOGImages: z.coerce.boolean().optional().default(true), /** Allows the user to turn on/off Full Console Logs * @default true */ - verbose: z.boolean().optional().default(false), + verbose: z.coerce.boolean().optional(), /** OPTIONAL - Integrations Configuration * This option allows the user to configure the included integrations * Options shown are the availble options @@ -60,7 +64,7 @@ export const GhostUserConfigSchema = z.object({ */ sitemap: z.custom().optional(), }) - .optional(), + .optional().default({}), }); /** USER CONFIGURATION SCHEMA */ diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index a24919e3..56707f73 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: false, + verbose: true, }), ], }); From 01ad923e30b61e60627b21e7c74c978d969828c0 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 00:14:18 -0800 Subject: [PATCH 33/46] last change.... i forgot to remove those two `?` marks as they are no longer required --- packages/astro-ghostcms/src/astro-ghostcms.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 1ea43d48..3516fb21 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -202,13 +202,13 @@ export default defineIntegration({ // Setup @astrojs/sitemap Integration checkIntegration( "@astrojs/sitemap", - sitemap(options.Integrations?.sitemap) + sitemap(options.Integrations.sitemap) ); // Setup astro-robots-txt Integration checkIntegration( "astro-robots-txt", - robotsTxt(options.Integrations?.robotsTxt) + robotsTxt(options.Integrations.robotsTxt) ); // Setup Default 404 Page From bc3ec6d6536141e47db6d8e31903010af70d9ae8 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 01:01:59 -0800 Subject: [PATCH 34/46] fix casing --- packages/astro-ghostcms/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro-ghostcms/src/index.ts b/packages/astro-ghostcms/src/index.ts index b7e3d1eb..0bcf5e48 100644 --- a/packages/astro-ghostcms/src/index.ts +++ b/packages/astro-ghostcms/src/index.ts @@ -1,3 +1,3 @@ -import astroghostcms from "./astro-ghostcms"; +import astroGhostCMS from "./astro-ghostcms"; -export default astroghostcms; +export default astroGhostCMS; From b1d7a044cff86b34cfbfd5ba18bae657cf8a83f7 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 01:16:10 -0800 Subject: [PATCH 35/46] new logging --- packages/astro-ghostcms/src/astro-ghostcms.ts | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 3516fb21..0333e22b 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -44,19 +44,18 @@ export default defineIntegration({ // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); + const loggerTagged = (message: string) => { + return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}`) + } + // Configure ENV Logger - const GhostENVLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "ENV Check", - )}`, - ); + const GhostENVLogger = loggerTagged("ENV Check"); // Configure Integration Loggers & verbose logging - const GhostIntegrationLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "Integrations", - )}`, - ); + const GhostIntegrationLogger = loggerTagged("Integrations"); + + // Configure Route Logger & verbose logging + const GhostRouteLogger = loggerTagged("Router"); // Log Info Helper const intLogInfo = (message:string) => { @@ -65,13 +64,6 @@ export default defineIntegration({ } }; - // Configure Route Logger & verbose logging - const GhostRouteLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "Router", - )}`, - ); - // Log Route Info Helper const routeLogInfo = (message:string) => { if (verbose) { @@ -241,17 +233,13 @@ export default defineIntegration({ ); }, "astro:server:start": async ({ logger }) => { + const loggerTagged = (message: string) => { + return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green(message)}`) + } // Configure Loggers - const GhostLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( - c.green("DEV"), - )}`, - ); - const GhostUpdateLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( - c.green("VERSION CHECK"), - )}`, - ); + const GhostLogger = loggerTagged("DEV"); + + const GhostUpdateLogger = loggerTagged("VERSION CHECK"); // Start the DEV server GhostLogger.info( From 9f6f1371553d89721624f07af4af8a8f72f02478 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 01:30:10 -0800 Subject: [PATCH 36/46] Change all InjectRoute entrypoints to utilitze the `createResolver` `resolve()` Util --- packages/astro-ghostcms/package.json | 5 +---- packages/astro-ghostcms/src/astro-ghostcms.ts | 2 +- .../src/integrations/rssfeed/astro-ghostcms-rss.ts | 6 ++---- .../satoriog/astro-ghostcms-satoriog.ts | 14 ++++++-------- playgrounds/astro-playground/astro.config.mjs | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/astro-ghostcms/package.json b/packages/astro-ghostcms/package.json index 6e38ac4d..30d210f9 100644 --- a/packages/astro-ghostcms/package.json +++ b/packages/astro-ghostcms/package.json @@ -45,10 +45,7 @@ "exports": { ".": "./src/index.ts", "./api": "./src/api/index.ts", - "./404.astro": "./src/routes/404.astro", - "./rss-routes/*": "./src/integrations/rssfeed/routes/*", - "./satoriOG": "./src/integrations/satoriog/satori.ts", - "./open-graph/*": "./src/integrations/satoriog/routes/*" + "./satoriOG": "./src/integrations/satoriog/satori.ts" }, "scripts": { "test": "vitest run", diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 0333e22b..21c401ab 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -96,7 +96,7 @@ export default defineIntegration({ routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`))); injectRoute({ pattern: pattern, - entrypoint: `${name}${entrypoint}`, + entrypoint: resolve(`./routes${entrypoint}`), prerender: true, }); } else { diff --git a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts index e2100c3f..3828f8c6 100644 --- a/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts +++ b/packages/astro-ghostcms/src/integrations/rssfeed/astro-ghostcms-rss.ts @@ -23,16 +23,14 @@ export default defineIntegration({ RSSLogger.info(c.bold(c.magenta("RSS Feed Enabled. Setting up..."))); - const rssRoute = "@matthiesenxyz/astro-ghostcms/rss-routes"; - injectRoute({ pattern: "/rss-style.xsl", - entrypoint: `${rssRoute}/rss-style.xsl.ts`, + entrypoint: resolve("./routes/rss-style.xsl.ts"), }); injectRoute({ pattern: "/rss.xml", - entrypoint: `${rssRoute}/rss.xml.ts`, + entrypoint: resolve("./routes/rss.xml.ts"), }); }, "astro:config:done": ({ logger }) => { diff --git a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts index d8cc56c3..eba963b3 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/astro-ghostcms-satoriog.ts @@ -31,36 +31,34 @@ export default defineIntegration({ c.bold(c.magenta("OG Image Integration Enabled. Setting up...")), ); - const pkgname = "@matthiesenxyz/astro-ghostcms/open-graph"; - injectRoute({ pattern: "/open-graph/[slug].png", - entrypoint: `${pkgname}/[slug].png.ts`, + entrypoint: resolve("./routes/[slug].png.ts"), }); injectRoute({ pattern: "/open-graph/index.png", - entrypoint: `${pkgname}/index.png.ts`, + entrypoint: resolve("./routes/index.png.ts"), }); injectRoute({ pattern: "/open-graph/authors.png", - entrypoint: `${pkgname}/authors.png.ts`, + entrypoint: resolve("./routes/authors.png.ts"), }); injectRoute({ pattern: "/open-graph/author/[slug].png", - entrypoint: `${pkgname}/author/[slug].png.ts`, + entrypoint: resolve("./routes/author/[slug].png.ts"), }); injectRoute({ pattern: "/open-graph/tags.png", - entrypoint: `${pkgname}/tags.png.ts`, + entrypoint: resolve("./routes/tags.png.ts"), }); injectRoute({ pattern: "/open-graph/tag/[slug].png", - entrypoint: `${pkgname}/tag/[slug].png.ts`, + entrypoint: resolve("./routes/tag/[slug].png.ts"), }); updateConfig({ diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index 56707f73..a24919e3 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -14,7 +14,7 @@ export default defineConfig({ ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: true, + verbose: false, }), ], }); From 9ec2a6178279bb5c2dd9bcf37b439e782fa6315f Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 19:00:22 -0800 Subject: [PATCH 37/46] Updates to starlight-ghostcms and create-astro-ghostcms --- .changeset/heavy-maps-act.md | 5 + .changeset/quiet-teachers-knock.md | 5 + .../src/templates/basic/package.json | 6 +- .../src/templates/brutal/astro.config.mjs | 8 +- .../src/templates/brutal/package.json | 6 +- .../src/templates/catppuccin/astro.config.mjs | 8 +- .../src/templates/catppuccin/package.json | 6 +- .../src/templates/starterkit/astro.config.mjs | 11 +- .../src/templates/starterkit/package.json | 4 +- packages/starlight-ghostcms/package.json | 12 +- .../src/overrides/Sidebar.astro | 2 +- .../src/routes/authors.astro | 2 +- .../src/utils/api/content-api/content-api.ts | 116 ------- .../src/utils/api/content-api/index.ts | 8 - .../api/content-api/schemas/authors/index.ts | 1 - .../api/content-api/schemas/helpers/index.ts | 1 - .../api/content-api/schemas/pages/index.ts | 1 - .../api/content-api/schemas/posts/index.ts | 1 - .../api/content-api/schemas/settings/index.ts | 1 - .../api/content-api/schemas/tags/index.ts | 1 - .../api/content-api/schemas/tiers/index.ts | 1 - .../content-api.test.ts => ghostAPI.test.ts} | 20 +- .../api/{api-functions.ts => ghostAPI.ts} | 59 ++-- .../starlight-ghostcms/src/utils/api/index.ts | 4 +- .../src/utils/api/invariant.ts | 1 - .../authors => schemas}/authors.test.ts | 8 +- .../schemas/authors => schemas}/authors.ts | 0 .../api/{content-api => }/schemas/index.ts | 2 +- .../schemas/pages => schemas}/pages.ts | 4 +- .../schemas/posts => schemas}/posts.test.ts | 12 +- .../schemas/posts => schemas}/posts.ts | 4 +- .../src/utils/api/schemas/settings.test.ts | 39 +++ .../schemas/settings => schemas}/settings.ts | 0 .../schemas/helpers => schemas}/socials.ts | 0 .../schemas/tags => schemas}/tags.ts | 0 .../schemas/tiers => schemas}/tiers.ts | 0 playgrounds/astro-playground/astro.config.mjs | 4 +- playgrounds/astro-playground/package.json | 1 + pnpm-lock.yaml | 294 ++++-------------- 39 files changed, 212 insertions(+), 446 deletions(-) create mode 100644 .changeset/heavy-maps-act.md create mode 100644 .changeset/quiet-teachers-knock.md delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/content-api.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/index.ts delete mode 100644 packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/index.ts rename packages/starlight-ghostcms/src/utils/api/{content-api/content-api.test.ts => ghostAPI.test.ts} (82%) rename packages/starlight-ghostcms/src/utils/api/{api-functions.ts => ghostAPI.ts} (72%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/authors => schemas}/authors.test.ts (95%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/authors => schemas}/authors.ts (100%) rename packages/starlight-ghostcms/src/utils/api/{content-api => }/schemas/index.ts (85%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/pages => schemas}/pages.ts (94%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/posts => schemas}/posts.test.ts (87%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/posts => schemas}/posts.ts (95%) create mode 100644 packages/starlight-ghostcms/src/utils/api/schemas/settings.test.ts rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/settings => schemas}/settings.ts (100%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/helpers => schemas}/socials.ts (100%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/tags => schemas}/tags.ts (100%) rename packages/starlight-ghostcms/src/utils/api/{content-api/schemas/tiers => schemas}/tiers.ts (100%) diff --git a/.changeset/heavy-maps-act.md b/.changeset/heavy-maps-act.md new file mode 100644 index 00000000..51b68206 --- /dev/null +++ b/.changeset/heavy-maps-act.md @@ -0,0 +1,5 @@ +--- +"@matthiesenxyz/create-astro-ghostcms": minor +--- + +Bumb all templates to new `astro-ghostcms` version v3.3 diff --git a/.changeset/quiet-teachers-knock.md b/.changeset/quiet-teachers-knock.md new file mode 100644 index 00000000..9d4b6fae --- /dev/null +++ b/.changeset/quiet-teachers-knock.md @@ -0,0 +1,5 @@ +--- +"@matthiesenxyz/starlight-ghostcms": minor +--- + +Bumb GhostCMS API, No user facing breaking changes. diff --git a/packages/create-astro-ghostcms/src/templates/basic/package.json b/packages/create-astro-ghostcms/src/templates/basic/package.json index 9882e8fb..155d14f8 100644 --- a/packages/create-astro-ghostcms/src/templates/basic/package.json +++ b/packages/create-astro-ghostcms/src/templates/basic/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.2.8", - "@matthiesenxyz/astro-ghostcms": "^3.1.5", - "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.5" + "astro": "^4.4.0", + "@matthiesenxyz/astro-ghostcms": "^3.3.0", + "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.13" }, "devDependencies": { "@astrojs/check": "^0.4.1", diff --git a/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs b/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs index a96a01f0..f82f45a0 100644 --- a/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs +++ b/packages/create-astro-ghostcms/src/templates/brutal/astro.config.mjs @@ -1,4 +1,4 @@ -import ghostcms from "@matthiesenxyz/astro-ghostcms"; +import astroGhostCMS from "@matthiesenxyz/astro-ghostcms"; import { defineConfig } from "astro/config"; import UnoCSS from "unocss/astro"; @@ -8,9 +8,11 @@ export default defineConfig({ trailingSlash: "ignore", integrations: [ UnoCSS({ injectReset: true }), - ghostcms({ - theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", + astroGhostCMS({ ghostURL: "https://ghostdemo.matthiesen.xyz", + ThemeProvider: { + theme: "@matthiesenxyz/astro-ghostcms-brutal", + }, }), ], }); diff --git a/packages/create-astro-ghostcms/src/templates/brutal/package.json b/packages/create-astro-ghostcms/src/templates/brutal/package.json index 3f35d750..f23c6966 100644 --- a/packages/create-astro-ghostcms/src/templates/brutal/package.json +++ b/packages/create-astro-ghostcms/src/templates/brutal/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.3.2", - "@matthiesenxyz/astro-ghostcms": "^3.2.2", - "@matthiesenxyz/astro-ghostcms-brutalbyelian": "^0.0.5", + "astro": "^4.4.0", + "@matthiesenxyz/astro-ghostcms": "^3.3.0", + "@matthiesenxyz/astro-ghostcms-brutalbyelian": "^0.0.11", "@unocss/astro": "^0.57.7" }, "devDependencies": { diff --git a/packages/create-astro-ghostcms/src/templates/catppuccin/astro.config.mjs b/packages/create-astro-ghostcms/src/templates/catppuccin/astro.config.mjs index ebb71227..720c7e04 100644 --- a/packages/create-astro-ghostcms/src/templates/catppuccin/astro.config.mjs +++ b/packages/create-astro-ghostcms/src/templates/catppuccin/astro.config.mjs @@ -1,5 +1,5 @@ import tailwind from "@astrojs/tailwind"; -import ghostcms from "@matthiesenxyz/astro-ghostcms"; +import astroGhostCMS from "@matthiesenxyz/astro-ghostcms"; import { defineConfig } from "astro/config"; // https://astro.build/config @@ -7,9 +7,11 @@ export default defineConfig({ site: "https://example.xyz/", integrations: [ tailwind(), - ghostcms({ - theme: "@matthiesenxyz/astro-ghostcms-catppuccin", + astroGhostCMS({ ghostURL: "https://ghostdemo.matthiesen.xyz", + ThemeProvider: { + theme: "@matthiesenxyz/astro-ghostcms-catppuccin", + }, }), ], }); diff --git a/packages/create-astro-ghostcms/src/templates/catppuccin/package.json b/packages/create-astro-ghostcms/src/templates/catppuccin/package.json index a4d190a7..622d693c 100644 --- a/packages/create-astro-ghostcms/src/templates/catppuccin/package.json +++ b/packages/create-astro-ghostcms/src/templates/catppuccin/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.2.8", - "@matthiesenxyz/astro-ghostcms": "^3.1.8", - "@matthiesenxyz/astro-ghostcms-catppuccin": "^0.0.3", + "astro": "^4.4.0", + "@matthiesenxyz/astro-ghostcms": "^3.3.0", + "@matthiesenxyz/astro-ghostcms-catppuccin": "^0.0.8", "@astrojs/tailwind": "^5.1.0", "tailwindcss": "^3.3.5" }, diff --git a/packages/create-astro-ghostcms/src/templates/starterkit/astro.config.mjs b/packages/create-astro-ghostcms/src/templates/starterkit/astro.config.mjs index 49d63c42..3c99e570 100644 --- a/packages/create-astro-ghostcms/src/templates/starterkit/astro.config.mjs +++ b/packages/create-astro-ghostcms/src/templates/starterkit/astro.config.mjs @@ -9,10 +9,13 @@ export default defineConfig({ // Includes GhostCMS API, @astrojs/rss, @astrojs/sitemap, and astro-robots-txt GhostCMS({ ghostURL: "https://ghostdemo.matthiesen.xyz", - // This Option Disables all default theme injection and allows DIY mode. - disableRouteInjection: true, - // Enable this to disable the extra console logs - disableConsoleOutput: false, + ThemeProvider: { + disableThemeProvider: true, + }, + disableDefault404: true, + enableRSSFeed: false, + enableOGImages: false, + verbose: false, }), ], }); diff --git a/packages/create-astro-ghostcms/src/templates/starterkit/package.json b/packages/create-astro-ghostcms/src/templates/starterkit/package.json index 7684d5b8..382cb805 100644 --- a/packages/create-astro-ghostcms/src/templates/starterkit/package.json +++ b/packages/create-astro-ghostcms/src/templates/starterkit/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "@astrojs/check": "^0.4.1", - "@matthiesenxyz/astro-ghostcms": "^3.1.4", - "astro": "^4.2.8", + "@matthiesenxyz/astro-ghostcms": "^3.3.0", + "astro": "^4.4.0", "typescript": "^5.3.3", "astro-font": "^0.0.77" }, diff --git a/packages/starlight-ghostcms/package.json b/packages/starlight-ghostcms/package.json index 716f8eb5..58820694 100644 --- a/packages/starlight-ghostcms/package.json +++ b/packages/starlight-ghostcms/package.json @@ -60,19 +60,19 @@ }, "devDependencies": { "@astrojs/starlight": "^0.19.0", - "@ts-ghost/tsconfig": "workspace:*", "astro": "^4.4.0", - "vitest": "^1.2.2", + "vitest": "^1.3.1", "vitest-fetch-mock": "^0.2.2" }, "dependencies": { "@astrojs/rss": "^4.0.5", - "@ts-ghost/core-api": "5.1.2", - "vite": "^5.1.2", - "vite-tsconfig-paths": "^4.2.2" + "@ts-ghost/core-api": "^6.0.0", + "@ts-ghost/content-api": "^4.0.12", + "vite": "^5.1.5", + "vite-tsconfig-paths": "^4.3.1" }, "peerDependencies": { "@astrojs/starlight": ">=0.19.0", - "astro": ">=4.3.7" + "astro": ">=4.4.0" } } diff --git a/packages/starlight-ghostcms/src/overrides/Sidebar.astro b/packages/starlight-ghostcms/src/overrides/Sidebar.astro index a75b80b9..5319d41a 100644 --- a/packages/starlight-ghostcms/src/overrides/Sidebar.astro +++ b/packages/starlight-ghostcms/src/overrides/Sidebar.astro @@ -3,7 +3,7 @@ import StarlightSidebar from '@astrojs/starlight/components/Sidebar.astro' import type { Props } from '@astrojs/starlight/props' import config from 'virtual:starlight-ghost-config' import { isBlogPostPage, isBlogRoot } from '../utils/page' -import { getAllPages, getAllPosts, getSluggedPage } from '../utils/api/api-functions.js' +import { getAllPages, getAllPosts, getSluggedPage } from '../utils/api' import type { SidebarEntry } from './sidebartypes' export async function getRecentBlogEntries(){ diff --git a/packages/starlight-ghostcms/src/routes/authors.astro b/packages/starlight-ghostcms/src/routes/authors.astro index 0d965af0..f446ef52 100644 --- a/packages/starlight-ghostcms/src/routes/authors.astro +++ b/packages/starlight-ghostcms/src/routes/authors.astro @@ -2,7 +2,7 @@ import config from 'virtual:starlight-ghost-config' import Page from '../components/Page.astro' //import PrevNextLinks from '../components/PrevNextLinks.astro' -import { getAllAuthors } from '../utils/api/api-functions' +import { getAllAuthors } from '../utils/api' import { getPageProps } from '../utils/page' import AdvancedAuthorCard from '../components/AdvancedAuthorCard.astro'; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/content-api.ts b/packages/starlight-ghostcms/src/utils/api/content-api/content-api.ts deleted file mode 100644 index 6035e96a..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/content-api.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { - APIComposer, - BasicFetcher, - HTTPClient, - contentAPICredentialsSchema, - slugOrIdSchema, -} from "@ts-ghost/core-api"; - -import { - authorsIncludeSchema, - authorsSchema, - pagesIncludeSchema, - pagesSchema, - postsIncludeSchema, - postsSchema, - settingsSchema, - tagsIncludeSchema, - tagsSchema, - tiersIncludeSchema, - tiersSchema, -} from "./schemas"; - -export type { ContentAPICredentials, APIVersions } from "@ts-ghost/core-api"; - -export enum BrowseEndpointType { - authors = "authors", - tiers = "tiers", - posts = "posts", - pages = "pages", - tags = "tags", - settings = "settings", -} - -export default class TS_API { - private httpClient: HTTPClient; - - constructor( - protected readonly url: string, - protected readonly key: string, - protected readonly version: Version, - ) { - const apiCredentials = contentAPICredentialsSchema.parse({ - key, - version, - url, - }); - this.httpClient = new HTTPClient({ - ...apiCredentials, - endpoint: "content", - }); - } - - get authors() { - return new APIComposer( - "authors", - { - schema: authorsSchema, - identitySchema: slugOrIdSchema, - include: authorsIncludeSchema, - }, - this.httpClient, - ).access(["read", "browse"]); - } - get tiers() { - return new APIComposer( - "tiers", - { - schema: tiersSchema, - identitySchema: slugOrIdSchema, - include: tiersIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get posts() { - return new APIComposer( - "posts", - { - schema: postsSchema, - identitySchema: slugOrIdSchema, - include: postsIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get pages() { - return new APIComposer( - "pages", - { - schema: pagesSchema, - identitySchema: slugOrIdSchema, - include: pagesIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - get tags() { - return new APIComposer( - "tags", - { - schema: tagsSchema, - identitySchema: slugOrIdSchema, - include: tagsIncludeSchema, - }, - this.httpClient, - ).access(["browse", "read"]); - } - - get settings() { - return new BasicFetcher( - "settings", - { output: settingsSchema }, - this.httpClient, - ); - } -} diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/index.ts deleted file mode 100644 index fb09f087..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { default as TS_API } from "./content-api"; -export * from "./schemas"; - -export type { - InferFetcherDataShape, - InferResponseDataShape, - BrowseParams, -} from "@ts-ghost/core-api"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/index.ts deleted file mode 100644 index f9adb07f..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./authors"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/index.ts deleted file mode 100644 index f4fb9f52..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./socials"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/index.ts deleted file mode 100644 index c4e34b27..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./pages"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/index.ts deleted file mode 100644 index 4f89127a..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./posts"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/index.ts deleted file mode 100644 index dcf101b0..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./settings"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/index.ts deleted file mode 100644 index 006f4bf5..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./tags"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/index.ts b/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/index.ts deleted file mode 100644 index aec8c265..00000000 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./tiers"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/content-api.test.ts b/packages/starlight-ghostcms/src/utils/api/ghostAPI.test.ts similarity index 82% rename from packages/starlight-ghostcms/src/utils/api/content-api/content-api.test.ts rename to packages/starlight-ghostcms/src/utils/api/ghostAPI.test.ts index e47ec835..a7b190f8 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/content-api.test.ts +++ b/packages/starlight-ghostcms/src/utils/api/ghostAPI.test.ts @@ -1,11 +1,15 @@ import { assert, beforeEach, describe, expect, test } from "vitest"; -import TS_API from "./content-api"; +import { TSGhostContentAPI } from "@ts-ghost/content-api"; describe("content-api", () => { - let api: TS_API; + let api: TSGhostContentAPI; beforeEach(() => { - api = new TS_API("https://ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + api = new TSGhostContentAPI( + "https://ghost.org", + "59d4bf56c73c04a18c867dc3ba", + "v5.0", + ); }); test("content-api", () => { @@ -14,21 +18,25 @@ describe("content-api", () => { test("content-api shouldn't instantiate with an incorrect url", () => { assert.throws(() => { - const api = new TS_API("ghost.org", "59d4bf56c73c04a18c867dc3ba", "v5.0"); + const api = new TSGhostContentAPI( + "ghost.org", + "59d4bf56c73c04a18c867dc3ba", + "v5.0", + ); api.settings; }); }); test("content-api shouldn't instantiate with an incorrect key", () => { assert.throws(() => { - const api = new TS_API("https://ghost.org", "a", "v5.0"); + const api = new TSGhostContentAPI("https://ghost.org", "a", "v5.0"); api.settings; }); }); test("content-api shouldn't instantiate with an incorrect version", () => { assert.throws(() => { - const api = new TS_API( + const api = new TSGhostContentAPI( "https://ghost.org", "1efedd9db174adee2d23d982:4b74dca0219bad629852191af326a45037346c2231240e0f7aec1f9371cc14e8", // @ts-expect-error diff --git a/packages/starlight-ghostcms/src/utils/api/api-functions.ts b/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts similarity index 72% rename from packages/starlight-ghostcms/src/utils/api/api-functions.ts rename to packages/starlight-ghostcms/src/utils/api/ghostAPI.ts index a784ebec..784f2f6a 100644 --- a/packages/starlight-ghostcms/src/utils/api/api-functions.ts +++ b/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts @@ -1,9 +1,8 @@ +import { TSGhostContentAPI } from "@ts-ghost/content-api"; +import type { Page, Post } from "./schemas"; + // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; -import { TS_API } from "./content-api"; -import type { ContentAPICredentials } from "./content-api/content-api"; -import type { Page, Post } from "./content-api/schemas"; -import { invariant } from "./invariant.js"; const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "all", @@ -11,13 +10,11 @@ const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "CONTENT_", ); -invariant(CONTENT_API_KEY, "CONTENT_API_KEY Missing from .env"); -invariant(CONTENT_API_URL, "CONTENT_API_URL Missing from .env"); - -const key: ContentAPICredentials["key"] = CONTENT_API_KEY; -const url: ContentAPICredentials["url"] = CONTENT_API_URL; +// SETUP GHOST API +const ghostApiKey = CONTENT_API_KEY || ""; +const ghostUrl = CONTENT_API_URL || ""; const version = "v5.0"; -const api = new TS_API(url, key, version); +const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version); export const getAllAuthors = async () => { const results = await api.authors @@ -67,21 +64,20 @@ export const getAllPosts = async () => { return posts; }; -export const getSluggedPost = async (slug: string) => { +export const getSluggedPost = async (slug:string) => { const results = await api.posts - .read({ slug: slug }) + .read({slug: slug}) .include({ authors: true, tags: true, - }) - .fetch(); - - if (!results.success) { - throw new Error(results.errors.map((e) => e.message).join(", ")); - } - return { - post: results.data, - }; + }).fetch() + + if (!results.success) { + throw new Error(results.errors.map((e) => e.message).join(", ")); + } + return { + post: results.data, + }; }; export const getAllPages = async () => { @@ -101,21 +97,20 @@ export const getAllPages = async () => { return pages; }; -export const getSluggedPage = async (slug: string) => { +export const getSluggedPage = async (slug:string) => { const results = await api.pages - .read({ slug: slug }) + .read({slug: slug}) .include({ authors: true, tags: true, - }) - .fetch(); - - if (!results.success) { - throw new Error(results.errors.map((e) => e.message).join(", ")); - } - return { - post: results.data, - }; + }).fetch() + + if (!results.success) { + throw new Error(results.errors.map((e) => e.message).join(", ")); + } + return { + post: results.data, + }; }; export const getSettings = async () => { diff --git a/packages/starlight-ghostcms/src/utils/api/index.ts b/packages/starlight-ghostcms/src/utils/api/index.ts index 91557560..70fcf4bd 100644 --- a/packages/starlight-ghostcms/src/utils/api/index.ts +++ b/packages/starlight-ghostcms/src/utils/api/index.ts @@ -1,3 +1,3 @@ -export * from "./api-functions"; -export * from "./content-api/schemas"; +export * from "./ghostAPI"; +export * from "./schemas"; export * from "./invariant"; diff --git a/packages/starlight-ghostcms/src/utils/api/invariant.ts b/packages/starlight-ghostcms/src/utils/api/invariant.ts index 787f7935..8d37a1ba 100644 --- a/packages/starlight-ghostcms/src/utils/api/invariant.ts +++ b/packages/starlight-ghostcms/src/utils/api/invariant.ts @@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const tinyinvariant = "merged"; const isProduction: boolean = process.env.NODE_ENV === "production"; const prefix: string = "Invariant failed"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/authors.test.ts b/packages/starlight-ghostcms/src/utils/api/schemas/authors.test.ts similarity index 95% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/authors.test.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/authors.test.ts index 1d24851f..7cd4b54e 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/authors.test.ts +++ b/packages/starlight-ghostcms/src/utils/api/schemas/authors.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; import createFetchMock from "vitest-fetch-mock"; -import TS_API from "../../content-api"; +import { TSGhostContentAPI } from "@ts-ghost/content-api"; const fetchMocker = createFetchMock(vi); @@ -9,7 +9,7 @@ describe("authors api .browse() Args Type-safety", () => { const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; - const api = new TS_API(url, key, "v5.0"); + const api = new TSGhostContentAPI(url, key, "v5.0"); test(".browse() params shouldnt accept invalid params", () => { // @ts-expect-error - shouldnt accept invalid params const browse = api.authors.browse({ pp: 2 }); @@ -95,10 +95,10 @@ describe("authors api .browse() Args Type-safety", () => { }); describe("authors resource mocked", () => { - let api: TS_API; + let api: TSGhostContentAPI; beforeEach(() => { - api = new TS_API( + api = new TSGhostContentAPI( "https://my-ghost-blog.com", "59d4bf56c73c04a18c867dc3ba", "v5.0", diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/authors.ts b/packages/starlight-ghostcms/src/utils/api/schemas/authors.ts similarity index 100% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/authors/authors.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/authors.ts diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/index.ts b/packages/starlight-ghostcms/src/utils/api/schemas/index.ts similarity index 85% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/index.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/index.ts index 88bfc1b9..43c252a2 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/index.ts +++ b/packages/starlight-ghostcms/src/utils/api/schemas/index.ts @@ -1,7 +1,7 @@ export * from "./authors"; -export * from "./helpers"; export * from "./pages"; export * from "./posts"; export * from "./settings"; +export * from "./socials"; export * from "./tags"; export * from "./tiers"; diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/pages.ts b/packages/starlight-ghostcms/src/utils/api/schemas/pages.ts similarity index 94% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/pages.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/pages.ts index 2fcd9655..c688d91f 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/pages/pages.ts +++ b/packages/starlight-ghostcms/src/utils/api/schemas/pages.ts @@ -7,8 +7,8 @@ import { } from "@ts-ghost/core-api"; import { z } from "astro/zod"; -import { authorsSchema } from "../authors"; -import { tagsSchema } from "../tags"; +import { authorsSchema } from "./authors"; +import { tagsSchema } from "./tags"; const postsAuthorSchema = authorsSchema.extend({ url: z.string().nullish(), diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.test.ts b/packages/starlight-ghostcms/src/utils/api/schemas/posts.test.ts similarity index 87% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.test.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/posts.test.ts index b2dfbbe3..35427607 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.test.ts +++ b/packages/starlight-ghostcms/src/utils/api/schemas/posts.test.ts @@ -1,14 +1,14 @@ import { describe, expect, test } from "vitest"; -import TS_API from "../../content-api"; -import type { Post } from "./posts"; +import { TSGhostContentAPI } from "@ts-ghost/content-api"; +import type { Post } from "./index"; const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; describe("posts api .browse() Args Type-safety", () => { - const api = new TS_API(url, key, "v5.0"); + const api = new TSGhostContentAPI(url, key, "v5.0"); test(".browse() params shouldnt accept invalid params", () => { // @ts-expect-error - shouldnt accept invalid params const browse = api.posts.browse({ pp: 2 }); @@ -21,8 +21,7 @@ describe("posts api .browse() Args Type-safety", () => { foo: true, } satisfies { [k in keyof Post]?: true | undefined }; - // biome-ignore lint/style/useConst: - let test = api.posts + const test = api.posts .browse() // @ts-expect-error - shouldnt accept invalid params .fields(outputFields); @@ -45,8 +44,7 @@ describe("posts api .browse() Args Type-safety", () => { title: true, } satisfies { [k in keyof Post]?: true | undefined }; - // biome-ignore lint/style/useConst: - let test = api.posts.browse().fields(outputFields); + const test = api.posts.browse().fields(outputFields); expect(test.getOutputFields()).toEqual(["slug", "title"]); // @ts-expect-error - shouldnt accept invalid params diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.ts b/packages/starlight-ghostcms/src/utils/api/schemas/posts.ts similarity index 95% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/posts.ts index b479ee17..cb514ed8 100644 --- a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/posts/posts.ts +++ b/packages/starlight-ghostcms/src/utils/api/schemas/posts.ts @@ -7,8 +7,8 @@ import { } from "@ts-ghost/core-api"; import { z } from "astro/zod"; -import { authorsSchema } from "../authors"; -import { tagsSchema } from "../tags"; +import { authorsSchema } from "./authors"; +import { tagsSchema } from "./tags"; const postsAuthorSchema = authorsSchema.extend({ url: z.string().nullish(), diff --git a/packages/starlight-ghostcms/src/utils/api/schemas/settings.test.ts b/packages/starlight-ghostcms/src/utils/api/schemas/settings.test.ts new file mode 100644 index 00000000..02d9f403 --- /dev/null +++ b/packages/starlight-ghostcms/src/utils/api/schemas/settings.test.ts @@ -0,0 +1,39 @@ +import { beforeEach, describe, expect, test } from "vitest"; + +import { TSGhostContentAPI } from "@ts-ghost/content-api"; + +const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com"; +const key = + process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba"; + +describe("settings integration tests browse", () => { + let api: TSGhostContentAPI; + beforeEach(() => { + api = new TSGhostContentAPI(url, key, "v5.0"); + }); + test("settings.fetch()", async () => { + const result = await api.settings.fetch(); + expect(result).not.toBeUndefined(); + expect(result).not.toBeNull(); + if (!result.success) { + expect(result.errors).toBeDefined(); + expect(result.errors).toHaveLength(1); + } else { + expect(result.data).toBeDefined(); + const settings = result.data; + expect(settings).toBeDefined(); + expect(settings.title).toBe("Astro Starter"); + expect(settings.description).toBe("Thoughts, stories and ideas."); + expect(settings.logo).toBeNull(); + expect(settings.cover_image).toBe( + "https://static.ghost.org/v4.0.0/images/publication-cover.jpg", + ); + expect(settings.icon).toBeNull(); + expect(settings.lang).toBe("en"); + expect(settings.timezone).toBe("Etc/UTC"); + expect(settings.codeinjection_head).toBeNull(); + expect(settings.codeinjection_foot).toBeNull(); + expect(settings.members_support_address).toBe("noreply"); + } + }); +}); diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/settings.ts b/packages/starlight-ghostcms/src/utils/api/schemas/settings.ts similarity index 100% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/settings/settings.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/settings.ts diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/socials.ts b/packages/starlight-ghostcms/src/utils/api/schemas/socials.ts similarity index 100% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/helpers/socials.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/socials.ts diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/tags.ts b/packages/starlight-ghostcms/src/utils/api/schemas/tags.ts similarity index 100% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/tags/tags.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/tags.ts diff --git a/packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/tiers.ts b/packages/starlight-ghostcms/src/utils/api/schemas/tiers.ts similarity index 100% rename from packages/starlight-ghostcms/src/utils/api/content-api/schemas/tiers/tiers.ts rename to packages/starlight-ghostcms/src/utils/api/schemas/tiers.ts diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index a24919e3..8a95f1f6 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -10,11 +10,11 @@ export default defineConfig({ //tailwind(), UnoCSS({ injectReset: true }), ghostcms({ - ghostURL: "https://ghostdemo.matthiesen.xyz", + ghostURL: 'https://ghostdemo.matthiesen.xyz', ThemeProvider: { theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", }, - verbose: false, + verbose: true, }), ], }); diff --git a/playgrounds/astro-playground/package.json b/playgrounds/astro-playground/package.json index 533aece7..462cb878 100644 --- a/playgrounds/astro-playground/package.json +++ b/playgrounds/astro-playground/package.json @@ -13,6 +13,7 @@ "dependencies": { "astro": "^4.4.0", "@matthiesenxyz/astro-ghostcms": "workspace:*", + "@matthiesenxyz/astro-ghostcms-theme-default": "workspace:*", "@matthiesenxyz/astro-ghostcms-brutalbyelian": "workspace:*", "@astrojs/tailwind": "^5.1.0", "@unocss/astro": "^0.58.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1093d096..3a119f2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,7 +104,7 @@ importers: version: link:../astro-ghostcms-rendercontent '@unocss/astro': specifier: ^0.58.5 - version: 0.58.5(vite@5.1.4) + version: 0.58.5(vite@5.1.5) '@unocss/reset': specifier: ^0.58.5 version: 0.58.5 @@ -122,7 +122,7 @@ importers: version: 1.5.2 unocss: specifier: ^0.58.5 - version: 0.58.5(postcss@8.4.35)(vite@5.1.4) + version: 0.58.5(postcss@8.4.35)(vite@5.1.5) devDependencies: '@typescript-eslint/parser': specifier: ^7.0.1 @@ -247,31 +247,31 @@ importers: '@astrojs/rss': specifier: ^4.0.5 version: 4.0.5 + '@ts-ghost/content-api': + specifier: ^4.0.12 + version: 4.0.12 '@ts-ghost/core-api': - specifier: 5.1.2 - version: 5.1.2 + specifier: ^6.0.0 + version: 6.0.0 vite: - specifier: ^5.1.2 - version: 5.1.3 + specifier: ^5.1.5 + version: 5.1.5(@types/node@20.11.24) vite-tsconfig-paths: - specifier: ^4.2.2 - version: 4.3.1(vite@5.1.3) + specifier: ^4.3.1 + version: 4.3.1(vite@5.1.5) devDependencies: '@astrojs/starlight': specifier: ^0.19.0 version: 0.19.0(astro@4.4.0) - '@ts-ghost/tsconfig': - specifier: workspace:* - version: link:../tsconfig astro: specifier: ^4.4.0 version: 4.4.0(typescript@5.3.3) vitest: - specifier: ^1.2.2 - version: 1.2.2(@vitest/ui@1.3.1) + specifier: ^1.3.1 + version: 1.3.1(@vitest/ui@1.3.1) vitest-fetch-mock: specifier: ^0.2.2 - version: 0.2.2(vitest@1.2.2) + version: 0.2.2(vitest@1.3.1) packages/tsconfig: {} @@ -286,9 +286,12 @@ importers: '@matthiesenxyz/astro-ghostcms-brutalbyelian': specifier: workspace:* version: link:../../packages/astro-ghostcms-brutalbyelian + '@matthiesenxyz/astro-ghostcms-theme-default': + specifier: workspace:* + version: link:../../packages/astro-ghostcms-theme-default '@unocss/astro': specifier: ^0.58.5 - version: 0.58.5(vite@5.1.4) + version: 0.58.5(vite@5.1.5) astro: specifier: ^4.4.0 version: 4.4.0(typescript@5.3.3) @@ -304,7 +307,7 @@ importers: version: 5.3.3 unocss: specifier: ^0.58.5 - version: 0.58.5(postcss@8.4.35)(vite@5.1.4) + version: 0.58.5(postcss@8.4.35)(vite@5.1.5) playgrounds/starlight-playground: dependencies: @@ -1891,13 +1894,6 @@ packages: zod: 3.22.4 dev: false - /@ts-ghost/core-api@5.1.2: - resolution: {integrity: sha512-YqLLGAJ8GxHx3GvotnZxmkDuT9ZjJo4DVLl30n5aXr/+1Y3O6PpNpwAa1ws67cshx0rbFmTAGN76goKbVfLDTg==} - dependencies: - jose: 5.2.2 - zod: 3.22.4 - dev: false - /@ts-ghost/core-api@6.0.0: resolution: {integrity: sha512-5Q7nbrmAoJ/5PcW2lPgCVyAJloVaQqybHpzXuFRbKj5sYWNeJbcwSrnYOBw/3t1tA2ghPrNVXqWOGrGKqZl1Zg==} dependencies: @@ -2134,7 +2130,7 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - /@unocss/astro@0.58.5(vite@5.1.4): + /@unocss/astro@0.58.5(vite@5.1.5): resolution: {integrity: sha512-LtuVnj8oFAK9663OVhQO8KpdJFiOyyPsYfnOZlDCOFK3gHb/2WMrzdBwr1w8LoQF3bDedkFMKirVF7gWjyZiaw==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -2144,8 +2140,8 @@ packages: dependencies: '@unocss/core': 0.58.5 '@unocss/reset': 0.58.5 - '@unocss/vite': 0.58.5(vite@5.1.4) - vite: 5.1.4(sass@1.71.0) + '@unocss/vite': 0.58.5(vite@5.1.5) + vite: 5.1.5(@types/node@20.11.24) transitivePeerDependencies: - rollup @@ -2305,7 +2301,7 @@ packages: dependencies: '@unocss/core': 0.58.5 - /@unocss/vite@0.58.5(vite@5.1.4): + /@unocss/vite@0.58.5(vite@5.1.5): resolution: {integrity: sha512-p4o1XNX1rvjmoUqSSdua8XyWNg/d+YUChDd2L/xEty+6j2qv0wUaohs3UQ87vWlv632/UmgdX+2MbrgtqthCtw==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -2320,18 +2316,10 @@ packages: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.7 - vite: 5.1.4(sass@1.71.0) + vite: 5.1.5(@types/node@20.11.24) transitivePeerDependencies: - rollup - /@vitest/expect@1.2.2: - resolution: {integrity: sha512-3jpcdPAD7LwHUUiT2pZTj2U82I2Tcgg2oVPvKxhn6mDI2On6tfvPQTjAI4628GUGDZrCm4Zna9iQHm5cEexOAg==} - dependencies: - '@vitest/spy': 1.2.2 - '@vitest/utils': 1.2.2 - chai: 4.4.1 - dev: true - /@vitest/expect@1.3.1: resolution: {integrity: sha512-xofQFwIzfdmLLlHa6ag0dPV8YsnKOCP1KdAeVVh34vSjN2dcUiXYCD9htu/9eM7t8Xln4v03U9HLxLpPlsXdZw==} dependencies: @@ -2340,14 +2328,6 @@ packages: chai: 4.4.1 dev: true - /@vitest/runner@1.2.2: - resolution: {integrity: sha512-JctG7QZ4LSDXr5CsUweFgcpEvrcxOV1Gft7uHrvkQ+fsAVylmWQvnaAr/HDp3LAH1fztGMQZugIheTWjaGzYIg==} - dependencies: - '@vitest/utils': 1.2.2 - p-limit: 5.0.0 - pathe: 1.1.2 - dev: true - /@vitest/runner@1.3.1: resolution: {integrity: sha512-5FzF9c3jG/z5bgCnjr8j9LNq/9OxV2uEBAITOXfoe3rdZJTdO7jzThth7FXv/6b+kdY65tpRQB7WaKhNZwX+Kg==} dependencies: @@ -2356,14 +2336,6 @@ packages: pathe: 1.1.2 dev: true - /@vitest/snapshot@1.2.2: - resolution: {integrity: sha512-SmGY4saEw1+bwE1th6S/cZmPxz/Q4JWsl7LvbQIky2tKE35US4gd0Mjzqfr84/4OD0tikGWaWdMja/nWL5NIPA==} - dependencies: - magic-string: 0.30.7 - pathe: 1.1.2 - pretty-format: 29.7.0 - dev: true - /@vitest/snapshot@1.3.1: resolution: {integrity: sha512-EF++BZbt6RZmOlE3SuTPu/NfwBF6q4ABS37HHXzs2LUVPBLx2QoY/K0fKpRChSo8eLiuxcbCVfqKgx/dplCDuQ==} dependencies: @@ -2372,12 +2344,6 @@ packages: pretty-format: 29.7.0 dev: true - /@vitest/spy@1.2.2: - resolution: {integrity: sha512-k9Gcahssw8d7X3pSLq3e3XEu/0L78mUkCjivUqCQeXJm9clfXR/Td8+AP+VC1O6fKPIDLcHDTAmBOINVuv6+7g==} - dependencies: - tinyspy: 2.2.1 - dev: true - /@vitest/spy@1.3.1: resolution: {integrity: sha512-xAcW+S099ylC9VLU7eZfdT9myV67Nor9w9zhf0mGCYJSO+zM2839tOeROTdikOi/8Qeusffvxb/MyBSOja1Uig==} dependencies: @@ -2399,15 +2365,6 @@ packages: vitest: 1.3.1(@vitest/ui@1.3.1) dev: true - /@vitest/utils@1.2.2: - resolution: {integrity: sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==} - dependencies: - diff-sequences: 29.6.3 - estree-walker: 3.0.3 - loupe: 2.3.7 - pretty-format: 29.7.0 - dev: true - /@vitest/utils@1.3.1: resolution: {integrity: sha512-d3Waie/299qqRyHTm2DjADeTaNdNSVsnwHPWrs20JMpjh6eiVq7ggggweO8rc4arhf6rRkWuHKwvxGvejUXZZQ==} dependencies: @@ -7303,12 +7260,6 @@ packages: engines: {node: '>=8'} dev: true - /strip-literal@1.3.0: - resolution: {integrity: sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==} - dependencies: - acorn: 8.11.3 - dev: true - /strip-literal@2.0.0: resolution: {integrity: sha512-f9vHgsCWBq2ugHAkGMiiYY+AYG0D/cbloKKg0nhaaaSNsujdGIpVXCNsrJpCKr5M0f4aI31mr13UjY6GAuXCKA==} dependencies: @@ -7798,7 +7749,7 @@ packages: engines: {node: '>= 10.0.0'} dev: false - /unocss@0.58.5(postcss@8.4.35)(vite@5.1.4): + /unocss@0.58.5(postcss@8.4.35)(vite@5.1.5): resolution: {integrity: sha512-0g4P6jLgRRNnhscxw7nQ9RHGrKJ1UPPiHPet+YT3TXUcmy4mTiYgo9+kGQf5bjyrzsELJ10cT6Qz2y6g9Tls4g==} engines: {node: '>=14'} peerDependencies: @@ -7810,7 +7761,7 @@ packages: vite: optional: true dependencies: - '@unocss/astro': 0.58.5(vite@5.1.4) + '@unocss/astro': 0.58.5(vite@5.1.5) '@unocss/cli': 0.58.5 '@unocss/core': 0.58.5 '@unocss/extractor-arbitrary-variants': 0.58.5 @@ -7829,8 +7780,8 @@ packages: '@unocss/transformer-compile-class': 0.58.5 '@unocss/transformer-directives': 0.58.5 '@unocss/transformer-variant-group': 0.58.5 - '@unocss/vite': 0.58.5(vite@5.1.4) - vite: 5.1.4(sass@1.71.0) + '@unocss/vite': 0.58.5(vite@5.1.5) + vite: 5.1.5(@types/node@20.11.24) transitivePeerDependencies: - postcss - rollup @@ -7907,48 +7858,6 @@ packages: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - /vite-node@1.2.2: - resolution: {integrity: sha512-1as4rDTgVWJO3n1uHmUYqq7nsFgINQ9u+mRcXpjeOMJUmviqNKjcZB7UfRZrlM7MjYXMKpuWp5oGkjaFLnjawg==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - dependencies: - cac: 6.7.14 - debug: 4.3.4 - pathe: 1.1.2 - picocolors: 1.0.0 - vite: 5.1.4(sass@1.71.0) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - - /vite-node@1.3.1: - resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - dependencies: - cac: 6.7.14 - debug: 4.3.4 - pathe: 1.1.2 - picocolors: 1.0.0 - vite: 5.1.4(sass@1.71.0) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - /vite-node@1.3.1(@types/node@20.11.24): resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0} @@ -7958,7 +7867,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.4(@types/node@20.11.24) + vite: 5.1.5(@types/node@20.11.24) transitivePeerDependencies: - '@types/node' - less @@ -7970,7 +7879,7 @@ packages: - terser dev: true - /vite-tsconfig-paths@4.3.1(vite@5.1.3): + /vite-tsconfig-paths@4.3.1(vite@5.1.5): resolution: {integrity: sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==} peerDependencies: vite: '*' @@ -7981,47 +7890,12 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 3.0.2(typescript@5.3.3) - vite: 5.1.3 + vite: 5.1.5(@types/node@20.11.24) transitivePeerDependencies: - supports-color - typescript dev: false - /vite@5.1.3: - resolution: {integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - dependencies: - esbuild: 0.19.12 - postcss: 8.4.35 - rollup: 4.11.0 - optionalDependencies: - fsevents: 2.3.3 - dev: false - /vite@5.1.4(@types/node@20.11.24): resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -8092,6 +7966,41 @@ packages: optionalDependencies: fsevents: 2.3.3 + /vite@5.1.5(@types/node@20.11.24): + resolution: {integrity: sha512-BdN1xh0Of/oQafhU+FvopafUp6WaYenLU/NFoL5WyJL++GxkNfieKzBhM24H3HVsPQrlAqB7iJYTHabzaRed5Q==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 20.11.24 + esbuild: 0.19.12 + postcss: 8.4.35 + rollup: 4.11.0 + optionalDependencies: + fsevents: 2.3.3 + /vitefu@0.2.5(vite@5.1.4): resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} peerDependencies: @@ -8102,18 +8011,6 @@ packages: dependencies: vite: 5.1.4(@types/node@20.11.24) - /vitest-fetch-mock@0.2.2(vitest@1.2.2): - resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} - engines: {node: '>=14.14.0'} - peerDependencies: - vitest: '>=0.16.0' - dependencies: - cross-fetch: 3.1.8 - vitest: 1.2.2(@vitest/ui@1.3.1) - transitivePeerDependencies: - - encoding - dev: true - /vitest-fetch-mock@0.2.2(vitest@1.3.1): resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} engines: {node: '>=14.14.0'} @@ -8126,63 +8023,6 @@ packages: - encoding dev: true - /vitest@1.2.2(@vitest/ui@1.3.1): - resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': ^1.0.0 - '@vitest/ui': ^1.0.0 - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@types/node': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - dependencies: - '@vitest/expect': 1.2.2 - '@vitest/runner': 1.2.2 - '@vitest/snapshot': 1.2.2 - '@vitest/spy': 1.2.2 - '@vitest/ui': 1.3.1(vitest@1.3.1) - '@vitest/utils': 1.2.2 - acorn-walk: 8.3.2 - cac: 6.7.14 - chai: 4.4.1 - debug: 4.3.4 - execa: 8.0.1 - local-pkg: 0.5.0 - magic-string: 0.30.7 - pathe: 1.1.2 - picocolors: 1.0.0 - std-env: 3.7.0 - strip-literal: 1.3.0 - tinybench: 2.6.0 - tinypool: 0.8.2 - vite: 5.1.4(sass@1.71.0) - vite-node: 1.2.2 - why-is-node-running: 2.2.2 - transitivePeerDependencies: - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - dev: true - /vitest@1.3.1(@types/node@20.11.24)(@vitest/ui@1.3.1): resolution: {integrity: sha512-/1QJqXs8YbCrfv/GPQ05wAZf2eakUPLPa18vkJAKE7RXOKfVHqMZZ1WlTjiwl6Gcn65M5vpNUB6EFLnEdRdEXQ==} engines: {node: ^18.0.0 || >=20.0.0} @@ -8284,7 +8124,7 @@ packages: tinybench: 2.6.0 tinypool: 0.8.2 vite: 5.1.4(sass@1.71.0) - vite-node: 1.3.1 + vite-node: 1.3.1(@types/node@20.11.24) why-is-node-running: 2.2.2 transitivePeerDependencies: - less From 363c22bf36b18b539883b62fe96ac0e5cdd32755 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 19:02:07 -0800 Subject: [PATCH 38/46] removed extra changeset --- .changeset/ninety-apricots-dream.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .changeset/ninety-apricots-dream.md diff --git a/.changeset/ninety-apricots-dream.md b/.changeset/ninety-apricots-dream.md deleted file mode 100644 index 4518e0a0..00000000 --- a/.changeset/ninety-apricots-dream.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@matthiesenxyz/create-astro-ghostcms": patch -"@matthiesenxyz/starlight-ghostcms": patch ---- - -Code Linted From f7816e69a6ffd40ee4dc939bdf157e901cbdcae5 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 20:24:59 -0800 Subject: [PATCH 39/46] cleanup starlight-ghostcms code --- packages/starlight-ghostcms/README.md | 4 +- packages/starlight-ghostcms/index.ts | 46 ++++------ packages/starlight-ghostcms/package.json | 4 +- .../src/integrations/vite.ts | 4 +- .../src/overrides/Sidebar.astro | 2 +- .../src/routes/[slug].astro | 2 +- .../starlight-ghostcms/src/routes/about.astro | 2 +- .../src/routes/authors.astro | 2 +- .../starlight-ghostcms/src/routes/index.astro | 2 +- .../starlight-ghostcms/src/routes/rss.xml.ts | 2 +- .../starlight-ghostcms/src/schemas/config.ts | 15 ++++ .../src/utils/api/ghostAPI.ts | 4 + packages/starlight-ghostcms/tsconfig.json | 30 +------ packages/starlight-ghostcms/virtual.d.ts | 4 +- .../starlight-playground/astro.config.mjs | 1 + pnpm-lock.yaml | 90 +++++++++++++++++-- 16 files changed, 138 insertions(+), 76 deletions(-) diff --git a/packages/starlight-ghostcms/README.md b/packages/starlight-ghostcms/README.md index bcd4ada5..a756b101 100644 --- a/packages/starlight-ghostcms/README.md +++ b/packages/starlight-ghostcms/README.md @@ -48,7 +48,9 @@ import starlightGhostCMS from '@matthiesenxyz/starlight-ghostcms'; export default defineConfig({ integrations: [ starlight({ - plugins: [starlightGhostCMS()], + plugins: [ + starlightGhostCMS() + ], title: 'My Docs', }), ], diff --git a/packages/starlight-ghostcms/index.ts b/packages/starlight-ghostcms/index.ts index 66d719f2..ff69284b 100644 --- a/packages/starlight-ghostcms/index.ts +++ b/packages/starlight-ghostcms/index.ts @@ -30,6 +30,7 @@ export default function starlightGhostCMS( logger, updateConfig: updateStarlightConfig, }) { + // Update the Starlight config with the GhostCMS config updateStarlightConfig({ social: { ...starlightConfig.social, @@ -57,47 +58,36 @@ export default function starlightGhostCMS( }, }); + // Add the Starlight-GhostCMS integration addIntegration({ name: "@matthiesenxyz/starlight-ghostcms", hooks: { "astro:config:setup": ({ injectRoute, updateConfig }) => { - injectRoute({ - pattern: "/blog", - entrypoint: - "@matthiesenxyz/starlight-ghostcms/routes/index.astro", - prerender: true, - }); - injectRoute({ - pattern: "/blog/[slug]", - 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", - }); updateConfig({ vite: { plugins: [vitePluginStarlightGhostConfig(config)], }, }); + + const makeRoute = (endpoint: string, entrypoint: string) => { + injectRoute({ + pattern: `/${endpoint}`, + entrypoint: `@matthiesenxyz/starlight-ghostcms/routes/${entrypoint}`, + prerender: true, + }); + }; + + makeRoute("blog", "index.astro"); + makeRoute("blog/[slug]", "[slug].astro"); + makeRoute("blog/about", "about.astro"); + makeRoute("blog/authors", "authors.astro"); + makeRoute("rss.xml", "rss.xml.ts"); + }, }, }); + }, }, }; diff --git a/packages/starlight-ghostcms/package.json b/packages/starlight-ghostcms/package.json index 58820694..b72f5d63 100644 --- a/packages/starlight-ghostcms/package.json +++ b/packages/starlight-ghostcms/package.json @@ -60,7 +60,7 @@ }, "devDependencies": { "@astrojs/starlight": "^0.19.0", - "astro": "^4.4.0", + "astro": "^4.4.1", "vitest": "^1.3.1", "vitest-fetch-mock": "^0.2.2" }, @@ -73,6 +73,6 @@ }, "peerDependencies": { "@astrojs/starlight": ">=0.19.0", - "astro": ">=4.4.0" + "astro": ">=4.4.1" } } diff --git a/packages/starlight-ghostcms/src/integrations/vite.ts b/packages/starlight-ghostcms/src/integrations/vite.ts index eff6ca08..c48797a6 100644 --- a/packages/starlight-ghostcms/src/integrations/vite.ts +++ b/packages/starlight-ghostcms/src/integrations/vite.ts @@ -6,12 +6,12 @@ import type { StarlightGhostConfig } from "../schemas/config.ts"; export function vitePluginStarlightGhostConfig( config: StarlightGhostConfig, ): VitePlugin { - const moduleId = "virtual:starlight-ghost-config"; + const moduleId = 'virtual:starlight-ghostcms/config'; const resolvedModuleId = `\0${moduleId}`; const moduleContent = `export default ${JSON.stringify(config)}`; return { - name: "vite-plugin-starlight-ghost-config", + name: "vite-plugin-starlight-ghostcms-config", load(id) { return id === resolvedModuleId ? moduleContent : undefined; }, diff --git a/packages/starlight-ghostcms/src/overrides/Sidebar.astro b/packages/starlight-ghostcms/src/overrides/Sidebar.astro index 5319d41a..ffc8f358 100644 --- a/packages/starlight-ghostcms/src/overrides/Sidebar.astro +++ b/packages/starlight-ghostcms/src/overrides/Sidebar.astro @@ -1,7 +1,7 @@ --- import StarlightSidebar from '@astrojs/starlight/components/Sidebar.astro' import type { Props } from '@astrojs/starlight/props' -import config from 'virtual:starlight-ghost-config' +import config from 'virtual:starlight-ghostcms/config' import { isBlogPostPage, isBlogRoot } from '../utils/page' import { getAllPages, getAllPosts, getSluggedPage } from '../utils/api' import type { SidebarEntry } from './sidebartypes' diff --git a/packages/starlight-ghostcms/src/routes/[slug].astro b/packages/starlight-ghostcms/src/routes/[slug].astro index 6ae03dd2..c7ce65e2 100644 --- a/packages/starlight-ghostcms/src/routes/[slug].astro +++ b/packages/starlight-ghostcms/src/routes/[slug].astro @@ -1,5 +1,5 @@ --- -import config from 'virtual:starlight-ghost-config' +import config from 'virtual:starlight-ghostcms/config' import { Image } from "astro:assets"; import Page from '../components/Page.astro' import { getPageProps } from '../utils/page' diff --git a/packages/starlight-ghostcms/src/routes/about.astro b/packages/starlight-ghostcms/src/routes/about.astro index c4a2b1fa..0eabf65d 100644 --- a/packages/starlight-ghostcms/src/routes/about.astro +++ b/packages/starlight-ghostcms/src/routes/about.astro @@ -1,5 +1,5 @@ --- -import config from 'virtual:starlight-ghost-config' +import config from 'virtual:starlight-ghostcms/config' import Metadata from '../components/Metadata.astro' import Page from '../components/Page.astro' //import PrevNextLinks from '../components/PrevNextLinks.astro' diff --git a/packages/starlight-ghostcms/src/routes/authors.astro b/packages/starlight-ghostcms/src/routes/authors.astro index f446ef52..d8c88103 100644 --- a/packages/starlight-ghostcms/src/routes/authors.astro +++ b/packages/starlight-ghostcms/src/routes/authors.astro @@ -1,5 +1,5 @@ --- -import config from 'virtual:starlight-ghost-config' +import config from 'virtual:starlight-ghostcms/config' import Page from '../components/Page.astro' //import PrevNextLinks from '../components/PrevNextLinks.astro' import { getAllAuthors } from '../utils/api' diff --git a/packages/starlight-ghostcms/src/routes/index.astro b/packages/starlight-ghostcms/src/routes/index.astro index dea5b647..56d89342 100644 --- a/packages/starlight-ghostcms/src/routes/index.astro +++ b/packages/starlight-ghostcms/src/routes/index.astro @@ -1,6 +1,6 @@ --- //import type { InferGetStaticPropsType } from 'astro' -import config from 'virtual:starlight-ghost-config' +import config from 'virtual:starlight-ghostcms/config' import Page from '../components/Page.astro' import Posts from '../components/Posts.astro' diff --git a/packages/starlight-ghostcms/src/routes/rss.xml.ts b/packages/starlight-ghostcms/src/routes/rss.xml.ts index 6781f1ae..1955fb73 100644 --- a/packages/starlight-ghostcms/src/routes/rss.xml.ts +++ b/packages/starlight-ghostcms/src/routes/rss.xml.ts @@ -5,7 +5,7 @@ import { getAllPosts, getSettings, invariant } from "../utils/api"; const posts = await getAllPosts(); const settings = await getSettings(); -import config from "virtual:starlight-ghost-config"; +import config from "virtual:starlight-ghostcms/config"; export async function GET({ site }: APIContext) { invariant(settings, "Settings is not defined"); diff --git a/packages/starlight-ghostcms/src/schemas/config.ts b/packages/starlight-ghostcms/src/schemas/config.ts index b2f617df..19c55fd8 100644 --- a/packages/starlight-ghostcms/src/schemas/config.ts +++ b/packages/starlight-ghostcms/src/schemas/config.ts @@ -3,6 +3,21 @@ import { z } from "astro/zod"; const configSchema = z .object({ + /** OPTIONAL - Either set the URL in your .env or put it here + * @example + * // https://astro.build/config + * export default defineConfig({ + * integrations: [ + * starlight({ + * plugins: [ + * starlightGhost({ + * ghostURL: "https://ghostdemo.matthiesen.xyz" + * }) + * ], + * }) + * ], + * }); */ + ghostURL: z.string().url("Must be a URL").optional(), /** * The number of blog posts to display per page in the blog post list. */ diff --git a/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts b/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts index 784f2f6a..db629d25 100644 --- a/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts +++ b/packages/starlight-ghostcms/src/utils/api/ghostAPI.ts @@ -3,6 +3,7 @@ import type { Page, Post } from "./schemas"; // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; +//import StarlightGhostConfig from "virtual:starlight-ghostcms/config"; const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "all", @@ -10,6 +11,9 @@ const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( "CONTENT_", ); + +//const ConfURL = StarlightGhostConfig.ghostURL || ""; + // SETUP GHOST API const ghostApiKey = CONTENT_API_KEY || ""; const ghostUrl = CONTENT_API_URL || ""; diff --git a/packages/starlight-ghostcms/tsconfig.json b/packages/starlight-ghostcms/tsconfig.json index 73727041..77da9dd0 100644 --- a/packages/starlight-ghostcms/tsconfig.json +++ b/packages/starlight-ghostcms/tsconfig.json @@ -1,29 +1,3 @@ { - "$schema": "https://json.schemastore.org/tsconfig", - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "esModuleInterop": true, - "exactOptionalPropertyTypes": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "jsx": "react-jsx", - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "module": "ESNext", - "moduleResolution": "bundler", - "noFallthroughCasesInSwitch": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true, - "target": "ESNext", - "useDefineForClassFields": true, - "verbatimModuleSyntax": true - } - } \ No newline at end of file + "extends": "astro/tsconfigs/strict" +} \ No newline at end of file diff --git a/packages/starlight-ghostcms/virtual.d.ts b/packages/starlight-ghostcms/virtual.d.ts index 5f5ef663..1667ac7b 100644 --- a/packages/starlight-ghostcms/virtual.d.ts +++ b/packages/starlight-ghostcms/virtual.d.ts @@ -1,5 +1,5 @@ -declare module "virtual:starlight-ghost-config" { - const StarlightGhostConfig: import("./src/schemas/config").StarlightGhostConfig; +declare module "virtual:starlight-ghostcms/config" { + const StarlightGhostConfig: import("./src/schemas/config.ts").StarlightGhostConfig; export default StarlightGhostConfig; } diff --git a/playgrounds/starlight-playground/astro.config.mjs b/playgrounds/starlight-playground/astro.config.mjs index 391a2f20..b5c80711 100644 --- a/playgrounds/starlight-playground/astro.config.mjs +++ b/playgrounds/starlight-playground/astro.config.mjs @@ -10,6 +10,7 @@ export default defineConfig({ title: "My Docs", plugins: [ starlightGhostCMS({ + ghostURL: 'https://ghostdemo.matthiesen.xyz', title: "Demo Blog", rssDescription: "Starlight Playground", }), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a119f2f..ca719988 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -262,10 +262,10 @@ importers: devDependencies: '@astrojs/starlight': specifier: ^0.19.0 - version: 0.19.0(astro@4.4.0) + version: 0.19.0(astro@4.4.9) astro: - specifier: ^4.4.0 - version: 4.4.0(typescript@5.3.3) + specifier: ^4.4.1 + version: 4.4.9(@types/node@20.11.24) vitest: specifier: ^1.3.1 version: 1.3.1(@vitest/ui@1.3.1) @@ -453,6 +453,33 @@ packages: vfile: 6.0.1 transitivePeerDependencies: - supports-color + dev: false + + /@astrojs/mdx@2.1.1(astro@4.4.9): + resolution: {integrity: sha512-AgGFdE7HOGmoFooGvMSatkA9FiSKwyVW7ImHot/bXJ6uAbFfu6iG2ht18Cf1pT22Hda/6iSCGWusFvBv0/EnKQ==} + engines: {node: '>=18.14.1'} + peerDependencies: + astro: ^4.0.0 + dependencies: + '@astrojs/markdown-remark': 4.2.1 + '@mdx-js/mdx': 3.0.1 + acorn: 8.11.3 + astro: 4.4.9(@types/node@20.11.24) + es-module-lexer: 1.4.1 + estree-util-visit: 2.0.0 + github-slugger: 2.0.0 + gray-matter: 4.0.3 + hast-util-to-html: 9.0.0 + kleur: 4.1.5 + rehype-raw: 7.0.0 + remark-gfm: 4.0.0 + remark-smartypants: 2.1.0 + source-map: 0.7.4 + unist-util-visit: 5.0.0 + vfile: 6.0.1 + transitivePeerDependencies: + - supports-color + dev: true /@astrojs/prism@3.0.0: resolution: {integrity: sha512-g61lZupWq1bYbcBnYZqdjndShr/J3l/oFobBKPA3+qMat146zce3nz2kdO4giGbhYDt4gYdhmoBz0vZJ4sIurQ==} @@ -499,6 +526,35 @@ packages: vfile: 6.0.1 transitivePeerDependencies: - supports-color + dev: false + + /@astrojs/starlight@0.19.0(astro@4.4.9): + resolution: {integrity: sha512-izNZLs99d4AAoN5eV6Ek71SVKEAs8N/GjT+n9J0Q8q1Zgtk/qcv3KzuPXBZmiAbPl/9E2+BG8f4dpdoc+F4U3g==} + peerDependencies: + astro: ^4.2.7 + dependencies: + '@astrojs/mdx': 2.1.1(astro@4.4.9) + '@astrojs/sitemap': 3.1.1 + '@pagefind/default-ui': 1.0.4 + '@types/hast': 3.0.4 + '@types/mdast': 4.0.3 + astro: 4.4.9(@types/node@20.11.24) + astro-expressive-code: 0.32.4(astro@4.4.9) + bcp-47: 2.1.0 + hast-util-select: 6.0.2 + hastscript: 8.0.0 + mdast-util-directive: 3.0.0 + mdast-util-to-markdown: 2.1.0 + pagefind: 1.0.4 + rehype: 13.0.1 + remark-directive: 3.0.0 + unified: 11.0.4 + unist-util-remove: 4.0.0 + unist-util-visit: 5.0.0 + vfile: 6.0.1 + transitivePeerDependencies: + - supports-color + dev: true /@astrojs/tailwind@5.1.0(astro@4.3.7)(tailwindcss@3.4.1): resolution: {integrity: sha512-BJoCDKuWhU9FT2qYg+fr6Nfb3qP4ShtyjXGHKA/4mHN94z7BGcmauQK23iy+YH5qWvTnhqkd6mQPQ1yTZTe9Ig==} @@ -2642,6 +2698,17 @@ packages: astro: 4.4.0(typescript@5.3.3) hast-util-to-html: 8.0.4 remark-expressive-code: 0.32.4 + dev: false + + /astro-expressive-code@0.32.4(astro@4.4.9): + resolution: {integrity: sha512-/Kq8wLMz0X2gbLWGmPryqEdFV/om/GROsoLtPFqLrLCRD5CpwxXAW185BIGZKf4iYsyJim1vvcpQm5Y9hV5B1g==} + peerDependencies: + astro: ^3.3.0 || ^4.0.0-beta + dependencies: + astro: 4.4.9(@types/node@20.11.24) + hast-util-to-html: 8.0.4 + remark-expressive-code: 0.32.4 + dev: true /astro-font@0.0.77: resolution: {integrity: sha512-dh5TX2uxwqdFq15DF9cbRZgEdE9o8q522MP6xZYs+rnd3dexfDsIJMeEIDNVO7rkRxwJ7sphhCqTmdWvUJaiDg==} @@ -2928,8 +2995,8 @@ packages: tsconfck: 3.0.2(typescript@5.3.3) unist-util-visit: 5.0.0 vfile: 6.0.1 - vite: 5.1.4(@types/node@20.11.24) - vitefu: 0.2.5(vite@5.1.4) + vite: 5.1.5(@types/node@20.11.24) + vitefu: 0.2.5(vite@5.1.5) which-pm: 2.1.1 yargs-parser: 21.1.1 zod: 3.22.4 @@ -2945,7 +3012,6 @@ packages: - supports-color - terser - typescript - dev: false /astrojs-compiler-sync@0.3.5(@astrojs/compiler@2.5.3): resolution: {integrity: sha512-y420rhIIJ2HHDkYeqKArBHSdJNIIGMztLH90KGIX3zjcJyt/cr9Z2wYA8CP5J1w6KE7xqMh0DAkhfjhNDpQb2Q==} @@ -8009,7 +8075,17 @@ packages: vite: optional: true dependencies: - vite: 5.1.4(@types/node@20.11.24) + vite: 5.1.4(sass@1.71.0) + + /vitefu@0.2.5(vite@5.1.5): + resolution: {integrity: sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==} + peerDependencies: + vite: ^3.0.0 || ^4.0.0 || ^5.0.0 + peerDependenciesMeta: + vite: + optional: true + dependencies: + vite: 5.1.5(@types/node@20.11.24) /vitest-fetch-mock@0.2.2(vitest@1.3.1): resolution: {integrity: sha512-XmH6QgTSjCWrqXoPREIdbj40T7i1xnGmAsTAgfckoO75W1IEHKR8hcPCQ7SO16RsdW1t85oUm6pcQRLeBgjVYQ==} From 70b6fd2d1657cf800d70f703b7ba9cb64f6f9fbf Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 20:26:43 -0800 Subject: [PATCH 40/46] remove unused config option --- packages/starlight-ghostcms/src/schemas/config.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/starlight-ghostcms/src/schemas/config.ts b/packages/starlight-ghostcms/src/schemas/config.ts index 19c55fd8..b2f617df 100644 --- a/packages/starlight-ghostcms/src/schemas/config.ts +++ b/packages/starlight-ghostcms/src/schemas/config.ts @@ -3,21 +3,6 @@ import { z } from "astro/zod"; const configSchema = z .object({ - /** OPTIONAL - Either set the URL in your .env or put it here - * @example - * // https://astro.build/config - * export default defineConfig({ - * integrations: [ - * starlight({ - * plugins: [ - * starlightGhost({ - * ghostURL: "https://ghostdemo.matthiesen.xyz" - * }) - * ], - * }) - * ], - * }); */ - ghostURL: z.string().url("Must be a URL").optional(), /** * The number of blog posts to display per page in the blog post list. */ From f078ebc06372652dc32a7baab64f3bbac9956cbc Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 21:24:01 -0800 Subject: [PATCH 41/46] new starlight feature.... prep for expansion of astro-ghostcms --- .changeset/quiet-teachers-knock.md | 3 +++ packages/starlight-ghostcms/index.ts | 15 +++++++++----- .../src/overrides/MarkdownContent.astro | 11 +++++++--- .../src/overrides/Sidebar.astro | 20 +++++++++---------- .../src/overrides/SiteTitle.astro | 3 ++- .../starlight-ghostcms/src/routes/rss.xml.ts | 2 +- .../starlight-ghostcms/src/schemas/config.ts | 10 +++++++++- packages/starlight-ghostcms/src/utils/page.ts | 8 ++++---- .../starlight-playground/astro.config.mjs | 2 +- 9 files changed, 47 insertions(+), 27 deletions(-) diff --git a/.changeset/quiet-teachers-knock.md b/.changeset/quiet-teachers-knock.md index 9d4b6fae..5bec232a 100644 --- a/.changeset/quiet-teachers-knock.md +++ b/.changeset/quiet-teachers-knock.md @@ -3,3 +3,6 @@ --- Bumb GhostCMS API, No user facing breaking changes. + +NEW: +- You can now set a `route: "blog"` in your `astro.config.mjs` to change the default `/` to your blog/posts \ No newline at end of file diff --git a/packages/starlight-ghostcms/index.ts b/packages/starlight-ghostcms/index.ts index ff69284b..8e1238dd 100644 --- a/packages/starlight-ghostcms/index.ts +++ b/packages/starlight-ghostcms/index.ts @@ -78,11 +78,16 @@ export default function starlightGhostCMS( }); }; - makeRoute("blog", "index.astro"); - makeRoute("blog/[slug]", "[slug].astro"); - makeRoute("blog/about", "about.astro"); - makeRoute("blog/authors", "authors.astro"); - makeRoute("rss.xml", "rss.xml.ts"); + makeRoute(`${config.route}`, + "index.astro"); + makeRoute(`${config.route}/[slug]`, + "[slug].astro"); + makeRoute(`${config.route}/about`, + "about.astro"); + makeRoute(`${config.route}/authors`, + "authors.astro"); + makeRoute("rss.xml", + "rss.xml.ts"); }, }, diff --git a/packages/starlight-ghostcms/src/overrides/MarkdownContent.astro b/packages/starlight-ghostcms/src/overrides/MarkdownContent.astro index 80c0151b..b9df9e05 100644 --- a/packages/starlight-ghostcms/src/overrides/MarkdownContent.astro +++ b/packages/starlight-ghostcms/src/overrides/MarkdownContent.astro @@ -1,22 +1,27 @@ --- import StarlightMarkdownContent from '@astrojs/starlight/components/MarkdownContent.astro' import type { Props } from '@astrojs/starlight/props' - +import config from 'virtual:starlight-ghostcms/config' import { isAnyBlogPostPage } from '../utils/page' import Metadata from '../components/Metadata.astro' import type { Post } from '../schemas/posts' +export function checkpath(path: string){ + return path.split('/').includes(config.route) ? true : false +} + +const isBlog = checkpath(Astro.url.pathname) const isBlogPost = isAnyBlogPostPage(Astro.props.slug) let blogEntry: Post | undefined = undefined --- - {isBlogPost && blogEntry ? : null} + {isBlog && blogEntry ? : null} { - isBlogPost && blogEntry ? ( + isBlog && blogEntry ? ( ) : null diff --git a/packages/starlight-ghostcms/src/overrides/Sidebar.astro b/packages/starlight-ghostcms/src/overrides/Sidebar.astro index ffc8f358..885426c2 100644 --- a/packages/starlight-ghostcms/src/overrides/Sidebar.astro +++ b/packages/starlight-ghostcms/src/overrides/Sidebar.astro @@ -17,19 +17,17 @@ export async function getBlogPageEntries(){ } export function checkpath(path: string){ - if ( path.slice(0, 5) === "/blog" ){ - return true - } else { return false } + return path.split('/').includes(config.route) ? true : false } export function isAbout(path: string){ - if ( path === "/blog/about" ){ + if ( path === `/${config.route}/about` ){ return true } else { return false } } export function isAuthors(path: string){ - if ( path === "/blog/authors" ){ + if ( path === `/${config.route}/authors` ){ return true } else { return false } } @@ -38,7 +36,7 @@ const recentEntries = isBlog ? await getRecentBlogEntries() : [] const aboutPage = await getSluggedPage("about"); const AboutEntry:SidebarEntry = { attrs: {}, badge: undefined, - href: '/blog/about', + href: `/${config.route}/about`, isCurrent: isAbout(Astro.url.pathname), type: 'link', label: aboutPage?.post?.title @@ -55,7 +53,7 @@ const blogSidebar: Props['sidebar'] = isBlog { attrs: {}, badge: undefined, - href: '/blog/authors', + href: `/${config.route}/authors`, isCurrent: isAuthors(Astro.url.pathname), label: 'Our Authors', type: 'link', @@ -63,7 +61,7 @@ const blogSidebar: Props['sidebar'] = isBlog { attrs: {}, badge: undefined, - href: '/blog', + href: `/${config.route}`, isCurrent: isBlogRoot(Astro.props.slug), label: 'All posts', type: 'link', @@ -74,8 +72,8 @@ const blogSidebar: Props['sidebar'] = isBlog entries: recentEntries.map((blogEntry) => ({ attrs: {}, badge: blogEntry.featured?({text: "⭐", variant: "note"}):undefined, - href: `/blog/${blogEntry.slug}`, - isCurrent: isBlogPostPage(Astro.props.slug, `blog/${blogEntry.slug}`), + href: `/${config.route}/${blogEntry.slug}`, + isCurrent: isBlogPostPage(Astro.props.slug, `${config.route}/${blogEntry.slug}`), label: blogEntry.title, type: 'link', })), @@ -89,7 +87,7 @@ const blogSidebar: Props['sidebar'] = isBlog { !isBlog && (
- Blog + Blog
) } diff --git a/packages/starlight-ghostcms/src/overrides/SiteTitle.astro b/packages/starlight-ghostcms/src/overrides/SiteTitle.astro index 328b4874..5093fd36 100644 --- a/packages/starlight-ghostcms/src/overrides/SiteTitle.astro +++ b/packages/starlight-ghostcms/src/overrides/SiteTitle.astro @@ -1,11 +1,12 @@ --- import type { Props } from "@astrojs/starlight/props"; import AstrolightSiteTitle from "@astrojs/starlight/components/SiteTitle.astro"; +import config from 'virtual:starlight-ghostcms/config' ---