Skip to content

Commit

Permalink
fix(getdocs): get documents from raw.github
Browse files Browse the repository at this point in the history
  • Loading branch information
RobsonOlv committed Dec 6, 2023
1 parent c4881e2 commit 07c0add
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 45 deletions.
56 changes: 37 additions & 19 deletions src/pages/docs/tracks/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Breadcrumb from 'components/breadcrumb'

import getHeadings from 'utils/getHeadings'
import getNavigation from 'utils/getNavigation'
import getGithubFile from 'utils/getGithubFile'
// import getGithubFile from 'utils/getGithubFile'
import { getDocsPaths as getTracksPaths } from 'utils/getDocsPaths'
import replaceMagicBlocks from 'utils/replaceMagicBlocks'
import escapeCurlyBraces from 'utils/escapeCurlyBraces'
Expand Down Expand Up @@ -215,19 +215,29 @@ export const getStaticProps: GetStaticProps = async ({
}
}

let documentationContent = await getGithubFile(
'vtexdocs',
'help-center-content',
branch,
path
)
// let documentationContent = await getGithubFile(
// 'vtexdocs',
// 'help-center-content',
// branch,
// path
// )

const contributors = await getFileContributors(
'vtexdocs',
'help-center-content',
branch,
path
)
let documentationContent =
(await fetch(
`https://raw.githubusercontent.com/vtexdocs/help-center-content/${branch}/${path}`
)
.then((res) => res.text())
.catch((err) => console.log(err))) || ''

const contributors =
(await getFileContributors(
'vtexdocs',
'help-center-content',
branch,
path
).catch((err) => {
console.log(err)
})) || []

let format: 'md' | 'mdx' = 'mdx'
try {
Expand Down Expand Up @@ -278,12 +288,20 @@ export const getStaticProps: GetStaticProps = async ({
)?.path
if (seeAlsoPath) {
try {
const documentationContent = await getGithubFile(
'vtexdocs',
'help-center-content',
'main',
seeAlsoPath
)
const documentationContent =
(await fetch(
`https://raw.githubusercontent.com/vtexdocs/help-center-content/main/${seeAlsoPath}`
)
.then((res) => res.text())
.catch((err) => console.log(err))) || ''

// const documentationContent = await getGithubFile(
// 'vtexdocs',
// 'help-center-content',W
// 'main',
// seeAlsoPath
// )

const serialized = await serialize(documentationContent, {
parseFrontmatter: true,
})
Expand Down
54 changes: 35 additions & 19 deletions src/pages/docs/tutorial/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Breadcrumb from 'components/breadcrumb'

import getHeadings from 'utils/getHeadings'
import getNavigation from 'utils/getNavigation'
import getGithubFile from 'utils/getGithubFile'
// import getGithubFile from 'utils/getGithubFile'
import { getDocsPaths as getTutorialsPaths } from 'utils/getDocsPaths'
import replaceMagicBlocks from 'utils/replaceMagicBlocks'
import escapeCurlyBraces from 'utils/escapeCurlyBraces'
Expand Down Expand Up @@ -214,19 +214,29 @@ export const getStaticProps: GetStaticProps = async ({
}
}

let documentationContent = await getGithubFile(
'vtexdocs',
'help-center-content',
branch,
path
)
// let documentationContent = await getGithubFile(
// 'vtexdocs',
// 'help-center-content',
// branch,
// path
// )

const contributors = await getFileContributors(
'vtexdocs',
'help-center-content',
branch,
path
)
let documentationContent =
(await fetch(
`https://raw.githubusercontent.com/vtexdocs/help-center-content/${branch}/${path}`
)
.then((res) => res.text())
.catch((err) => console.log(err))) || ''

const contributors =
(await getFileContributors(
'vtexdocs',
'help-center-content',
branch,
path
).catch((err) => {
console.log(err)
})) || []

let format: 'md' | 'mdx' = 'mdx'
try {
Expand Down Expand Up @@ -277,12 +287,18 @@ export const getStaticProps: GetStaticProps = async ({
)?.path
if (seeAlsoPath) {
try {
const documentationContent = await getGithubFile(
'vtexdocs',
'help-center-content',
'main',
seeAlsoPath
)
const documentationContent =
(await fetch(
`https://raw.githubusercontent.com/vtexdocs/help-center-content/main/${seeAlsoPath}`
)
.then((res) => res.text())
.catch((err) => console.log(err))) || ''
// const documentationContent = await getGithubFile(
// 'vtexdocs',
// 'help-center-content',
// 'main',
// seeAlsoPath
// )
const serialized = await serialize(documentationContent, {
parseFrontmatter: true,
})
Expand Down
22 changes: 15 additions & 7 deletions src/pages/updates/announcements/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
localeType,
} from 'utils/navigation-utils'
import getNavigation from 'utils/getNavigation'
import getGithubFile from 'utils/getGithubFile'
// import getGithubFile from 'utils/getGithubFile'
import { getDocsPaths as getNewsPaths } from 'utils/getDocsPaths'
import replaceMagicBlocks from 'utils/replaceMagicBlocks'
import escapeCurlyBraces from 'utils/escapeCurlyBraces'
Expand Down Expand Up @@ -176,12 +176,20 @@ export const getStaticProps: GetStaticProps = async ({
}
}

let documentationContent = await getGithubFile(
'vtexdocs',
'help-center-content',
branch,
path
)
// let documentationContent = await getGithubFile(
// 'vtexdocs',
// 'help-center-content',
// branch,
// path
// )

let documentationContent =
(await fetch(
`https://raw.githubusercontent.com/vtexdocs/help-center-content/${branch}/${path}`
)
.then((res) => res.text())
.catch((err) => console.log(err))) || ''

const logger = getLogger('News')

try {
Expand Down

0 comments on commit 07c0add

Please sign in to comment.