diff --git a/.changeset/wicked-bikes-raise.md b/.changeset/wicked-bikes-raise.md new file mode 100644 index 0000000..4cafc0a --- /dev/null +++ b/.changeset/wicked-bikes-raise.md @@ -0,0 +1,27 @@ +--- +"@studiocms/markdown-remark": minor +--- + +Introduce custom User-Defined component handling. + +This update includes significant enhancements to the Markdown Remark processor Astro Integration, allowing for more flexible and powerful Markdown rendering with custom components. + +### New Features: + +- Added custom components support in the Markdown Remark processor Astro Integration. +- Introduced utility functions in `utils.ts` for component proxy creation, indentation handling, dedenting strings, and merging records. +- Moved zod schema to separate `schema.ts` file. + +### Integration Updates: + +- Enhanced Astro integration to support custom components configuration via `astro.config.mjs`. +- Updated `markdown.ts` to include custom components during Markdown rendering. +- Extended `index.ts` to utilize the new schema and utilities. + +### Documentation: + +- Updated `README.md` with instructions for setting up custom components in Astro integration. + +### Dependencies: + +- Added `entities` and `ultrahtml` as new dependencies. \ No newline at end of file diff --git a/packages/markdown-remark/README.md b/packages/markdown-remark/README.md index 4005c10..04108cb 100644 --- a/packages/markdown-remark/README.md +++ b/packages/markdown-remark/README.md @@ -29,6 +29,8 @@ pnpm add @studiocms/markdown-remark ### As an Astro Integration +With the Astro integration enabled, you can either pass in custom components into your astro config, or manually for the specific render your trying to do shown in the following methods. + #### Setup the integration **`astro.config.mjs`** @@ -44,7 +46,24 @@ export default defineConfig({ * https://docs.astro.build/en/reference/configuration-reference/#markdown-options */ }, - integrations: [markdownRemark()], + integrations: [markdownRemark({ + // Used for injecting CSS for Headings and Callouts + injectCSS: true, + // User defined components that will be used when processing markdown + components: { + // Example of a custom defined component + custom: "./src/components/Custom.astro", + }, + // Custom Markdown config + markdown: { + // Configure the available callout themes + callouts: { + theme: 'obsidian' // Can also be 'github' or 'vitepress' + }, + autoLinkHeadings: true, + sanitize: {} // see https://github.com/natemoo-re/ultrahtml?tab=readme-ov-file#sanitization for full options + } + })], }); ``` @@ -55,6 +74,7 @@ export default defineConfig({ ```astro --- import { Markdown } from 'studiocms:markdown-remark'; +import Custom from '../components/Custom.astro'; ---
@@ -63,7 +83,7 @@ import { Markdown } from 'studiocms:markdown-remark';Some content shown after opening!
This is a custom component
This is a custom component
+