master
  1// @ts-check
  2import { buildConfig, siteConfig } from './src/config.ts';
  3import { CDN } from './src/constants/cdn.ts';
  4import { pluginLanguageBadge } from './src/plugins/expressive-code-lang-badget.ts';
  5import { rehypeComponentsAsync } from './src/plugins/rehype-components-async.ts';
  6import { rehypeComponentsList } from './src/plugins/rehype-components-list.ts';
  7import { rehypeWrapTables } from './src/plugins/rehype-wrap-tables.ts';
  8import { remarkArticleReferences } from './src/plugins/remark-article-references';
  9import { remarkCreateTime } from './src/plugins/remark-create-time.ts';
 10import { remarkExcerpt } from './src/plugins/remark-excerpt.ts';
 11// import { remarkHeadingShift } from './src/plugins/remark-heading-shift.ts';
 12import { remarkImageProcess } from './src/plugins/remark-image-process.ts';
 13import { remarkObsidianCallout } from './src/plugins/remark-obsidian-callout.ts';
 14import { remarkReadingTime } from './src/plugins/remark-reading-time.ts';
 15import { rehypeHeadingIds } from '@astrojs/markdown-remark';
 16import mdx from '@astrojs/mdx';
 17import sitemap from '@astrojs/sitemap';
 18import solidJs from '@astrojs/solid-js';
 19import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers';
 20import tailwindcss from '@tailwindcss/vite';
 21import AstroPWA from '@vite-pwa/astro';
 22import expressiveCode from 'astro-expressive-code';
 23import icon from 'astro-icon';
 24import pagefind from 'astro-pagefind';
 25import { defineConfig } from 'astro/config';
 26import rehypeAutolinkHeadings from 'rehype-autolink-headings';
 27import rehypeMathJaxCHtml from 'rehype-mathjax/chtml';
 28import remarkDirective from 'remark-directive';
 29import remarkDirectiveRehype from 'remark-directive-rehype';
 30import remarkMath from 'remark-math';
 31import Icons from 'unplugin-icons/vite';
 32
 33// https://astro.build/config
 34export default defineConfig({
 35  site: 'https://astral-halo.netlify.app/',
 36  base: '/',
 37  output: 'static',
 38  trailingSlash: 'ignore',
 39  integrations: [
 40    icon(),
 41    sitemap({ filter: (page) => !page.includes('/archives/') && !page.includes('/about/') }),
 42    pagefind(),
 43    AstroPWA({
 44      manifest: {
 45        name: siteConfig.title,
 46        short_name: siteConfig.title,
 47        description: siteConfig.subtitle,
 48        lang: siteConfig.lang,
 49        theme_color: '#4f94c9', // Should be the same as the primary color in src/styles/global.css
 50        background_color: '#f2e8e0', // Should be the same as the base-100 color in src/styles/global.css
 51      },
 52      pwaAssets: {
 53        config: true,
 54      },
 55      workbox: {
 56        navigateFallback: '/',
 57        globPatterns: ['**/*.{css,js,html,svg,png,ico,txt}'],
 58      },
 59      devOptions: {
 60        enabled: false,
 61        navigateFallbackAllowlist: [/^\/$/],
 62      },
 63    }),
 64    expressiveCode({
 65      themeCssSelector: (theme) => `[data-theme="${buildConfig.themeNames[theme.type]}"]`,
 66      plugins: [pluginLineNumbers(), pluginLanguageBadge()],
 67      shiki: {
 68        langAlias: {
 69          pip: 'ini',
 70        },
 71      },
 72    }),
 73    mdx(),
 74    solidJs({ devtools: true }),
 75  ],
 76  markdown: {
 77    remarkPlugins: [
 78      // remarkHeadingShift,
 79      remarkMath,
 80      remarkDirective,
 81      // @ts-expect-error Types of the plugin are not correct
 82      remarkDirectiveRehype,
 83      remarkCreateTime,
 84      remarkReadingTime,
 85      remarkExcerpt,
 86      remarkImageProcess,
 87      remarkObsidianCallout,
 88      remarkArticleReferences,
 89    ],
 90    rehypePlugins: [
 91      rehypeHeadingIds,
 92      [
 93        rehypeAutolinkHeadings,
 94        {
 95          behavior: 'append',
 96          content: {
 97            type: 'text',
 98            value: '#',
 99          },
100          properties: {
101            'aria-label': 'Anchor link',
102          },
103        },
104      ],
105      [
106        rehypeMathJaxCHtml,
107        {
108          chtml: {
109            fontURL: CDN.mathjaxFont,
110          },
111        },
112      ],
113      rehypeWrapTables,
114  [rehypeComponentsAsync, { components: rehypeComponentsList }],
115    ],
116  },
117  vite: {
118    plugins: [tailwindcss(), Icons({ compiler: 'solid' })],
119    build: {
120      rollupOptions: {
121        external: ['workbox-window'],
122      },
123    },
124  },
125});