Skip to content

Commit f4a4fdf

Browse files
authored
Merge pull request #382 from opensourcepledge/vladh/add-horizontalrule
Sanity: add HorizontalRule
2 parents 9a6ef2f + c7ac470 commit f4a4fdf

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

sanity.config.ts

+23
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ export default defineConfig({
224224
validation: (rule) => rule.required(),
225225
},
226226
],
227+
},
228+
{
229+
type: 'object',
230+
title: 'Horizontal Rule',
231+
name: 'horizontalRule',
232+
description: 'Horizontal rule',
233+
fields: [
234+
// NOTE: We don't generally need a field for this component.
235+
// However, there are two reasons to actually have a field.
236+
// (1) All Sanity schema types seem to require fields. (2) It
237+
// is useful to have a field called “title” which shows this
238+
// component's title in the article preview. So we create a
239+
// dummy “title” field that always has the same title.
240+
{
241+
type: 'string',
242+
name: 'title',
243+
title: 'Horizontal rule dummy title',
244+
hidden: true,
245+
},
246+
],
247+
initialValue: {
248+
title: 'Horizontal rule',
249+
},
227250
}
228251
],
229252
validation: (rule) => rule.required(),

src/pages/blog/[slug].astro

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Block from '../../portableTextComponents/Block.astro';
1717
import CaptionedImage from '../../portableTextComponents/CaptionedImage.astro';
1818
import YoutubeEmbed from '../../portableTextComponents/YoutubeEmbed.astro';
1919
import VideoEmbed from '../../portableTextComponents/VideoEmbed.astro';
20+
import HorizontalRule from '../../portableTextComponents/HorizontalRule.astro';
2021
2122
const ARTICLE_QUERY = `*[_type == "article" && slug.current == $slug][0]{
2223
_id,
@@ -48,6 +49,7 @@ const components = {
4849
captionedImage: CaptionedImage,
4950
youtubeEmbed: YoutubeEmbed,
5051
videoEmbed: VideoEmbed,
52+
horizontalRule: HorizontalRule,
5153
},
5254
block: Block,
5355
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
// © 2025 Functional Software, Inc. dba Sentry
3+
// SPDX-License-Identifier: Apache-2.0
4+
---
5+
6+
<hr>

0 commit comments

Comments
 (0)