-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): allow custom ogImage templates
Signed-off-by: ZTL-UwU <[email protected]>
- Loading branch information
Showing
10 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
title: OG Image | ||
description: Customizing the dynamic OG Image. | ||
icon: lucide:image | ||
--- | ||
|
||
**shadcn-docs-nuxt** utilizes the [nuxt-og-image](https://nuxtseo.com/og-image/getting-started/installation) module to generate dynamic OG Images. | ||
|
||
The dynamic OG Image is used in all pages **except** the index page. The index page uses a static OG Image defined in the [`ogImage`](/api/configuration/shadcn-docs#site) field instead. | ||
|
||
## Using Built-in Templates | ||
|
||
To use a template, set the name of the OG Image component in the [`ogImageComponent`](/api/configuration/shadcn-docs#site). | ||
|
||
```ts [app.config.ts] | ||
export default defineAppConfig({ | ||
shadcnDocs: { | ||
site: { | ||
ogImageComponent: 'ShadcnDocs', | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
Out of the box, a shadcn-docs-nuxt template and multiple community templates are available. | ||
|
||
| Component Name | Preview | | ||
| :------------: | :--------------------------------------------------: | | ||
| `ShadcnDocs` | ![Shadcn Docs OG Image Preview](/og-shadcn-docs.png) | | ||
| `Nuxt` | ![Shadcn Docs OG Image Preview](/og-nuxt.png) | | ||
| `Nuxt SEO` | ![Shadcn Docs OG Image Preview](/og-nuxt-seo.png) | | ||
|
||
::alert{to="https://github.com/nuxt-modules/og-image/tree/main/src/runtime/nuxt/components/Templates/Community" icon="lucide:list"} | ||
See the full list of community templates. | ||
:: | ||
|
||
## Using Custom Templates | ||
|
||
To use a custom template, create a template by following the guide in the [Nuxt SEO Docs](https://nuxtseo.com/og-image/getting-started/getting-familar-with-nuxt-og-image#_1-create-your-template-component). Then set the component name of your template in `ogImageComponent`. | ||
|
||
::code-group | ||
```vue [components/OgImage/BlogPost.vue] | ||
<template> | ||
<div class="flex size-full items-start justify-start border-[12px] border-solid border-blue-500 bg-gray-50"> | ||
<div class="flex h-full items-start justify-start"> | ||
<div class="flex size-full flex-col justify-between"> | ||
<h1 class="p-20 text-left text-[80px] font-black"> | ||
{{ title }} | ||
</h1> | ||
<p class="mb-0 px-20 pb-10 text-2xl font-bold"> | ||
mycoolsite.com | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
withDefaults(defineProps<{ | ||
title?: string; | ||
}>(), { | ||
title: 'title', | ||
}); | ||
</script> | ||
``` | ||
|
||
```ts [app.config.ts] | ||
export default defineAppConfig({ | ||
shadcnDocs: { | ||
site: { | ||
ogImageComponent: 'BlogPost', | ||
}, | ||
}, | ||
}); | ||
``` | ||
:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters