From 739150958725f501c6133fb9805726d797854149 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 21 Jan 2024 06:57:59 -0800 Subject: [PATCH] just some code cleanup and organization --- index.ts | 99 +++++++++++-------- package.json | 52 +++++----- src/api/functions.ts | 22 ++--- src/{ => theme}/components/AuthorCard.astro | 2 +- src/{ => theme}/components/AuthorList.astro | 2 +- src/{ => theme}/components/FeatureImage.astro | 2 +- src/{ => theme}/components/Footer.astro | 2 +- src/{ => theme}/components/Header.astro | 2 +- src/{ => theme}/components/HeroContent.astro | 2 +- src/{ => theme}/components/MainLayout.astro | 2 +- src/{ => theme}/components/Page.astro | 2 +- src/{ => theme}/components/Paginator.astro | 0 src/{ => theme}/components/Post.astro | 2 +- src/{ => theme}/components/PostFooter.astro | 2 +- src/{ => theme}/components/PostHero.astro | 2 +- src/{ => theme}/components/PostPreview.astro | 2 +- .../components/PostPreviewList.astro | 2 +- src/{ => theme}/components/TagCard.astro | 2 +- src/{ => theme}/layouts/default.astro | 2 +- src/{ => theme}/routes/404.astro | 0 src/{ => theme}/routes/[slug].astro | 2 +- .../routes/archives/[...page].astro | 3 +- src/{ => theme}/routes/author/[slug].astro | 2 +- src/{ => theme}/routes/authors.astro | 2 +- src/{ => theme}/routes/index.astro | 2 +- src/{ => theme}/routes/rss.xml.js | 2 +- src/{ => theme}/routes/tag/[slug].astro | 2 +- src/{ => theme}/routes/tags.astro | 2 +- src/{ => theme}/styles/404.css | 0 src/{ => theme}/styles/app.scss | 0 src/{ => theme}/styles/reset.scss | 0 src/{ => theme}/styles/variables.scss | 0 src/{ => theme}/utils/index.ts | 0 src/utils/UserConfigSchema.ts | 1 + 34 files changed, 119 insertions(+), 102 deletions(-) rename src/{ => theme}/components/AuthorCard.astro (97%) rename src/{ => theme}/components/AuthorList.astro (97%) rename src/{ => theme}/components/FeatureImage.astro (95%) rename src/{ => theme}/components/Footer.astro (98%) rename src/{ => theme}/components/Header.astro (99%) rename src/{ => theme}/components/HeroContent.astro (98%) rename src/{ => theme}/components/MainLayout.astro (89%) rename src/{ => theme}/components/Page.astro (99%) rename src/{ => theme}/components/Paginator.astro (100%) rename src/{ => theme}/components/Post.astro (99%) rename src/{ => theme}/components/PostFooter.astro (97%) rename src/{ => theme}/components/PostHero.astro (97%) rename src/{ => theme}/components/PostPreview.astro (99%) rename src/{ => theme}/components/PostPreviewList.astro (93%) rename src/{ => theme}/components/TagCard.astro (96%) rename src/{ => theme}/layouts/default.astro (98%) rename src/{ => theme}/routes/404.astro (100%) rename src/{ => theme}/routes/[slug].astro (99%) rename src/{ => theme}/routes/archives/[...page].astro (92%) rename src/{ => theme}/routes/author/[slug].astro (99%) rename src/{ => theme}/routes/authors.astro (94%) rename src/{ => theme}/routes/index.astro (93%) rename src/{ => theme}/routes/rss.xml.js (90%) rename src/{ => theme}/routes/tag/[slug].astro (99%) rename src/{ => theme}/routes/tags.astro (95%) rename src/{ => theme}/styles/404.css (100%) rename src/{ => theme}/styles/app.scss (100%) rename src/{ => theme}/styles/reset.scss (100%) rename src/{ => theme}/styles/variables.scss (100%) rename src/{ => theme}/utils/index.ts (100%) diff --git a/index.ts b/index.ts index 5dc35d90..9bfca339 100644 --- a/index.ts +++ b/index.ts @@ -6,24 +6,40 @@ import { loadEnv } from 'vite'; import { fromZodError } from "zod-validation-error"; import { viteGhostCMS } from "./src/utils/virtual-imports"; -// LOAD ENVIRONMENT VARIABLES -const mode = 'all'; -const prefixes = 'CONTENT_API'; -const env = loadEnv(mode, process.cwd(), prefixes); +/** INTERNAL CONSTANTS */ +const IC = { + /** INTERNAL PACKAGE NAME */ + PKG:'@matthiesenxyz/astro-ghostcms', + /** 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", + /** INTERNAL STRING */ + URL_MISSING:"CONTENT_API_URL Missing from .env", + /** INTERNAL STRING */ + IT:"Injecting Theme: ", + /** INTERNAL STRING */ + IR:"Injecting 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:"GhostCMS Injection Complete. Integration is now ready.", +} -// INTERNAL CONSTANTS -const pkg = '@matthiesenxyz/astro-ghostcms'; -const CHECK_ENV = "Checking for Environment Variables..."; -const KEY_MISSING = "CONTENT_API_KEY Missing from .env"; -const URL_MISSING = "CONTENT_API_URL Missing from .env"; -const IT = "Injecting Theme: " -const IR = "Injecting Routes..."; -const IRD = "Route Injection Disabled - Skipping..."; -const IIR = "Injecting Integration Route: " -const II = "Injecting Integration: "; -const AIbU = "Already Imported by User: "; -const CF = "Checking for "; -const CONFSETUPDONE = "GhostCMS Injection Complete. Integration is now ready." +/** 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 @@ -31,7 +47,7 @@ const CONFSETUPDONE = "GhostCMS Injection Complete. Integration is now ready." */ export default function GhostCMS(options: UserConfig): AstroIntegration { return { - name: pkg, + name: IC.PKG, hooks: { 'astro:config:setup': async ({ injectRoute, @@ -47,36 +63,39 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { logger.error(`Config Error - ${ validationError }`); throw validationError; } + /** INTERNAL USERCONFIG ALIAS */ const uconf = o.data; + /** CONFIG OPTION: ROUTE INJECTION */ const injection = uconf.disableRouteInjection; + /** CONFIG OPTION: THEME */ const entry = uconf.theme; + /** CONFIG OPTION: CONSOLE OUTPUT */ const logs = uconf.disableConsoleOutput; // Check For ENV Variables - if(!logs) {logger.info(CHECK_ENV)} + if(!logs) {logger.info(IC.CHECK_ENV)} // CHECK FOR API KEY - if(env.CONTENT_API_KEY === undefined){ - logger.error(KEY_MISSING); - throw KEY_MISSING; + if(ENV.CONTENT_API_KEY === undefined){ + logger.error(IC.KEY_MISSING); + throw IC.KEY_MISSING; } // CHECK FOR API URL - if(env.CONTENT_API_URL === undefined){ - logger.error(URL_MISSING); - throw URL_MISSING; + if(ENV.CONTENT_API_URL === undefined){ + logger.error(IC.URL_MISSING); + throw IC.URL_MISSING; } - if(!injection){ // THEME SELECTOR - if (entry === pkg) { - if(!logs) {logger.info(IT + pkg)} + if (entry === IC.PKG) { + if(!logs) {logger.info(IC.IT + IC.PKG)} } else { - if(!logs) {logger.info(IT + entry)} + if(!logs) {logger.info(IC.IT + entry)} } // INJECT ROUTES - if(!logs) {logger.info(IR)} + if(!logs) {logger.info(IC.IR)} injectRoute({ pattern: '/', @@ -118,35 +137,35 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { entrypoint: `${entry}/archives/[...page].astro` }); } else { - if(!logs) {logger.info(IRD)} + if(!logs) {logger.info(IC.IRD)} } // IMPORT INTEGRATIONS & INTEGRATION ROUTES const int = [...config.integrations]; // IMPORT INTEGRATION: @ASTROJS/RSS - if(!logs) {logger.info(IIR + "@astrojs/rss")} + if(!logs) {logger.info(IC.IIR + "@astrojs/rss")} injectRoute({ pattern: '/rss.xml', - entrypoint: `${pkg}/rss.xml.js` + entrypoint: `${IC.PKG}/rss.xml.js` }); // IMPORT INTEGRATION: @ASTROJS/SITEMAP - if(!logs) {logger.info(CF + "@astrojs/sitemap")} + if(!logs) {logger.info(IC.CF + "@astrojs/sitemap")} if (!int.find(({ name }) => name === '@astrojs/sitemap')) { - if(!logs) {logger.info(II + "@astrojs/sitemap")} + if(!logs) {logger.info(IC.II + "@astrojs/sitemap")} int.push(ghostSitemap(uconf)); } else { - if(!logs) {logger.info(AIbU + "@astrojs/sitemap")} + if(!logs) {logger.info(IC.AIbU + "@astrojs/sitemap")} }; // IMPORT INTEGRATION: ASTRO-ROBOTS-TXT - if(!logs) {logger.info(CF + "astro-robots-txt")} + if(!logs) {logger.info(IC.CF + "astro-robots-txt")} if (!int.find(({ name }) => name === 'astro-robots-txt')) { - if(!logs) {logger.info(II + "astro-robots-txt")} + if(!logs) {logger.info(IC.II + "astro-robots-txt")} int.push(ghostRobots(uconf)); } else { - if(!logs) {logger.info(AIbU + "astro-robots-txt")} + if(!logs) {logger.info(IC.AIbU + "astro-robots-txt")} }; try {updateConfig({ integrations: [ @@ -161,7 +180,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration { }, 'astro:config:done': async ({ logger }) => { - logger.info(CONFSETUPDONE); + logger.info(IC.CONFSETUPDONE); } } } diff --git a/package.json b/package.json index 27d2370f..6d52dca9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@matthiesenxyz/astro-ghostcms", "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", - "version": "2.1.7", + "version": "2.1.8", "author": "MatthiesenXYZ (https://matthiesen.xyz)", "type": "module", "license": "MIT", @@ -17,15 +17,15 @@ "exports": { ".": "./index.ts", "./api": "./src/api/index.ts", - "./index.astro": "./src/routes/index.astro", - "./404.astro": "./src/routes/404.astro", - "./[slug].astro": "./src/routes/[slug].astro", - "./tags.astro": "./src/routes/tags.astro", - "./authors.astro": "./src/routes/authors.astro", - "./tag/[slug].astro": "./src/routes/tag/[slug].astro", - "./author/[slug].astro": "./src/routes/author/[slug].astro", - "./archives/[...page].astro": "./src/routes/archives/[...page].astro", - "./rss.xml.js": "./src/routes/rss.xml.js" + "./index.astro": "./src/theme/routes/index.astro", + "./404.astro": "./src/theme/routes/404.astro", + "./[slug].astro": "./src/theme/routes/[slug].astro", + "./tags.astro": "./src/theme/routes/tags.astro", + "./authors.astro": "./src/theme/routes/authors.astro", + "./tag/[slug].astro": "./src/theme/routes/tag/[slug].astro", + "./author/[slug].astro": "./src/theme/routes/author/[slug].astro", + "./archives/[...page].astro": "./src/theme/routes/archives/[...page].astro", + "./rss.xml.js": "./src/theme/routes/rss.xml.js" }, "main": "index.ts", "types": "src/api/tryghost-content-api.d.ts", @@ -57,25 +57,23 @@ }, "dependencies": { "@astrojs/check": "^0.3.4", - "typescript": "^5.3.3", - "zod-validation-error": "^3.0.0", - "axios": "^1.0.0", - "astro-font": "^0.0.72", - "@astrojs/renderer-svelte": "0.5.2", "@astrojs/rss": "^4.0.2", - "@astrojs/sitemap": "^3.0.4", + "@astrojs/sitemap": "^3.0.5", + "@typescript-eslint/eslint-plugin": "^6.19.0", + "@typescript-eslint/parser": "^6.19.0", + "astro": "^4.2.1", + "astro-font": "^0.0.72", "astro-robots-txt": "^1.0.0", - "@snowpack/plugin-dotenv": "^2.2.0", - "@typescript-eslint/eslint-plugin": "^6.5.0", - "@typescript-eslint/parser": "^6.5.0", - "astro": "^4.1.2", - "eslint": "^8.48.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-astro": "^0.29.0", - "prettier": "^3.0.3", - "prettier-plugin-astro": "^0.12.0", - "sass": "^1.66.1", + "axios": "^1.6.5", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-astro": "^0.29.1", + "prettier": "^3.2.4", + "prettier-plugin-astro": "^0.12.3", + "sass": "^1.70.0", "tiny-invariant": "^1.3.1", - "vite": "^4.4.9" + "typescript": "^5.3.3", + "vite": "^4.5.2", + "zod-validation-error": "^3.0.0" } } diff --git a/src/api/functions.ts b/src/api/functions.ts index 509ce4c0..812e2541 100644 --- a/src/api/functions.ts +++ b/src/api/functions.ts @@ -25,57 +25,57 @@ const api = GhostContentAPI({ key, url, version }); // SET Include params const include:ArrayOrValue = ['authors', 'tags']; -// Get Posts (General "ALL") +/** Get Posts (General "ALL") */ export const getGhostPosts = async () => { const ghostPosts:PostsOrPages = await api.posts.browse({include,filter:'visibility:public'}) return ghostPosts; }; -// Get Posts (Recent "setLimit?") +/** Get Posts (Recent "setLimit?") */ export const getGhostRecentPosts = async (setLimit?:ArrayOrValue) => { const ghostRecentPosts:PostsOrPages = await api.posts.browse({limit:setLimit?setLimit:"6",include,filter:'visibility:public'}); return ghostRecentPosts; }; -// Get Posts (Featured "setLimit?") +/** Get Posts (Featured "setLimit?") */ export const getGhostFeaturedPosts = async (setLimit?:ArrayOrValue) => { const ghostFeaturedPosts:PostsOrPages = await api.posts.browse({limit:setLimit?setLimit:"1",include,filter:'featured:true'}); return ghostFeaturedPosts; }; -// Get Post (By Slug) +/** Get Post (By Slug) */ export const getGhostPostbySlug = async (slug:Nullable) => { const ghostPostbySlug:PostOrPage = await api.posts.read({slug},{include}); return ghostPostbySlug; }; -// Get Post (By Tag) +/** Get Post (By Tag) */ export const getGhostPostsbyTag = async (slug:Nullable) => { const ghostPostsbyTag:PostsOrPages = await api.posts.browse({filter:`tag:${slug}`,include}); return ghostPostsbyTag; }; -// Get Tags (General "ALL") +/** Get Tags (General "ALL") */ export const getGhostTags = async () => { const ghostTags:Tags = await api.tags.browse({include:`count.posts`}); return ghostTags; }; -// Get Tag (By Slug) +/** Get Tag (By Slug) */ export const getGhostTagbySlug = async (slug:Nullable) => { const ghostTagbySlug:Tag = await api.tags.read({slug},{include:`count.posts`}); return ghostTagbySlug; }; -// Get Authors (General "ALL") +/** Get Authors (General "ALL") */ export const getGhostAuthors = async () => { const ghostAuthors:Authors = await api.authors.browse({include:`count.posts`}); return ghostAuthors; }; -// Get Pages (ALL) +/** Get Pages (ALL) */ export const getGhostPages = async () => { const ghostPages:PostsOrPages = await api.pages.browse(); return ghostPages; }; -// Get Page (by Slug) +/** Get Page (by Slug) */ export const getGhostPage = async (slug:Nullable) => { const ghostPage:PostOrPage = await api.pages.read({slug}); return ghostPage; }; -// Get Settings +/** Get Settings */ export const getGhostSettings = async () => { const ghostSettings:Settings = await api.settings.browse(); return ghostSettings; }; diff --git a/src/components/AuthorCard.astro b/src/theme/components/AuthorCard.astro similarity index 97% rename from src/components/AuthorCard.astro rename to src/theme/components/AuthorCard.astro index 23e4ab86..aa7fb26d 100644 --- a/src/components/AuthorCard.astro +++ b/src/theme/components/AuthorCard.astro @@ -1,6 +1,6 @@ --- import { getGhostImgPath } from "../utils"; -import type { Settings, Author } from "../api"; +import type { Settings, Author } from "../../api"; export type Props = { author: Author; wide?: boolean; diff --git a/src/components/AuthorList.astro b/src/theme/components/AuthorList.astro similarity index 97% rename from src/components/AuthorList.astro rename to src/theme/components/AuthorList.astro index 9b278c8a..bf94d6f0 100644 --- a/src/components/AuthorList.astro +++ b/src/theme/components/AuthorList.astro @@ -1,6 +1,6 @@ --- import { getGhostImgPath } from "../utils"; -import type { Settings, PostOrPage } from "../api"; +import type { Settings, PostOrPage } from "../../api"; export type Props = { post: PostOrPage; settings: Settings; diff --git a/src/components/FeatureImage.astro b/src/theme/components/FeatureImage.astro similarity index 95% rename from src/components/FeatureImage.astro rename to src/theme/components/FeatureImage.astro index ddbddaa2..c0949b42 100644 --- a/src/components/FeatureImage.astro +++ b/src/theme/components/FeatureImage.astro @@ -1,6 +1,6 @@ --- import { getGhostImgPath } from "../utils"; -import type { Settings } from "../api"; +import type { Settings } from "../../api"; export type Props = { image: string; alt?: string; diff --git a/src/components/Footer.astro b/src/theme/components/Footer.astro similarity index 98% rename from src/components/Footer.astro rename to src/theme/components/Footer.astro index 2f4d2939..e1664fa3 100644 --- a/src/components/Footer.astro +++ b/src/theme/components/Footer.astro @@ -1,5 +1,5 @@ --- -import type { Settings } from "../api"; +import type { Settings } from "../../api"; export type Props = { settings: Settings; }; diff --git a/src/components/Header.astro b/src/theme/components/Header.astro similarity index 99% rename from src/components/Header.astro rename to src/theme/components/Header.astro index 996f8add..32eaa73c 100644 --- a/src/components/Header.astro +++ b/src/theme/components/Header.astro @@ -1,5 +1,5 @@ --- -import type { Settings } from "../api"; +import type { Settings } from "../../api"; export type Props = { settings: Settings; }; diff --git a/src/components/HeroContent.astro b/src/theme/components/HeroContent.astro similarity index 98% rename from src/components/HeroContent.astro rename to src/theme/components/HeroContent.astro index c52a8788..6fa4bdd4 100644 --- a/src/components/HeroContent.astro +++ b/src/theme/components/HeroContent.astro @@ -1,6 +1,6 @@ --- import { getGhostImgPath } from "../utils"; -import type { Settings } from "../api"; +import type { Settings } from "../../api"; export type Props = { featureImg?: string; mainTitle?: string; diff --git a/src/components/MainLayout.astro b/src/theme/components/MainLayout.astro similarity index 89% rename from src/components/MainLayout.astro rename to src/theme/components/MainLayout.astro index d5ca8ab7..b8372fbb 100644 --- a/src/components/MainLayout.astro +++ b/src/theme/components/MainLayout.astro @@ -1,7 +1,7 @@ --- import Header from "./Header.astro"; import Footer from "./Footer.astro"; -import type { Settings } from "../api"; +import type { Settings } from "../../api"; export type Props = { settings: Settings; }; diff --git a/src/components/Page.astro b/src/theme/components/Page.astro similarity index 99% rename from src/components/Page.astro rename to src/theme/components/Page.astro index 857f8d92..07c54be2 100644 --- a/src/components/Page.astro +++ b/src/theme/components/Page.astro @@ -1,6 +1,6 @@ --- import FeatureImage from "./FeatureImage.astro"; -import type { Settings, PostOrPage } from "../api"; +import type { Settings, PostOrPage } from "../../api"; export type Props = { page: PostOrPage; settings: Settings; diff --git a/src/components/Paginator.astro b/src/theme/components/Paginator.astro similarity index 100% rename from src/components/Paginator.astro rename to src/theme/components/Paginator.astro diff --git a/src/components/Post.astro b/src/theme/components/Post.astro similarity index 99% rename from src/components/Post.astro rename to src/theme/components/Post.astro index 1554ef89..1357b80f 100644 --- a/src/components/Post.astro +++ b/src/theme/components/Post.astro @@ -2,7 +2,7 @@ import PostHero from "./PostHero.astro"; import PostFooter from "./PostFooter.astro"; import invariant from "tiny-invariant"; -import type {PostOrPage, PostsOrPages, Settings } from "../api"; +import type {PostOrPage, PostsOrPages, Settings } from "../../api"; export type Props = { post: PostOrPage; settings: Settings; diff --git a/src/components/PostFooter.astro b/src/theme/components/PostFooter.astro similarity index 97% rename from src/components/PostFooter.astro rename to src/theme/components/PostFooter.astro index 7203f4be..2f5a1bba 100644 --- a/src/components/PostFooter.astro +++ b/src/theme/components/PostFooter.astro @@ -1,6 +1,6 @@ --- import PostPreview from "./PostPreview.astro"; -import type { Settings, PostOrPage, PostsOrPages } from "../api"; +import type { Settings, PostOrPage, PostsOrPages } from "../../api"; export type Props = { post: PostOrPage; settings: Settings; diff --git a/src/components/PostHero.astro b/src/theme/components/PostHero.astro similarity index 97% rename from src/components/PostHero.astro rename to src/theme/components/PostHero.astro index 49bb2c47..5684c03b 100644 --- a/src/components/PostHero.astro +++ b/src/theme/components/PostHero.astro @@ -2,7 +2,7 @@ import FeatureImage from "./FeatureImage.astro"; import AuthorList from "./AuthorList.astro"; import { formatDate } from "../utils"; -import type { Settings, PostOrPage } from "../api"; +import type { Settings, PostOrPage } from "../../api"; export type Props = { post: PostOrPage; settings: Settings; diff --git a/src/components/PostPreview.astro b/src/theme/components/PostPreview.astro similarity index 99% rename from src/components/PostPreview.astro rename to src/theme/components/PostPreview.astro index 4a4a6bbd..66cdca96 100644 --- a/src/components/PostPreview.astro +++ b/src/theme/components/PostPreview.astro @@ -1,7 +1,7 @@ --- import { getGhostImgPath, formatDate } from "../utils"; import AuthorList from "./AuthorList.astro"; -import type { Settings, PostOrPage, Tag } from "../api"; +import type { Settings, PostOrPage, Tag } from "../../api"; export type Props = { post: PostOrPage; settings: Settings; diff --git a/src/components/PostPreviewList.astro b/src/theme/components/PostPreviewList.astro similarity index 93% rename from src/components/PostPreviewList.astro rename to src/theme/components/PostPreviewList.astro index 126908a7..78b3d95c 100644 --- a/src/components/PostPreviewList.astro +++ b/src/theme/components/PostPreviewList.astro @@ -1,6 +1,6 @@ --- import PostPreview from "./PostPreview.astro"; -import type { Settings, PostOrPage } from "../api"; +import type { Settings, PostOrPage } from "../../api"; export type Props = { posts: PostOrPage[]; settings: Settings; diff --git a/src/components/TagCard.astro b/src/theme/components/TagCard.astro similarity index 96% rename from src/components/TagCard.astro rename to src/theme/components/TagCard.astro index f200ad6f..329c4bd3 100644 --- a/src/components/TagCard.astro +++ b/src/theme/components/TagCard.astro @@ -1,6 +1,6 @@ --- import { getGhostImgPath } from "../utils"; -import type { Settings, Tag } from "../api"; +import type { Settings, Tag } from "../../api"; export type Props = { tag: Tag; addClass?: string; diff --git a/src/layouts/default.astro b/src/theme/layouts/default.astro similarity index 98% rename from src/layouts/default.astro rename to src/theme/layouts/default.astro index 6733bb13..13155f7a 100644 --- a/src/layouts/default.astro +++ b/src/theme/layouts/default.astro @@ -1,5 +1,5 @@ --- -import type { Settings } from "../api"; +import type { Settings } from "../../api"; import { AstroFont } from "astro-font"; import ViewTransitions from "astro/components/ViewTransitions.astro"; import MainLayout from "../components/MainLayout.astro"; diff --git a/src/routes/404.astro b/src/theme/routes/404.astro similarity index 100% rename from src/routes/404.astro rename to src/theme/routes/404.astro diff --git a/src/routes/[slug].astro b/src/theme/routes/[slug].astro similarity index 99% rename from src/routes/[slug].astro rename to src/theme/routes/[slug].astro index 51fff808..4d952571 100644 --- a/src/routes/[slug].astro +++ b/src/theme/routes/[slug].astro @@ -3,7 +3,7 @@ import type { InferGetStaticPropsType } from 'astro'; import DefaultPageLayout from "../layouts/default.astro"; import Page from "../components/Page.astro"; import Post from "../components/Post.astro"; -import { getGhostSettings, getGhostPages, getGhostPosts } from "../api"; +import { getGhostSettings, getGhostPages, getGhostPosts } from "../../api"; import invariant from 'tiny-invariant'; export async function getStaticPaths() { diff --git a/src/routes/archives/[...page].astro b/src/theme/routes/archives/[...page].astro similarity index 92% rename from src/routes/archives/[...page].astro rename to src/theme/routes/archives/[...page].astro index 270cc410..4ceb637e 100644 --- a/src/routes/archives/[...page].astro +++ b/src/theme/routes/archives/[...page].astro @@ -5,8 +5,7 @@ import DefaultPageLayout from "../../layouts/default.astro"; import PostPreviewList from "../../components/PostPreviewList.astro"; import HeroContent from "../../components/HeroContent.astro"; import Paginator from "../../components/Paginator.astro"; -import { getGhostSettings, getGhostPosts } from "../../api"; -import type { PostOrPage } from '../../api'; +import { getGhostSettings, getGhostPosts, type PostOrPage } from "../../../api"; export async function getStaticPaths({ paginate }:GetStaticPathsOptions) { const posts = await getGhostPosts(); diff --git a/src/routes/author/[slug].astro b/src/theme/routes/author/[slug].astro similarity index 99% rename from src/routes/author/[slug].astro rename to src/theme/routes/author/[slug].astro index 34eb85e5..d94d706a 100644 --- a/src/routes/author/[slug].astro +++ b/src/theme/routes/author/[slug].astro @@ -2,7 +2,7 @@ import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; import DefaultPageLayout from "../../layouts/default.astro"; import PostPreviewList from "../../components/PostPreviewList.astro"; -import { getGhostPosts, getGhostAuthors, getGhostSettings } from "../../api"; +import { getGhostPosts, getGhostAuthors, getGhostSettings } from "../../../api"; import invariant from "tiny-invariant"; export async function getStaticPaths() { diff --git a/src/routes/authors.astro b/src/theme/routes/authors.astro similarity index 94% rename from src/routes/authors.astro rename to src/theme/routes/authors.astro index 5b7dd7da..43f63e9c 100644 --- a/src/routes/authors.astro +++ b/src/theme/routes/authors.astro @@ -1,7 +1,7 @@ --- import DefaultPageLayout from "../layouts/default.astro"; import AuthorCard from "../components/AuthorCard.astro"; -import { getGhostAuthors, getGhostSettings } from "../api"; +import { getGhostAuthors, getGhostSettings } from "../../api"; import invariant from "tiny-invariant"; let title = "All Authors"; diff --git a/src/routes/index.astro b/src/theme/routes/index.astro similarity index 93% rename from src/routes/index.astro rename to src/theme/routes/index.astro index a2c43d39..6989de3a 100644 --- a/src/routes/index.astro +++ b/src/theme/routes/index.astro @@ -2,7 +2,7 @@ import DefaultPageLayout from "../layouts/default.astro"; import PostPreviewList from "../components/PostPreviewList.astro"; import HeroContent from "../components/HeroContent.astro"; -import { getGhostPosts, getGhostSettings } from "../api"; +import { getGhostPosts, getGhostSettings } from "../../api"; import invariant from "tiny-invariant"; const posts = await getGhostPosts(); const settings = await getGhostSettings(); diff --git a/src/routes/rss.xml.js b/src/theme/routes/rss.xml.js similarity index 90% rename from src/routes/rss.xml.js rename to src/theme/routes/rss.xml.js index cd3b48db..45537d41 100644 --- a/src/routes/rss.xml.js +++ b/src/theme/routes/rss.xml.js @@ -1,5 +1,5 @@ import rss from "@astrojs/rss"; -import { getGhostPosts, getGhostSettings } from '../api'; +import { getGhostPosts, getGhostSettings } from '../../api'; import invariant from "tiny-invariant"; export async function GET(context) { diff --git a/src/routes/tag/[slug].astro b/src/theme/routes/tag/[slug].astro similarity index 99% rename from src/routes/tag/[slug].astro rename to src/theme/routes/tag/[slug].astro index e32c2a9d..43daa250 100644 --- a/src/routes/tag/[slug].astro +++ b/src/theme/routes/tag/[slug].astro @@ -2,7 +2,7 @@ import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; import DefaultPageLayout from "../../layouts/default.astro"; import PostPreview from "../../components/PostPreview.astro"; -import { getGhostPosts, getGhostTags, getGhostSettings } from "../../api"; +import { getGhostPosts, getGhostTags, getGhostSettings } from "../../../api"; import { getGhostImgPath } from "../../utils"; import invariant from "tiny-invariant"; diff --git a/src/routes/tags.astro b/src/theme/routes/tags.astro similarity index 95% rename from src/routes/tags.astro rename to src/theme/routes/tags.astro index e6a8547d..2b4badf8 100644 --- a/src/routes/tags.astro +++ b/src/theme/routes/tags.astro @@ -1,7 +1,7 @@ --- import DefaultPageLayout from "../layouts/default.astro"; import TagCard from "../components/TagCard.astro"; -import { getGhostSettings, getGhostTags } from "../api"; +import { getGhostSettings, getGhostTags } from "../../api"; import invariant from 'tiny-invariant'; diff --git a/src/styles/404.css b/src/theme/styles/404.css similarity index 100% rename from src/styles/404.css rename to src/theme/styles/404.css diff --git a/src/styles/app.scss b/src/theme/styles/app.scss similarity index 100% rename from src/styles/app.scss rename to src/theme/styles/app.scss diff --git a/src/styles/reset.scss b/src/theme/styles/reset.scss similarity index 100% rename from src/styles/reset.scss rename to src/theme/styles/reset.scss diff --git a/src/styles/variables.scss b/src/theme/styles/variables.scss similarity index 100% rename from src/styles/variables.scss rename to src/theme/styles/variables.scss diff --git a/src/utils/index.ts b/src/theme/utils/index.ts similarity index 100% rename from src/utils/index.ts rename to src/theme/utils/index.ts diff --git a/src/utils/UserConfigSchema.ts b/src/utils/UserConfigSchema.ts index 8e161285..e2f87d01 100644 --- a/src/utils/UserConfigSchema.ts +++ b/src/utils/UserConfigSchema.ts @@ -24,4 +24,5 @@ export const UserConfigSchema = z.object({ robotstxt: S.RobotsTxtSchema.optional(), }); +/** USER CONFIGURATION SCHEMA */ export type UserConfig = z.infer \ No newline at end of file