Svemix includes some default meta data / SEO handling, the cool thing is. All you have to do is export a loader function and return a metadata
property inside your loader. You can also specify default meta tags via the svelte config.
Each .svelte file inside your routes folder can export a loader function, this loader can return an object with the metadata property, which svemix makes automatically use of.
<script context="module" lang="ts" ssr>
import type { Loader } from 'svemix';
export const loader: Loader = async function (event) {
return {
metadata: {
title: 'About our company',
description: "I'm a about description"
// More
}
};
};
</script>
You can specify your default meta/seo config inside svelte.config.js
ts
importsvemix from 'svemix/plugin';/** @type {import('svemix').SvemixConfig} */constconfig = {//...svemix : {seo : {title : '',description : '',keywords : '',openGraph : {title : '',description : ''// etc.},site : '',title : ''}// etc.}},};export defaultconfig ;
ts
export interfaceMetaResult {title ?: string;description ?: string;keywords ?: string;canonical ?: string;openGraph ?:OpenGraph ;}export interfaceOpenGraph {title ?: string;description ?: string;url ?: string;type ?: string;article ?:OpenGraphArticle ;images ?:OpenGraphImage [];}export interfaceOpenGraphArticle {publishedTime ?: string;modifiedTime ?: string;expirationTime ?: string;section ?: string;authors ?: string[];tags ?: string[];}export interfaceOpenGraphImage {url : string;alt ?: string;width ?: number | string;height ?: number | string;}export interfacesite ?: string;title ?: string;description ?: string;image ?: string;imageAlt ?: string;}