its-personal/mdsvex.config.js

74 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-11-08 22:56:48 +00:00
import { defineMDSveXConfig as defineConfig } from 'mdsvex';
import remarkExternalLinks from 'remark-external-links';
import remarkSetImagePath from './src/lib/utils/remark-set-image-path.js';
import remarkLinkWithImageAsOnlyChild from './src/lib/utils/remark-link-with-image-as-only-child.js';
import rehypeImgSize from 'rehype-img-size';
2024-02-13 15:42:36 +00:00
import remarkUnwrapImages from 'remark-unwrap-images';
2023-11-08 22:56:48 +00:00
import remarkToc from 'remark-toc';
2024-02-13 15:42:36 +00:00
import rehypeSlug from 'rehype-slug';
2023-11-08 22:56:48 +00:00
// import { highlightCode } from './src/lib/utils/highlighter.js';
/** @type {import('mdsvex').MdsvexOptions} */
const config = defineConfig({
extensions: ['.svelte.md', '.md', '.svx'],
smartypants: {
dashes: 'oldschool'
},
2024-02-13 15:42:36 +00:00
/* Wait for skeleton to implement Prismjs, for now use <CodeBlock /> in .md files */
2023-11-08 22:56:48 +00:00
// layout: {
// blog: './src/lib/components/blog/_blog-layout.svelte',
// project: './src/lib/components/projects/_project-layout.svelte',
// _: './src/lib/components/fallback/_layout.svelte'
// },
2024-02-13 15:42:36 +00:00
/* Plugins */
2023-11-08 22:56:48 +00:00
rehypePlugins: [
2024-03-16 09:12:50 +00:00
[rehypeSlug],
[rehypeImgSize]
2024-02-13 15:42:36 +00:00
// [
// /** Custom rehype plugin to add loading="lazy" to all images */
// () => {
// return (tree) => {
// visit(tree, 'element', (node) => {
// if (node.tagName === 'img') {
// node.properties.loading = 'lazy';
// }
// });
// };
// }
// ]
2023-11-08 22:56:48 +00:00
],
remarkPlugins: [
2024-02-13 15:42:36 +00:00
[remarkToc, { maxDepth: 3, tight: true }],
[
2023-11-08 22:56:48 +00:00
(remarkExternalLinks,
{
target: '_blank'
})
],
2024-03-16 09:12:50 +00:00
[remarkUnwrapImages],
remarkSetImagePath,
remarkLinkWithImageAsOnlyChild
2024-02-13 15:42:36 +00:00
// [
// headings,
// {
// behavior: 'append',
// linkProperties: {},
// content: function (node) {
// return [
// h('span.icon.icon-link header-anchor', {
// ariaLabel: toString(node) + ' permalink'
// })
// ];
// }
// }
// ],
2024-03-16 09:12:50 +00:00
2024-02-13 15:42:36 +00:00
// remarkHeadingsPermaLinks,
// getHeadings
2023-11-08 22:56:48 +00:00
]
});
export default config;