woot RSS stylesheets are working now

This commit is contained in:
Adam Matthiesen 2024-02-05 22:14:12 -08:00
parent cb95f0fe83
commit 069b097f0b
6 changed files with 231 additions and 128 deletions

View File

@ -81,12 +81,16 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
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
logger.info("Checking Config...")
logConfigCheck.info("Checking Config...")
const GhostUserConfig = UserConfigSchema.safeParse(options || {}) as SafeParseSuccess<UserConfig>;
if (!GhostUserConfig.success) {
const validationError = fromZodError((GhostUserConfig as unknown as SafeParseError<UserConfig>).error);
logger.error(`Config Error - ${ validationError }`);
logConfigCheck.error(`Config Error - ${ validationError }`);
throw Error("");
}
const GhostConfig = GhostUserConfig.data;
@ -103,18 +107,18 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
}
// Check For ENV Variables
if(!GCD.dCO) {logger.info(IC.CHECK_ENV)}
if(!GCD.dCO) {logConfigCheck.info(IC.CHECK_ENV)}
// CHECK FOR API KEY
if(ENV.CONTENT_API_KEY === undefined){
logger.error(IC.KEY_MISSING);
logConfigCheck.error(IC.KEY_MISSING);
throw IC.KEY_MISSING;
}
// CHECK FOR API URL
if(GCD.gSite === undefined){
logger.warn(IC.NOURL)
logConfigCheck.warn(IC.NOURL)
if(ENV.CONTENT_API_URL === undefined){
logger.error(IC.URL_MISSING);
logConfigCheck.error(IC.URL_MISSING);
throw IC.URL_MISSING;
}
}
@ -123,34 +127,38 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
// THEME SELECTOR
if ( GCD.theme === IC.DT ) {
if( !GCD.dCO ) { logger.info( IC.IT + IC.DT )}
if( !GCD.dCO ) { logConfigCheck.info( IC.IT + IC.DT )}
} else {
if( !GCD.dCO ) { logger.info( IC.IT + GCD.theme )}
if( !GCD.dCO ) { logConfigCheck.info( IC.IT + GCD.theme )}
}
// INJECT ROUTES
// DEFAULT PROGRAM ROUTES
if( !GCD.dCO ) { logger.info( IC.IDR )}
if( !GCD.dCO ) { logConfigSetup.info( IC.IDR )}
if( !GCD.d404 ){
if( !GCD.dCO ) { logger.info( IC.F0FR )}
if( !GCD.dCO ) { logConfigSetup.info( IC.F0FR )}
injectRoute({
pattern: '/404',
entrypoint: `${IC.PKG}/404.astro`
});
} else { if( !GCD.dCO ) { logger.info(IC.id404)}}
} else { if( !GCD.dCO ) { logConfigSetup.info(IC.id404)}}
if( !GCD.dRSS ) {
if( !GCD.dCO ) { logger.info( IC.RSS )}
if( !GCD.dCO ) { logConfigSetup.info( IC.RSS )}
injectRoute({
pattern: '/rss.xml',
entrypoint: `${IC.PKG}/rss.xml.ts`
});
} else { if( !GCD.dCO ) { logger.info(IC.idRSS)}}
injectRoute({
pattern: '/rss-style.xsl',
entrypoint: `${IC.PKG}/rss-style.xsl.ts`
});
} else { if( !GCD.dCO ) { logConfigSetup.info(IC.idRSS)}}
if ( !GCD.dOG ) {
if( !GCD.dCO ) { logger.info( IC.satori_e )}
if( !GCD.dCO ) { logConfigSetup.info( IC.satori_e )}
injectRoute({
pattern: '/open-graph/[slug].png',
entrypoint: `${IC.PKG}/open-graph/[slug].png.ts`
@ -175,10 +183,10 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
pattern: '/open-graph/tag/[slug].png',
entrypoint: `${IC.PKG}/open-graph/tag/[slug].png.ts`
});
} else { if( !GCD.dCO ) { logger.info( IC.satori_d )}}
} else { if( !GCD.dCO ) { logConfigSetup.info( IC.satori_d )}}
// THEME ROUTES
if( !GCD.dCO ) { logger.info( IC.ITR )}
if( !GCD.dCO ) { logConfigSetup.info( IC.ITR )}
injectRoute({
pattern: '/',
@ -215,27 +223,27 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
entrypoint: `${GCD.theme}/archives/[...page].astro`
});
} else { if( !GCD.dCO ) { logger.info( IC.IRD )} }
} else { if( !GCD.dCO ) { logConfigSetup.info( IC.IRD )} }
// IMPORT INTEGRATIONS & INTEGRATION ROUTES
const integrations = [...config.integrations];
// IMPORT INTEGRATION: @ASTROJS/SITEMAP
if( !GCD.dCO ) { logger.info( `${IC.CF}@astrojs/sitemap` )}
if( !GCD.dCO ) { logConfigSetup.info( `${IC.CF}@astrojs/sitemap` )}
if (!integrations.find(({ name }) => name === '@astrojs/sitemap' )) {
if( !GCD.dCO ) { logger.info( `${IC.II}@astrojs/sitemap` )}
if( !GCD.dCO ) { logConfigSetup.info( `${IC.II}@astrojs/sitemap` )}
integrations.push(ghostSitemap(GCD.SM));
} else { if( !GCD.dCO ) { logger.info( `${IC.AIbU}@astrojs/sitemap` )}
} else { if( !GCD.dCO ) { logConfigSetup.info( `${IC.AIbU}@astrojs/sitemap` )}
};
// IMPORT INTEGRATION: ASTRO-ROBOTS-TXT
if( !GCD.dCO ) { logger.info( `${IC.CF}astro-robots-txt` )}
if( !GCD.dCO ) { logConfigSetup.info( `${IC.CF}astro-robots-txt` )}
if (!integrations.find(({ name }) => name === 'astro-robots-txt' )) {
if( !GCD.dCO ) { logger.info( `${IC.II}astro-robots-txt` )}
if( !GCD.dCO ) { logConfigSetup.info( `${IC.II}astro-robots-txt` )}
integrations.push(ghostRobots(GCD.RTXT));
} else {
if( !GCD.dCO ) { logger.info( `${IC.AIbU}astro-robots-txt` )}
if( !GCD.dCO ) { logConfigSetup.info( `${IC.AIbU}astro-robots-txt` )}
};
// FINAL STEP TO KEEP INTEGRATION LIVE
@ -252,7 +260,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
}
// LOAD VITE AND SETUP viteGhostCMS Configs
}) } catch ( e ) {
logger.error( e as string );
logConfigSetup.error( e as string );
throw e;
};
@ -264,17 +272,27 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
},
'astro:config:done': async ({ logger }) => {
logger.info(IC.CONFSETUPDONE);
// DEFINE LOGGERS
const logConfigDone = logger.fork("astro-ghostcms/config: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");
// Get Package Version for Intro
const pathname = fileURLToPath(import.meta.url);
const iJSON = path.resolve(pathname, "..", 'package.json');
const pJSON = await fse.readJson(iJSON);
// CONFIG DONE
logConfigDone.info(IC.CONFSETUPDONE);
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 ) {
logger.fork("astro-ghostcms/update-check").warn(`Current Version is v${pkgVer}, Most recent Version is v${npmVER}`)
logCurrentVersion.warn(`Current Installed Version is v${pkgVer}`);
logNpmVersion.warn(`Latest Published Version is v${npmVER}`);
logCheck.warn("Please consider updating.");
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
"version": "3.1.8",
"version": "3.1.8-dev01",
"homepage": "https://astro-ghostcms.xyz/",
"type": "module",
"license": "MIT",
@ -51,6 +51,7 @@
"./api-core": "./src/api/content-api/index.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",
"./config": "./src/integrations/virtual-config.ts",
"./types": "./types.ts",
"./satoriOG": "./src/integrations/satori.ts",
@ -68,7 +69,7 @@
"test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'"
},
"peerDependencies": {
"astro": "^4.2.8"
"astro": "^4.3.2"
},
"devDependencies": {
"@astrojs/check": "^0.4.1",

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
import { fileURLToPath } from 'node:url';
import path from "node:path";
import pkg from 'fs-extra';
const { readFile } = pkg;
export async function GET(){
const response = readFile(path.resolve(fileURLToPath(import.meta.url), "..", 'rss-style.xsl'));
const buffer = Buffer.from((await response).buffer);
return new Response(buffer, {
headers: { "Content-Type": "text/xsl" },
});
}

View File

@ -13,6 +13,7 @@ export async function GET({ site, generator }: APIContext) {
title: `${title} [Built on ${generator.slice(0, 8)}]`,
description: description,
site: site?site:"",
stylesheet: "/rss-style.xsl",
items: posts.map((post) => ({
title: post.title,
pubDate: new Date(post.published_at?post.published_at:post.created_at),

View File

@ -34,7 +34,7 @@ importers:
version: link:../packages/astro-ghostcms-catppuccin
astro:
specifier: ^4.3.2
version: 4.3.2(typescript@5.3.3)
version: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
tailwindcss:
specifier: ^3.3.5
version: 3.4.1
@ -56,7 +56,7 @@ importers:
version: 0.1.8(astro@4.3.2)(typescript@5.3.3)
astro:
specifier: ^4.3.2
version: 4.3.2(typescript@5.3.3)
version: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
devDependencies:
'@astrojs/check':
specifier: ^0.4.1
@ -83,8 +83,8 @@ importers:
specifier: ^5.1.2
version: 5.1.2
astro:
specifier: ^4.2.8
version: 4.2.8(@types/node@20.11.16)(typescript@5.3.3)
specifier: ^4.3.2
version: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
astro-robots-txt:
specifier: ^1.0.0
version: 1.0.0
@ -178,7 +178,7 @@ importers:
version: 0.5.10(tailwindcss@3.4.1)
astro:
specifier: ^4.2.1
version: 4.2.8(@types/node@20.11.16)(typescript@5.3.3)
version: 4.2.8
astro-navbar:
specifier: ^2.3.0
version: 2.3.0
@ -296,7 +296,7 @@ importers:
version: link:../packages/astro-ghostcms-theme-default
astro:
specifier: ^4.3.2
version: 4.3.2(typescript@5.3.3)
version: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
tailwindcss:
specifier: ^3.3.5
version: 3.4.1
@ -532,7 +532,7 @@ packages:
astro: ^3.0.0 || ^4.0.0
tailwindcss: ^3.0.24
dependencies:
astro: 4.2.8(@types/node@20.11.16)(typescript@5.3.3)
astro: 4.2.8
autoprefixer: 10.4.17(postcss@8.4.33)
postcss: 8.4.33
postcss-load-config: 4.0.2(postcss@8.4.33)
@ -547,7 +547,7 @@ packages:
astro: ^3.0.0 || ^4.0.0
tailwindcss: ^3.0.24
dependencies:
astro: 4.3.2(typescript@5.3.3)
astro: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
autoprefixer: 10.4.17(postcss@8.4.33)
postcss: 8.4.33
postcss-load-config: 4.0.2(postcss@8.4.33)
@ -1663,7 +1663,7 @@ packages:
astro: ^4.2.1
dependencies:
'@matthiesenxyz/astro-ghostcms': 3.1.8(astro@4.3.2)(sass@1.70.0)(typescript@5.3.3)
astro: 4.3.2(typescript@5.3.3)
astro: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
astro-font: 0.0.77
sass: 1.70.0
transitivePeerDependencies:
@ -1683,7 +1683,7 @@ packages:
astro: ^4.2.1
dependencies:
'@matthiesenxyz/astro-ghostcms': 3.1.8(astro@4.3.2)(sass@1.70.0)(typescript@5.3.3)
astro: 4.3.2(typescript@5.3.3)
astro: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
astro-font: 0.0.77
sass: 1.70.0
transitivePeerDependencies:
@ -1707,7 +1707,7 @@ packages:
'@matthiesenxyz/astro-ghostcms-theme-default': 0.1.9(astro@4.3.2)(typescript@5.3.3)
'@resvg/resvg-js': 2.6.0
'@ts-ghost/core-api': 5.1.2
astro: 4.3.2(typescript@5.3.3)
astro: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
astro-robots-txt: 1.0.0
satori: 0.10.13
satori-html: 0.3.2
@ -1737,7 +1737,7 @@ packages:
'@matthiesenxyz/astro-ghostcms-theme-default': 0.1.9(astro@4.3.2)(typescript@5.3.3)
'@resvg/resvg-js': 2.6.0
'@ts-ghost/core-api': 5.1.2
astro: 4.3.2(typescript@5.3.3)
astro: 4.3.2(@types/node@20.11.16)(typescript@5.3.3)
astro-robots-txt: 1.0.0
satori: 0.10.13
satori-html: 0.3.2
@ -2881,7 +2881,7 @@ packages:
- typescript
dev: false
/astro@4.2.8(@types/node@20.11.16)(typescript@5.3.3):
/astro@4.2.8:
resolution: {integrity: sha512-h78IAdSEPMo1bvR40HECQYpnMPfDnk9WxRNJ1+Hw5szk4k5IMUw3nG153nErJABRnaxb6WLv7dtS4tukzJz0mw==}
engines: {node: '>=18.14.1', npm: '>=6.14.0'}
hasBin: true
@ -2964,6 +2964,89 @@ packages:
- typescript
dev: false
/astro@4.3.2(@types/node@20.11.16)(typescript@5.3.3):
resolution: {integrity: sha512-SJotHzKG/I32ruYWItMRJjtmNQh14mVS7kahu3XfYyxvo6nx08PGJBTSPbqPrW1sjeQPHwcpVDFx3yMMK2kaxQ==}
engines: {node: '>=18.14.1', npm: '>=6.14.0'}
hasBin: true
dependencies:
'@astrojs/compiler': 2.5.0
'@astrojs/internal-helpers': 0.2.1
'@astrojs/markdown-remark': 4.2.1
'@astrojs/telemetry': 3.0.4
'@babel/core': 7.23.7
'@babel/generator': 7.23.6
'@babel/parser': 7.23.6
'@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.7)
'@babel/traverse': 7.23.7
'@babel/types': 7.23.6
'@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.5.3
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.1.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.5
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.5.4
server-destroy: 1.0.1
shikiji: 0.9.19
string-width: 7.1.0
strip-ansi: 7.1.0
tsconfck: 3.0.1(typescript@5.3.3)
unist-util-visit: 5.0.0
vfile: 6.0.1
vite: 5.0.12(@types/node@20.11.16)
vitefu: 0.2.5(vite@5.0.12)
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.3.2(sass@1.70.0)(typescript@5.3.3):
resolution: {integrity: sha512-SJotHzKG/I32ruYWItMRJjtmNQh14mVS7kahu3XfYyxvo6nx08PGJBTSPbqPrW1sjeQPHwcpVDFx3yMMK2kaxQ==}
engines: {node: '>=18.14.1', npm: '>=6.14.0'}
@ -3047,89 +3130,6 @@ packages:
- typescript
dev: false
/astro@4.3.2(typescript@5.3.3):
resolution: {integrity: sha512-SJotHzKG/I32ruYWItMRJjtmNQh14mVS7kahu3XfYyxvo6nx08PGJBTSPbqPrW1sjeQPHwcpVDFx3yMMK2kaxQ==}
engines: {node: '>=18.14.1', npm: '>=6.14.0'}
hasBin: true
dependencies:
'@astrojs/compiler': 2.5.0
'@astrojs/internal-helpers': 0.2.1
'@astrojs/markdown-remark': 4.2.1
'@astrojs/telemetry': 3.0.4
'@babel/core': 7.23.7
'@babel/generator': 7.23.6
'@babel/parser': 7.23.6
'@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.23.7)
'@babel/traverse': 7.23.7
'@babel/types': 7.23.6
'@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.5.3
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.1.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.5
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.5.4
server-destroy: 1.0.1
shikiji: 0.9.19
string-width: 7.1.0
strip-ansi: 7.1.0
tsconfck: 3.0.1(typescript@5.3.3)
unist-util-visit: 5.0.0
vfile: 6.0.1
vite: 5.0.12(@types/node@20.11.16)
vitefu: 0.2.5(vite@5.0.12)
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.0):
resolution: {integrity: sha512-y420rhIIJ2HHDkYeqKArBHSdJNIIGMztLH90KGIX3zjcJyt/cr9Z2wYA8CP5J1w6KE7xqMh0DAkhfjhNDpQb2Q==}
engines: {node: ^14.18.0 || >=16.0.0}