diff --git a/public/github_default.svg b/public/github_default.svg
new file mode 100644
index 000000000..e693cd34c
--- /dev/null
+++ b/public/github_default.svg
@@ -0,0 +1 @@
+
diff --git a/src/components/AddContentModal/SourceTypeStep/index.tsx b/src/components/AddContentModal/SourceTypeStep/index.tsx
index 8213cbc95..794f784b8 100644
--- a/src/components/AddContentModal/SourceTypeStep/index.tsx
+++ b/src/components/AddContentModal/SourceTypeStep/index.tsx
@@ -3,7 +3,7 @@ import { FC } from 'react'
import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
-import { RSS, TWITTER_HANDLE, YOUTUBE_CHANNEL } from '~/constants'
+import { GITHUB_REPOSITORY, RSS, TWITTER_HANDLE, YOUTUBE_CHANNEL } from '~/constants'
import { colors } from '~/utils'
import { extractNameFromLink } from '../utils'
@@ -27,6 +27,10 @@ const CONTENT_TYPE_MAPPING: Record = {
label: 'RSS Feed',
img: 'rss_feed.svg',
},
+ [GITHUB_REPOSITORY]: {
+ label: 'GitHub Repository',
+ img: 'github_default.svg',
+ },
}
export const SourceTypeStep: FC = ({ onNextStep, onPrevStep, type, value }) => (
diff --git a/src/components/AddContentModal/index.tsx b/src/components/AddContentModal/index.tsx
index 5bf005f52..36bc7b043 100644
--- a/src/components/AddContentModal/index.tsx
+++ b/src/components/AddContentModal/index.tsx
@@ -4,6 +4,8 @@ import * as sphinx from 'sphinx-bridge'
import { BaseModal } from '~/components/Modal'
import {
DOCUMENT,
+ GITHUB_REPOSITORY,
+ isE2E,
LINK,
NODE_ADD_ERROR,
RSS,
@@ -11,7 +13,6 @@ import {
TWITTER_SOURCE,
WEB_PAGE,
YOUTUBE_CHANNEL,
- isE2E,
} from '~/constants'
import { api } from '~/network/api'
import { useModal } from '~/stores/useModalStore'
@@ -80,7 +81,7 @@ const handleSubmitForm = async (
} else {
return
}
- } else if (sourceType === YOUTUBE_CHANNEL || sourceType === RSS) {
+ } else if (sourceType === YOUTUBE_CHANNEL || sourceType === RSS || sourceType === GITHUB_REPOSITORY) {
body.source = data.source
body.source_type = sourceType
}
diff --git a/src/components/AddContentModal/utils/__tests__/index.ts b/src/components/AddContentModal/utils/__tests__/index.ts
index 39ef6c068..70fa7855d 100644
--- a/src/components/AddContentModal/utils/__tests__/index.ts
+++ b/src/components/AddContentModal/utils/__tests__/index.ts
@@ -1,4 +1,13 @@
-import { DOCUMENT, LINK, RSS, TWITTER_HANDLE, TWITTER_SOURCE, WEB_PAGE, YOUTUBE_CHANNEL } from '~/constants'
+import {
+ DOCUMENT,
+ GITHUB_REPOSITORY,
+ LINK,
+ RSS,
+ TWITTER_HANDLE,
+ TWITTER_SOURCE,
+ WEB_PAGE,
+ YOUTUBE_CHANNEL,
+} from '~/constants'
import { extractNameFromLink, getInputType } from '..'
describe('youtubeRegex', () => {
@@ -61,6 +70,10 @@ describe('youtubeRegex', () => {
it('should assert we can check for document regex', async () => {
expect(getInputType('some plain text')).toBe(DOCUMENT)
})
+
+ it('should assert we can check for GitHub repository regex', async () => {
+ expect(getInputType('https://github.com/stakwork/sphinx-nav-fiber')).toBe(GITHUB_REPOSITORY)
+ })
})
describe('extractNameFromLink', () => {
diff --git a/src/components/AddContentModal/utils/index.ts b/src/components/AddContentModal/utils/index.ts
index 8ade526f6..2930bcfbe 100644
--- a/src/components/AddContentModal/utils/index.ts
+++ b/src/components/AddContentModal/utils/index.ts
@@ -1,4 +1,13 @@
-import { DOCUMENT, LINK, RSS, TWITTER_HANDLE, TWITTER_SOURCE, WEB_PAGE, YOUTUBE_CHANNEL } from '~/constants'
+import {
+ DOCUMENT,
+ GITHUB_REPOSITORY,
+ LINK,
+ RSS,
+ TWITTER_HANDLE,
+ TWITTER_SOURCE,
+ WEB_PAGE,
+ YOUTUBE_CHANNEL,
+} from '~/constants'
export const twitterHandlePattern = /\b(?:twitter\.com|x\.com)\/(?:@)?([\w_]+)(?:$|\?[^/]*$)/
@@ -14,6 +23,7 @@ const youtubeChannelPattern = /https?:\/\/(www\.)?youtube\.com\/(user\/)?(@)?([\
const genericUrlRegex = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/
const twitterBroadcastRegex = /https:\/\/twitter\.com\/i\/broadcasts\/([A-Za-z0-9_-]+)/
+const githubRepoPattern = /https:\/\/github\.com\/[\w-]+\/[\w-]+/
export function getInputType(source: string) {
const linkPatterns = [
@@ -45,6 +55,10 @@ export function getInputType(source: string) {
return RSS
}
+ if (githubRepoPattern.test(source)) {
+ return GITHUB_REPOSITORY
+ }
+
if (genericUrlRegex.test(source)) {
return WEB_PAGE
}
@@ -60,4 +74,5 @@ export const extractNameFromLink = (inputString: string, type = ''): string | nu
return match ? match[1] : null
}
-export const isSource = (type: string): boolean => !!type && [TWITTER_HANDLE, YOUTUBE_CHANNEL, RSS].includes(type)
+export const isSource = (type: string): boolean =>
+ !!type && [TWITTER_HANDLE, YOUTUBE_CHANNEL, RSS, GITHUB_REPOSITORY].includes(type)