diff --git a/.vscode/settings.json b/.vscode/settings.json
index 099362c4a..3c9ad40ea 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -19,6 +19,7 @@
"prototools",
"robotstxt",
"studiocms",
+ "twoslash",
"withstudiocms"
]
}
diff --git a/docs/src/content/docs/config-reference/included-integrations/index.mdx b/docs/src/content/docs/config-reference/included-integrations/index.mdx
index f36ab22ed..ac1ac45c0 100644
--- a/docs/src/content/docs/config-reference/included-integrations/index.mdx
+++ b/docs/src/content/docs/config-reference/included-integrations/index.mdx
@@ -15,33 +15,14 @@ import { defineStudioCMSConfig } from 'studiocms';
// ---cut---
export default defineStudioCMSConfig({
includedIntegrations: {
- useAstroRobots: true,
- astroRobotsConfig: {},
- useInoxSitemap: true,
+ robotsTXT: true,
},
})
```
-### `useAstroRobots`
+### `robotsTXT`
-- **Type:** `boolean | undefined`
+- **Type:** `boolean` | `RobotsConfig{}` | `undefined`
- **Default:** `true`
-Allows the user to enable/disable the use of the StudioCMS Custom `astro-robots-txt` Integration.
-
-### `astroRobotsConfig`
-
-- **Type:** `RobotsConfig{} | undefined{}`
-
-Allows you to modify the default behaviour of the this Integration. For more information on this Integration please visit the [Astro Robots Integration](https://www.npmjs.com/package/astro-robots).
-
-### `useInoxSitemap`
-
-#### TEMPORARILY DISABLED
-
-If you would like to still use the Inox-tools Sitemap Plugin, you can manually add it to your project's Integrations.
-
-- **Type:** `boolean | undefined`
-- **Default:** `true`
-
-Allows the user to enable/disable the use of the Inox-tools Sitemap Plugin. For more information on this Integration please visit the [Inox-tools Sitemap Integration](https://inox-tools.vercel.app/sitemap-ext).
\ No newline at end of file
+Allows the user to enable/disable the use of the StudioCMS Custom `astro-robots-txt` Integration. For more information on this Integration please visit the [Astro Robots Integration](https://www.npmjs.com/package/astro-robots).
\ No newline at end of file
diff --git a/docs/src/content/docs/config-reference/renderer-config/index.mdx b/docs/src/content/docs/config-reference/renderer-config/index.mdx
index c28bec468..34e5d05f1 100644
--- a/docs/src/content/docs/config-reference/renderer-config/index.mdx
+++ b/docs/src/content/docs/config-reference/renderer-config/index.mdx
@@ -12,10 +12,10 @@ import ReadMore from '~/components/ReadMore.astro';
The Markdown Content Renderer to use for rendering pages within StudioCMS
-- **Type:** `'marked'` | `'markdoc'` | `'astro'` | `'mdx'` | `CustomRenderer`
-- **Default:** `'marked'`
+- **Type:** `'astro'` | `'markdoc'` | `'mdx'` | `CustomRenderer`
+- **Default:** `'astro'`
-`renderer` determines how Markdown content should be rendered in `studioCMS`. This is used to setup your content data. The default value is `marked` but you can also use `markdoc` or `astro` which uses Astro's built-in Remark processor.
+`renderer` determines how Markdown content should be rendered in `studioCMS`. This is used to setup your content data. The default value is `astro` which uses the Astro built-in markdown processor but you can also use `markdoc`, `mdx` or define a Custom Renderer.
### Usage
@@ -24,22 +24,13 @@ import { defineStudioCMSConfig } from 'studiocms';
// ---cut---
export default defineStudioCMSConfig({
rendererConfig: {
- renderer: 'marked',
- markedConfig: {},
+ renderer: 'astro',
markdocConfig: {},
mdxConfig: {},
},
})
```
-## `markedConfig`
-
-`markedConfig` is an object that is used to determine how content should be rendered in the `studioCMS`. This is used to setup your content data.
-
-### Usage
-
-[See `markedConfig` for full options](/config-reference/marked-config)
-
## `markdocConfig`
`markdocConfig` is an object that is used to determine how content should be rendered in `studiocms` while using the MarkDoc renderer.
diff --git a/docs/src/content/docs/config-reference/renderer-config/markdoc-config.mdx b/docs/src/content/docs/config-reference/renderer-config/markdoc-config.mdx
index 612c3231c..37d7c00b5 100644
--- a/docs/src/content/docs/config-reference/renderer-config/markdoc-config.mdx
+++ b/docs/src/content/docs/config-reference/renderer-config/markdoc-config.mdx
@@ -30,7 +30,7 @@ This property has the following options:
### `renderType`
-- **Type:** `'html' | 'react-static' | markdocRenderer`
+- **Type:** `'html' | 'react-static' | MarkdocRenderer`
The MarkDoc content renderer type to use for rendering pages and posts can be `html`, `react-static` or a custom markdocRenderer.
diff --git a/docs/src/content/docs/config-reference/renderer-config/marked-config.mdx b/docs/src/content/docs/config-reference/renderer-config/marked-config.mdx
deleted file mode 100644
index 2f9a4a8f6..000000000
--- a/docs/src/content/docs/config-reference/renderer-config/marked-config.mdx
+++ /dev/null
@@ -1,152 +0,0 @@
----
-i18nReady: true
-title: markedConfig
-description: A reference page for markedConfig
-sidebar:
- order: 2.1
----
-
-`markedConfig` is an object that is used to determine how content should be rendered in the `studioCMS`. This is used to setup your content data.
-
-## Usage
-
-```ts twoslash {3-19} title="studiocms.config.mjs"
-import { defineStudioCMSConfig } from 'studiocms';
-// ---cut---
-export default defineStudioCMSConfig({
- rendererConfig: {
- markedConfig: {
- highlighterConfig: {
- highlighter: "disabled",
- shikiConfig: {
- theme: "houston",
- loadThemes: [],
- loadLangs: [],
- },
- },
- includedExtensions: {
- markedAlert: true,
- markedFootnote: true,
- markedSmartypants: true,
- markedEmoji: true,
- },
- loadmarkedExtensions: [],
- },
- }
-})
-```
-
-This property has the following options:
-
-### `includeExtensions`
-
-- **Type:** `markedExtensionsSchema{} | undefined{}`
-
-Allows you to enable or disable the included Marked Extensions, such as `marked-alert`, `marked-footnote`, `marked-smartypants`, and `marked-emoji`.
-
-#### `markedAlert`
-
-- **Type:** `boolean | undefined`
-- **Default:** `true`
-
-Allows you to enable/disable the use of the `marked-alert` extension.
-
-#### `markedFootnote`
-
-- **Type:** `boolean | undefined`
-- **Default:** `true`
-
-Allows you to enable/disable the use of the `marked-footnote` extension.
-
-#### `markedSmartyPants`
-
-- **Type:** `boolean | undefined`
-- **Default:** `true`
-
-Allows you to enable/disable the use of the `marked-smartypants` extension.
-
-#### `markedEmoji`
-
-- **Type:** `boolean | undefined`
-- **Default:** `true`
-
-Allows you to enable/disable the use of the `marked-emoji` extension.
-
-### `highlighterConfig`
-
-- **Type:** `markedHighlighterConfigSchema{} | undefined{}`
-
-This option allows you to choose the highlighter to use for code blocks in your content.
-
-#### `highlighter`
-
-- **Type:** `Enum<'shiki' | 'disabled'> | undefined`
-- **Default:** `'disabled'`
-
-:::note
-For the time being, the only available option is `shiki`.
-:::
-
-#### `shikiConfig`
-
-- **Type:** `shikiConfigSchema{} | undefined{}`
-
-This option allows you to configure the a `shiki` highlighter.
-
-##### `theme`
-
-- **Type:** : `string | undefined`
-- **Default:** `'houston'`
-
-Alows you to choose the theme for the `shiki` highlighter.
-
-The only available themes are the ones listed below:
-
-- `houston`
-- `github-dark`
-- `github-light`
-- `night-owl`
-
-##### `loadThemes`
-
-- **Type:** `string | undefined`
-- **Default:** `undefined`
-
-Allows you to load additional Shiki Themes. This option is only used if you want to load _additional_ Shiki Themes.
-
-For example if you want to load the `material-theme-palenight` theme, you would set the `loadTheme` option to `['material-theme-palenight']`.
-
-```ts
-loadThemes: [
- import("shiki/themes/material-theme-palenight"),
- ...asManyOtherThemesAsYouWant,
-];
-```
-
-##### `loadLang`
-
-- **Type:** `string[] | undefined`
-- **Default:** `undefined`
-
-Allows you to load additional Shiki Languages. This option is only used if you want to load _additional_ Shiki Languages.
-
-For example if you want to load `rust` and `toml` languages, you would set the `loadLang` option to `['rust', 'toml']`.
-
-```ts
-loadLang: [import('shiki/languages/rust'), import('shiki/languages/toml') ...asManyOtherLanguagesAsYouWant]
-```
-
-### `loadMarkedExtensions`
-
-- **Type:** `string[] | undefined`
-- **Default:** `undefined`
-
-Allows you to load additional Marked Extensions. This is only used if the user wants to load _additional_ [Marked Extensions](https://marked.js.org/using_advanced#extensions).
-
-For example if you want to load Admonitions, you would need to install the `npm package`, import it in your config and then declare it.
-
-```ts
-import markedAlert from "marked-alert";
-
-loadMarkedExtensions: [markedAlert()];
-```
diff --git a/packages/studiocms/src/index.ts b/packages/studiocms/src/index.ts
index 59a518235..7caeda89a 100644
--- a/packages/studiocms/src/index.ts
+++ b/packages/studiocms/src/index.ts
@@ -11,12 +11,12 @@ import {
type CustomRenderer,
type Renderer,
type SafePluginListType,
+ type StudioCMSConfig,
type StudioCMSOptions,
type StudioCMSPlugin,
type StudioCMSPluginOptions,
definePlugin,
} from '@studiocms/core/schemas';
-import { robotsTXTPreset } from '@studiocms/core/strings';
import {
// watchStudioCMSConfig,
// configResolver,
@@ -47,6 +47,11 @@ import { name as pkgName, version as pkgVersion } from '../package.json';
export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration {
// Setup the Resolver for the current file
const { resolve } = createResolver(import.meta.url);
+
+ let pluginListLength = 0;
+ let pluginListMessage = '';
+ let options: StudioCMSConfig;
+
return {
name: pkgName,
hooks: {
@@ -60,12 +65,15 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
// Resolve Options
// const options = await configResolver(params, opts);
// Disabled the above due to a vite processing error with dynamic imports
- const options = parseConfig(opts);
+ options = parseConfig(opts);
+
+ const { verbose, rendererConfig, defaultFrontEndConfig, includedIntegrations, plugins } =
+ options;
// Setup Logger
integrationLogger(
- { logger: params.logger, logLevel: 'info', verbose: options.verbose },
- 'Setting up StudioCMS Core...'
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'Setting up StudioCMS...'
);
// Check Astro Config for required settings
@@ -73,34 +81,35 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
// Setup Logger
integrationLogger(
- { logger: params.logger, logLevel: 'info', verbose: options.verbose },
- 'Setting up StudioCMS Integrations and Plugins...'
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'Setting up StudioCMS internals...'
);
- // Setup StudioCMS Integrations
+ // Setup StudioCMS Integrations Array (Default Integrations)
const integrations = [
{ integration: nodeNamespace() },
{ integration: core(options) },
- { integration: renderers(options.rendererConfig) },
- { integration: frontend(options) },
+ { integration: renderers(rendererConfig, verbose) },
{ integration: imageHandler(options) },
{ integration: auth(options) },
{ integration: dashboard(options) },
];
- // Robots.txt
- if (
- options.includedIntegrations?.robotsTXT === true ||
- typeof options.includedIntegrations?.robotsTXT === 'object'
- ) {
- integrations.push({
- integration: robotsTXT({
- ...robotsTXTPreset,
- ...(options.includedIntegrations?.robotsTXT === true
- ? {}
- : options.includedIntegrations?.robotsTXT),
- }),
- });
+ // Frontend Integration (Default)
+ if (defaultFrontEndConfig !== false) {
+ integrations.push({ integration: frontend(options) });
+ }
+
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'Adding optional integrations...'
+ );
+
+ // Robots.txt Integration (Default)
+ if (includedIntegrations.robotsTXT === true) {
+ integrations.push({ integration: robotsTXT() });
+ } else if (typeof includedIntegrations.robotsTXT === 'object') {
+ integrations.push({ integration: robotsTXT(includedIntegrations.robotsTXT) });
}
// Initialize and Add the default StudioCMS Plugin to the Safe Plugin List
@@ -111,6 +120,11 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
},
];
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'Setting up StudioCMS plugins...'
+ );
+
// Resolve StudioCMS Plugins
for (const {
name,
@@ -120,7 +134,7 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
frontendNavigationLinks,
pageTypes,
settingsPage,
- } of options.plugins || []) {
+ } of plugins || []) {
// Check if the identifier is reserved
if (identifier === 'studiocms') {
throw new StudioCMSError(
@@ -166,15 +180,8 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
},
});
- // Log the current plugins
- integrationLogger(
- {
- logger: params.logger.fork('studiocms:plugins'),
- logLevel: 'info',
- verbose: options?.verbose || false,
- },
- `Current Installed Plugins:\n Plugin Label - Plugin Identifier\n${safePluginList.map((p) => ` > ${p.name} - ${p.identifier}`).join('\n')}`
- );
+ pluginListLength = safePluginList.length;
+ pluginListMessage = safePluginList.map((p, i) => ` ${i + 1}. ${p.name}`).join('\n');
},
'astro:config:done': ({ injectTypes }) => {
// Make DTS file for StudioCMS Plugins Virtual Module
@@ -194,6 +201,16 @@ export function studioCMSIntegration(opts?: StudioCMSOptions): AstroIntegration
injectTypes(dtsFile.makeAstroInjectedType('plugins.d.ts'));
},
'astro:server:start': async ({ logger: l }) => {
+ // Log the current plugins
+ integrationLogger(
+ {
+ logger: l.fork('studiocms:plugins'),
+ logLevel: 'info',
+ verbose: options.verbose,
+ },
+ `Currently Installed StudioCMS Plugins: (${pluginListLength})\n${pluginListMessage}`
+ );
+
const logger = l.fork(`${pkgName}:update-check`);
try {
diff --git a/packages/studiocms_core/src/index.ts b/packages/studiocms_core/src/index.ts
index a32e2a3f3..63b267196 100644
--- a/packages/studiocms_core/src/index.ts
+++ b/packages/studiocms_core/src/index.ts
@@ -22,6 +22,11 @@ export function studioCMSCore(options: StudioCMSConfig): AstroIntegration {
name: pkgName,
hooks: {
'astro:config:setup': (params) => {
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose: options.verbose },
+ 'Setting up StudioCMS Core...'
+ );
+
// Create resolvers
const { resolve } = createResolver(import.meta.url);
const { resolve: userSrcDir } = createResolver(params.config.root.pathname);
@@ -106,6 +111,11 @@ export function studioCMSCore(options: StudioCMSConfig): AstroIntegration {
`,
},
});
+
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose: options.verbose },
+ 'Core Setup Complete...'
+ );
},
'astro:config:done': ({ injectTypes }) => {
// Inject the DTS File
diff --git a/packages/studiocms_core/src/schemas/config/auth.ts b/packages/studiocms_core/src/schemas/config/auth.ts
index be1377fee..ae6ede594 100644
--- a/packages/studiocms_core/src/schemas/config/auth.ts
+++ b/packages/studiocms_core/src/schemas/config/auth.ts
@@ -22,9 +22,9 @@ export const authProviderSchema = z
*
* Requires a GitHub OAuth App to be created and configured using ENV Variables
*
- * @default true
+ * @default false
*/
- github: z.boolean().optional().default(true),
+ github: z.boolean().optional().default(false),
/**
* Discord Auth Provider - Powered by Arctic
*
diff --git a/packages/studiocms_core/src/schemas/config/defaultFrontend.ts b/packages/studiocms_core/src/schemas/config/defaultFrontend.ts
index 0e4ce6231..48aa59ed6 100644
--- a/packages/studiocms_core/src/schemas/config/defaultFrontend.ts
+++ b/packages/studiocms_core/src/schemas/config/defaultFrontend.ts
@@ -81,4 +81,4 @@ export const FrontEndConfigSchema = z
export const DefaultFrontEndConfigSchema = z
.union([FrontEndConfigSchema, z.boolean()])
.optional()
- .default(true);
+ .default({});
diff --git a/packages/studiocms_core/src/schemas/config/index.ts b/packages/studiocms_core/src/schemas/config/index.ts
index 74a159f07..973fe02f0 100644
--- a/packages/studiocms_core/src/schemas/config/index.ts
+++ b/packages/studiocms_core/src/schemas/config/index.ts
@@ -1,8 +1,8 @@
import { z } from 'astro/zod';
-import { StudioCMSPluginSchema } from '../plugins';
+import type { StudioCMSPlugin } from '../plugins';
import { overridesSchema } from './componentoverrides';
import { dashboardConfigSchema } from './dashboard';
-import { DefaultFrontEndConfigSchema } from './defaultFrontend';
+import { DefaultFrontEndConfigSchema, FrontEndConfigSchema } from './defaultFrontend';
import { imageServiceSchema } from './imageService';
import { includedIntegrationsSchema } from './integrations';
import {
@@ -17,6 +17,7 @@ import {
//
export {
StudioCMSRendererConfigSchema,
+ FrontEndConfigSchema,
type StudioCMSRendererConfig,
type CustomRenderer,
type Renderer,
@@ -84,7 +85,7 @@ export const StudioCMSOptionsSchema = z
/**
* Add Plugins to the StudioCMS
*/
- plugins: z.array(StudioCMSPluginSchema).optional(),
+ plugins: z.custom().optional(),
})
.optional()
.default({});
diff --git a/packages/studiocms_core/src/schemas/config/integrations.ts b/packages/studiocms_core/src/schemas/config/integrations.ts
index 3973dc9d3..fe845bd5d 100644
--- a/packages/studiocms_core/src/schemas/config/integrations.ts
+++ b/packages/studiocms_core/src/schemas/config/integrations.ts
@@ -1,8 +1,6 @@
import type { RobotsConfig } from '@studiocms/robotstxt';
import { z } from 'astro/zod';
-const RobotsConfigSchema = z.union([z.custom(), z.boolean()]).optional().default({});
-
//
// INTEGRATIONS CONFIG SCHEMA
//
@@ -10,8 +8,10 @@ export const includedIntegrationsSchema = z
.object({
/**
* Allows the user to enable/disable the use of the StudioCMS Custom `astro-robots-txt` Integration
+ *
+ * @default robotsTXT: { policy: [ { userAgent: ['*'], allow: ['/'], disallow: ['/dashboard/'] } ] }
*/
- robotsTXT: RobotsConfigSchema,
+ robotsTXT: z.union([z.custom(), z.boolean()]).optional().default(true),
})
.optional()
.default({});
diff --git a/packages/studiocms_core/src/schemas/config/markdoc.ts b/packages/studiocms_core/src/schemas/config/markdoc.ts
index 221733398..d4ac9160e 100644
--- a/packages/studiocms_core/src/schemas/config/markdoc.ts
+++ b/packages/studiocms_core/src/schemas/config/markdoc.ts
@@ -20,12 +20,16 @@ const RenderableTreeNodesSchema = z.union([
RenderableTreeNodeSchema,
]);
+type CustomMarkDocRendererNodes = z.infer;
+
+export type markdocRenderer = (nodes: CustomMarkDocRendererNodes) => Promise;
+
const MarkdocRendererSchema = z.object({
name: z.string(),
- renderer: z.function().args(RenderableTreeNodesSchema).returns(z.promise(z.string())),
+ renderer: z.custom(),
});
-export type markdocRenderer = typeof MarkdocRendererSchema._input;
+export interface MarkdocRenderer extends z.infer {}
const ParserArgsSchema = z.object({
file: z.string().optional(),
@@ -67,7 +71,7 @@ export const markdocConfigSchema = z
* Can be one of the following: `html`, `react-static`, or a custom renderer
*/
renderType: z
- .union([z.literal('html'), z.literal('react-static'), MarkdocRendererSchema])
+ .union([z.literal('html'), z.literal('react-static'), z.custom()])
.optional()
.default('html'),
/**
diff --git a/packages/studiocms_core/src/schemas/config/rendererConfig.ts b/packages/studiocms_core/src/schemas/config/rendererConfig.ts
index 90f7e09c2..eed8e7ea6 100644
--- a/packages/studiocms_core/src/schemas/config/rendererConfig.ts
+++ b/packages/studiocms_core/src/schemas/config/rendererConfig.ts
@@ -19,10 +19,10 @@ export type { markdocRenderer };
* },
* };
*/
-export type CustomRenderer = {
+export interface CustomRenderer {
name: string;
renderer: Renderer;
-};
+}
/**
* StudioCMS Renderer Configuration Schema
diff --git a/packages/studiocms_core/src/schemas/plugins/index.ts b/packages/studiocms_core/src/schemas/plugins/index.ts
index 47802a89e..5b86a0344 100644
--- a/packages/studiocms_core/src/schemas/plugins/index.ts
+++ b/packages/studiocms_core/src/schemas/plugins/index.ts
@@ -185,7 +185,7 @@ export const SafePluginListSchema = z.array(SafePluginListItemSchema);
export type StudioCMSPluginOptions = z.infer;
export type SafePluginListItemType = z.infer;
export type SafePluginListType = z.infer;
-export type StudioCMSPlugin = StudioCMSPluginOptions;
+export interface StudioCMSPlugin extends StudioCMSPluginOptions {}
/**
* Defines a plugin for StudioCMS.
diff --git a/packages/studiocms_core/src/strings.ts b/packages/studiocms_core/src/strings.ts
index 2c333155e..4da394898 100644
--- a/packages/studiocms_core/src/strings.ts
+++ b/packages/studiocms_core/src/strings.ts
@@ -1,5 +1,3 @@
-import type { RobotsConfig } from '@studiocms/robotstxt';
-
export const CoreStrings = {
Start: 'Setting up StudioCMS Core...',
AddVirtualImports: 'Adding Virtual Imports...',
@@ -51,26 +49,6 @@ export const DashboardStrings = {
SetupComplete: 'StudioCMS Dashboard is Setup and Ready to Go!',
};
-export const MakeFrontendStrings = {
- NoDBStartPage:
- 'Database Start Page disabled, skipping Database Setup and injecting Default Frontend Routes...',
- InjectDefaultFrontendRoutes: 'Injecting Default Frontend Routes...',
- Inject404Route: 'Injecting 404 Route...',
- DefaultRoutesInjected: 'StudioCMS Default Routes Injected!',
- DBStartPageEnabled:
- 'Database Start Page enabled, skipping Default Frontend Routes Injection... Please follow the Database Setup Guide to create your Frontend.',
-};
-
-export const robotsTXTPreset: Partial = {
- policy: [
- {
- userAgent: ['*'],
- allow: ['/'],
- disallow: ['/dashboard/'],
- },
- ],
-};
-
export const imageHandlerStrings = {
CloudinaryCDNWarning:
'Using the Cloudinary CDN JS SDK Plugin requires the CMS_CLOUDINARY_CLOUDNAME environment variable to be set. Please add this to your .env file.',
diff --git a/packages/studiocms_frontend/src/index.ts b/packages/studiocms_frontend/src/index.ts
index 9a0ae4890..c6cf546c3 100644
--- a/packages/studiocms_frontend/src/index.ts
+++ b/packages/studiocms_frontend/src/index.ts
@@ -1,8 +1,69 @@
-import integration from './integration';
+import { integrationLogger } from '@matthiesenxyz/integration-utils/astroUtils';
+import type { AstroIntegration } from 'astro';
+import { createResolver } from 'astro-integration-kit';
+import { name } from '../package.json';
+import type { StudioCMSFrontEndOptions } from './schema';
/**
* StudioCMS Frontend Integration
*/
-const studioCMSFrontend = integration;
+function studioCMSFrontend(opts: StudioCMSFrontEndOptions): AstroIntegration {
+ // Create resolver relative to this file
+ const { resolve } = createResolver(import.meta.url);
+
+ // Destructure Options
+ const { verbose, dbStartPage, defaultFrontEndConfig } = opts;
+ const logLevel = 'info';
+
+ let shouldInject = false;
+
+ if (typeof defaultFrontEndConfig === 'boolean') {
+ shouldInject = defaultFrontEndConfig;
+ } else if (typeof defaultFrontEndConfig === 'object') {
+ shouldInject = defaultFrontEndConfig.injectDefaultFrontEndRoutes;
+ }
+
+ return {
+ name,
+ hooks: {
+ 'astro:config:setup': ({ injectRoute, logger }) => {
+ integrationLogger({ logger, logLevel, verbose }, 'Setting up Frontend...');
+
+ if (dbStartPage) {
+ integrationLogger(
+ { logger, logLevel, verbose },
+ 'Database Start Page enabled, skipping Default Frontend Routes Injection... Please follow the Database Setup Guide to create your Frontend.'
+ );
+ } else {
+ integrationLogger(
+ { logger, logLevel, verbose },
+ 'Database Start Page disabled, checking for Default Frontend Routes Injection...'
+ );
+
+ if (shouldInject) {
+ integrationLogger(
+ { logger, logLevel, verbose },
+ 'Route Injection enabled, Injecting Default Frontend Routes...'
+ );
+
+ injectRoute({
+ pattern: '/',
+ entrypoint: resolve('./routes/index.astro'),
+ prerender: false,
+ });
+
+ injectRoute({
+ pattern: '[...slug]',
+ entrypoint: resolve('./routes/[...slug].astro'),
+ prerender: false,
+ });
+
+ integrationLogger({ logger, logLevel, verbose }, 'Frontend Routes Injected!');
+ }
+ }
+ },
+ },
+ };
+}
export default studioCMSFrontend;
diff --git a/packages/studiocms_frontend/src/integration.ts b/packages/studiocms_frontend/src/integration.ts
deleted file mode 100644
index a73b815b0..000000000
--- a/packages/studiocms_frontend/src/integration.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { createResolver, defineIntegration } from 'astro-integration-kit';
-import { name } from '../package.json';
-import { StudioCMSFrontEndOptionsSchema } from './schema';
-import { makeFrontend } from './utils/makeFrontend';
-
-/**
- * StudioCMS Frontend Integration
- */
-export default defineIntegration({
- name,
- optionsSchema: StudioCMSFrontEndOptionsSchema,
- setup({ options }) {
- // Create resolver relative to this file
- const { resolve } = createResolver(import.meta.url);
-
- return {
- hooks: {
- 'astro:config:setup': (params) => {
- // Create the default frontend Routes
- makeFrontend(params, {
- options,
- routes: [
- { pattern: '/', entrypoint: resolve('./routes/index.astro') },
- { pattern: '[...slug]', entrypoint: resolve('./routes/[...slug].astro') },
- ],
- });
- },
- },
- };
- },
-});
diff --git a/packages/studiocms_frontend/src/utils/makeFrontend.ts b/packages/studiocms_frontend/src/utils/makeFrontend.ts
deleted file mode 100644
index d23342e5e..000000000
--- a/packages/studiocms_frontend/src/utils/makeFrontend.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { integrationLogger } from '@matthiesenxyz/integration-utils/astroUtils';
-import { MakeFrontendStrings } from '@studiocms/core/strings';
-import { defineUtility } from 'astro-integration-kit';
-import type { StudioCMSFrontEndOptions } from '../schema';
-
-export const makeFrontend = defineUtility('astro:config:setup')(
- (
- params,
- options: {
- options: StudioCMSFrontEndOptions;
- routes: {
- pattern: string;
- entrypoint: string;
- }[];
- }
- ) => {
- // Destructure Params
- const { injectRoute, logger } = params;
-
- // Destructure Options
- const {
- routes,
- // default404Route,
- options: { dbStartPage, verbose, defaultFrontEndConfig: config },
- } = options;
-
- let injectDefaultFrontEndRoutes = false;
-
- switch (typeof config) {
- case 'boolean':
- if (config === false) {
- return;
- }
-
- if (config === true) {
- injectDefaultFrontEndRoutes = true;
- }
- break;
- case 'object':
- injectDefaultFrontEndRoutes = config.injectDefaultFrontEndRoutes;
- break;
- }
-
- // Check if DB Start Page is enabled
- if (dbStartPage) {
- integrationLogger(
- { logger, logLevel: 'info', verbose },
- MakeFrontendStrings.DBStartPageEnabled
- );
- return;
- }
-
- integrationLogger({ logger, logLevel: 'info', verbose }, MakeFrontendStrings.NoDBStartPage);
-
- // Inject Default Frontend Routes if Enabled
- if (injectDefaultFrontEndRoutes) {
- integrationLogger(
- { logger, logLevel: 'info', verbose },
- MakeFrontendStrings.InjectDefaultFrontendRoutes
- );
- for (const route of routes) {
- injectRoute({
- pattern: route.pattern,
- entrypoint: route.entrypoint,
- });
- }
- integrationLogger(
- { logger, logLevel: 'info', verbose },
- MakeFrontendStrings.DefaultRoutesInjected
- );
- }
- }
-);
diff --git a/packages/studiocms_renderers/src/index.ts b/packages/studiocms_renderers/src/index.ts
index 267e5e725..6649321e4 100644
--- a/packages/studiocms_renderers/src/index.ts
+++ b/packages/studiocms_renderers/src/index.ts
@@ -1,4 +1,5 @@
import { runtimeLogger } from '@inox-tools/runtime-logger';
+import { integrationLogger } from '@matthiesenxyz/integration-utils/astroUtils';
import { stringify } from '@studiocms/core/lib';
import type { StudioCMSRendererConfig } from '@studiocms/core/schemas/renderer';
import type { AstroIntegration } from 'astro';
@@ -16,7 +17,10 @@ import { rendererAstroMarkdownDTS } from './stubs/renderer-markdownConfig';
*
* @see [StudioCMS Docs](https://docs.studiocms.dev) for more information on how to use StudioCMS.
*/
-export function studioCMSRenderers(options: StudioCMSRendererConfig): AstroIntegration {
+export function studioCMSRenderers(
+ options: StudioCMSRendererConfig,
+ verbose: boolean
+): AstroIntegration {
// Create resolver relative to this file
const { resolve } = createResolver(import.meta.url);
@@ -26,6 +30,10 @@ export function studioCMSRenderers(options: StudioCMSRendererConfig): AstroInteg
name: pkgName,
hooks: {
'astro:config:setup': (params) => {
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'Setting up StudioCMS Renderer...'
+ );
// Setup the runtime logger
runtimeLogger(params, { name: 'studiocms-renderer' });
@@ -38,6 +46,10 @@ export function studioCMSRenderers(options: StudioCMSRendererConfig): AstroInteg
'studiocms:renderer/astroMarkdownConfig': `export default ${stringify(params.config.markdown)}`,
},
});
+ integrationLogger(
+ { logger: params.logger, logLevel: 'info', verbose },
+ 'StudioCMS Renderer Virtual Imports Added...'
+ );
},
'astro:config:done': ({ injectTypes }) => {
// Inject Types for Renderer
diff --git a/packages/studiocms_robotstxt/src/consts.ts b/packages/studiocms_robotstxt/src/consts.ts
index b3d5aaee0..bb2392212 100644
--- a/packages/studiocms_robotstxt/src/consts.ts
+++ b/packages/studiocms_robotstxt/src/consts.ts
@@ -126,7 +126,7 @@ export type SearchEngineOptimization = {
PrerenderLLC: 'prerender';
};
-export type UsertAgentType =
+export type UserAgentType =
| '*'
| SearchEngines[keyof SearchEngines]
| SocialNetwork[keyof SocialNetwork]
diff --git a/packages/studiocms_robotstxt/src/core.ts b/packages/studiocms_robotstxt/src/core.ts
index 36b711d89..5c5f24b7c 100644
--- a/packages/studiocms_robotstxt/src/core.ts
+++ b/packages/studiocms_robotstxt/src/core.ts
@@ -158,7 +158,7 @@ export function generateContent(
? policy.userAgent
: [policy.userAgent || '*'];
for (const userAgent of userAgents) {
- // skiped
+ // skipped
if (userAgent) {
content += `User-agent: ${userAgent}\n`;
}
diff --git a/packages/studiocms_robotstxt/src/index.ts b/packages/studiocms_robotstxt/src/index.ts
index efa3a8321..d1b8bf2b4 100644
--- a/packages/studiocms_robotstxt/src/index.ts
+++ b/packages/studiocms_robotstxt/src/index.ts
@@ -1,6 +1,6 @@
import type { AstroConfig, AstroIntegration } from 'astro';
import { name } from '../package.json';
-import type { UsertAgentType } from './consts';
+import type { UserAgentType } from './consts';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
@@ -79,7 +79,7 @@ export interface PolicyOptions {
* ```
* Verified bots, refer to [DITIG](https://www.ditig.com/robots-txt-template#regular-template) or [Cloudflare Radar](https://radar.cloudflare.com/traffic/verified-bots).
*/
- userAgent?: UsertAgentType | UsertAgentType[];
+ userAgent?: UserAgentType | UserAgentType[];
/**
* @description
* [ At least one or more `allow` or `disallow` entries per rule ] Allows indexing site sections or individual pages.
@@ -148,8 +148,9 @@ const defaultConfig: RobotsConfig = {
host: false,
policy: [
{
- userAgent: '*',
- allow: '/',
+ userAgent: ['*'],
+ allow: ['/'],
+ disallow: ['/dashboard/'],
},
],
};
@@ -162,27 +163,27 @@ const defaultConfig: RobotsConfig = {
* @param astroConfig Robots Configuration
* @returns AstroIntegration
*/
-export default function createRobotsIntegration(astroConfig: RobotsConfig): AstroIntegration {
- let config: AstroConfig;
+export default function createRobotsIntegration(options?: RobotsConfig): AstroIntegration {
+ let astroConfig: AstroConfig;
let finalSiteMapHref: string;
let executionTime: number;
- const mergedConfig = { ...defaultConfig, ...astroConfig };
+ const config = { ...defaultConfig, ...options };
return {
name,
hooks: {
'astro:config:setup': ({ config: cfg }) => {
- config = cfg;
+ astroConfig = cfg;
},
'astro:build:start': () => {
- finalSiteMapHref = new URL(config.base, config.site).href;
+ finalSiteMapHref = new URL(astroConfig.base, astroConfig.site).href;
},
'astro:build:done': async ({ dir, logger }) => {
executionTime = measureExecutionTime(() => {
fs.writeFileSync(
new URL('robots.txt', dir),
- generateContent(mergedConfig, finalSiteMapHref, logger),
+ generateContent(config, finalSiteMapHref, logger),
'utf-8'
);
});
diff --git a/playground/astro.config.mts b/playground/astro.config.mts
index c438a96a3..16ee1a4dd 100644
--- a/playground/astro.config.mts
+++ b/playground/astro.config.mts
@@ -33,13 +33,6 @@ export default defineConfig({
// },
// ],
},
- dashboardConfig: {
- AuthConfig: {
- providers: {
- github: true,
- },
- },
- },
}),
// sentry({
// dsn: 'https://71c3c874d5d8ad20486529628ac13aae@sentry.studiocms.dev/4',