has an extensible module system, which is used internally to provide
features such as frontmatter
and meta
information for pages.
Use the modules option in iles.config.ts
to add modules to your application.
import { defineConfig } from 'iles'
import icons from '@islands/icons'
export default defineConfig({
modules: [
// Automatically imported and instantiated
'@islands/headings',
// Use an array to pass options
['@islands/prism', { showLineNumbers: true }] ,
// Manually imported, provides better type-inference
icons({ autoInstall: false }),
// A one-off module that won't be published
{
name: 'custom-module',
configResolved (config) {
console.log({ config })
},
},
],
})
When providing a string, will automatically add the specified module to the development dependencies. Otherwise, add the package manually and run install.
Modules in have access to the same configuration options as in
iles.config.ts
, and can make use of the config
and configResolved
hooks
that work similarly to those in Vite.
You can start your own module package by running:
pnpm create iles-module@next # or npm or yarn
Module packages should be "type": "module"
and have a default ESM export,
which is used to instantiate the module when the user provides it as a string.
No Need for PackagesIf you don't intend to publish it you can always import a local file or provide it inline instead.
A module to extract an excerpt from MDX documents:
🏷 can render HTML by using the excerpt
prop in an MDX component
⚙️ maxLength
, separator
, and extract
options to customize excerpt
import { defineConfig } from 'iles'
export default defineConfig({
modules: [
['@islands/excerpt', { maxLength: 140 }],
],
})
Use meta to access a plain-text version of the excerpt for the current page:
const { meta } = usePage()
const text = meta.excerpt
When importing MDX components, you use the excerpt
prop to render HTML:
<script setup>
import Introduction from '~/pages/intro.mdx'
const pages = useDocuments('~/pages/posts')
</script>
<template>
<Introduction excerpt/>
<template v-for="page in pages">
<component :is="page" excerpt/>
</template>
</template>
A module that injects a rehype plugin to parse headings in MDX documents:
🔗 adds an id to headings and injects an anchor tag to link them
🏷 automatically extracts the title from an <h1>
and sets frontmatter.title
📖 sets meta.headings
to enable rendering sidebars and table of contents
import { defineConfig } from 'iles'
export default defineConfig({
modules: [
'@islands/headings',
],
})
A module to add and configure unplugin-icons:
✨ autoInstall
enabled by default, and icon
prefix to prevent conflicts
🧱 configures the unplugin-vue-components
resolver automatically
🎨 files in the /icons
dir available as the app
collection, <IconApp...
modules: [
'@islands/icons',
],
A module that configures vite-plugin-image-presets
, allowing you to easily define presets to optimize and convert images:
🖼 define presets once, apply everywhere
🔗 use presets directly in img
, source
, and in markdown!
🖥 customize formats, srcset, & sizes
⚡️ on-demand in dev, cached at build time 📦
Check the readme for more information, or see it in action.
A module to generate RSS and Atom feeds, powered by feed:
📻 supports RSS, Atom, and JSON formats
💪🏼 strongly typed
⚡️ HMR during development to debug the result
modules: [
'@islands/feed',
],
A module that injects a remark plugin to highlight code blocks in MDX documents:
💎 uses prismjs supporting a wide variety of programming languages
🔦 highlight specific lines ({3}
, {7-13}
, or {16,23-27,40}
)
🔢 display line numbers (showLineNumbers
)
🚀 faster than @mapbox/rehype-prism
, remark-prism
and rehype-prism-plus
Check the readme for more information.
modules: [
'@islands/prism'
],
A module to add and configure vite-plugin-pwa to make your website work offline, created by @userquin.
import { defineConfig } from 'iles'
import pwa from '@islands/pwa'
export default defineConfig({
modules: [
pwa(options),
],
})
See the PWA guide for more information.
Shipped inside to provide MDX support.
meta
markdown: {
remarkPlugins: [
'remark-gemoji',
],
},
Shipped inside to provide support for pages.
<page>
block in Vue single-file components extendFrontmatter (frontmatter, filename) {
if (filename.includes('/posts/'))
frontmatter.layout = 'post'
},
extendRoute (route) {
if (route.path.startsWith('/posts'))
route.path = path.replace(/[\d-]+/, '') // remove date
},
extendRoutes (routes) {
routes.push({ path: '/custom', name: 'Custom', componentFilename: ... }))
},
Customizing FrontmatterextendFrontmatter is very flexible, you could use it to:
- Infer the title or date from the filename
- Set a different layout for all pages in a specific dir
- Provide additional data to use in the page, such as
gitLastUpdated
You can use any Vite.js plugins by configuring them as usual, but note that the following plugins are already included and pre-configured for you.
The examples list some of the defaults for each plugin.
You can provide additional options for each of them using
iles.config.ts
.
Provides support for Single File Components with Vue 3.
import { defineConfig } from 'iles'
export default defineConfig({
vue: {
reactivityTransform: true,
},
})
Enables auto-importing Vue components, and is leveraged internally to support automatic component resolution in MDX files.
// Example config from "The Vue Point in îles"
components: {
resolvers: [iconsResolver({ componentPrefix: '' })],
},
Provides support for SolidJS islands.
Auto-installed when configuring jsx: 'solid'
, solid: true
, or providing
plugin options for solid
in iles.config.ts
.
Provides support for Preact islands.
Auto-installed when configuring jsx: 'preact'
, preact: true
, or providing
plugin options for preact
in iles.config.ts
.
Provides support for Svelte islands.
Auto-installed when configuring svelte: true
, or providing
plugin options for svelte
in iles.config.ts
.