Skip to content

Commit 9ee325c

Browse files
committed
feat(md): expo
1 parent 22e1981 commit 9ee325c

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/md/rules.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,23 @@ test.each([
193193
)
194194
})
195195

196+
test.each([
197+
[
198+
'https://docs.expo.dev/get-started/start-developing/',
199+
'https://docs.expo.dev/get-started/start-developing.md',
200+
],
201+
[
202+
'https://expo.dev/blog/expo-go-vs-development-builds',
203+
'https://expo.dev/blog/expo-go-vs-development-builds.md',
204+
],
205+
[
206+
'https://expo.dev/blog/expo-go-vs-development-builds/',
207+
'https://expo.dev/blog/expo-go-vs-development-builds.md',
208+
],
209+
] as const)('expo rewrites %s to markdown URL', (url, expected) => {
210+
expect(rewrite(rules.expo, url)?.href).toBe(expected)
211+
})
212+
196213
test('conductor matches canonical and redirecting docs urls', () => {
197214
expect(patternsMatch(rules.conductor(), 'https://conductor.build/docs')).toBe(true)
198215
expect(patternsMatch(rules.conductor(), 'https://www.conductor.build/docs/installation')).toBe(

src/md/rules.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,35 @@ export const drizzle = rawRepoWithIndex({
7575
],
7676
checks: [{ url: 'https://orm.drizzle.team/docs/overview', contains: ['Drizzle ORM'] }],
7777
})
78+
export const expo = defineRule({
79+
key: 'expo',
80+
patterns: [
81+
new URLPattern({ hostname: 'docs.expo.dev' }),
82+
new URLPattern({ hostname: 'expo.dev', pathname: '/blog/:slug' }),
83+
new URLPattern({ hostname: 'expo.dev', pathname: '/blog/:slug/' }),
84+
],
85+
checks: [
86+
{
87+
url: 'https://docs.expo.dev/get-started/start-developing/',
88+
contains: ['Make your first change to an Expo project and see it live on your device.'],
89+
},
90+
{
91+
url: 'https://expo.dev/blog/expo-go-vs-development-builds',
92+
contains: [
93+
'Development builds and Expo Go are both tools for developing React Native apps',
94+
'## What exactly is Expo Go?',
95+
],
96+
minLength: 500,
97+
title: 'Expo Go vs Development Builds',
98+
},
99+
],
100+
rewrite(url) {
101+
if (/\.mdx?$/i.test(url.pathname)) return
102+
const mdUrl = new URL(url.href)
103+
mdUrl.pathname = url.pathname === '/' ? '/index.md' : `${url.pathname.replace(/\/$/, '')}.md`
104+
return mdUrl
105+
},
106+
})
78107
export const openai = appendMd({
79108
key: 'openai',
80109
patterns: [new URLPattern({ hostname: 'developers.openai.com' })],

0 commit comments

Comments
 (0)