Deploy fixes (#84)

* chore(deploy.yml): use v2 env and checkout master

* fix: correctly sanitize md file paths
This commit is contained in:
Artur
2024-10-17 12:59:07 -03:00
committed by GitHub
parent baa9b3cfc3
commit 7d77fe2686
4 changed files with 14 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import xss from 'xss'
import { FundSlug } from '@prisma/client'
import sanitize from 'sanitize-filename'
import xss from 'xss'
import markdownToHtml from '../../utils/markdownToHtml'
import { fileExists, getSingleFile } from '../../utils/md'
@@ -15,7 +16,7 @@ export default function About({ content }: { content: string }) {
}
export async function getStaticProps({ params }: { params: { fund: FundSlug } }) {
const md = getSingleFile(`docs/${params.fund}/about_us.md`)
const md = getSingleFile(`docs/${sanitize(params.fund)}/about_us.md`)
const content = await markdownToHtml(md || '')
@@ -29,7 +30,7 @@ export async function getStaticProps({ params }: { params: { fund: FundSlug } })
export function getStaticPaths() {
return {
paths: fundSlugs
.filter((fundSlug) => fileExists(`docs/${fundSlug}/about.md`))
.filter((fundSlug) => fileExists(`docs/${sanitize(fundSlug)}/about.md`))
.map((fundSlug) => `/${fundSlug}/about`),
fallback: true,
}

View File

@@ -1,16 +1,17 @@
import { FundSlug } from '@prisma/client'
import sanitize from 'sanitize-filename'
import markdownToHtml from '../../utils/markdownToHtml'
import { fileExists, getSingleFile } from '../../utils/md'
import BigDumbMarkdown from '../../components/BigDumbMarkdown'
import { fundSlugs } from '../../utils/funds'
import { fundHeaderNavLinks } from '../../data/headerNavLinks'
export default function About({ content }: { content: string }) {
return <BigDumbMarkdown content={content} />
}
export async function getStaticProps({ params }: { params: { fund: FundSlug } }) {
const md = getSingleFile(`docs/${params.fund}/apply_research.md`)
const md = getSingleFile(`docs/${sanitize(params.fund)}/apply_research.md`)
const content = await markdownToHtml(md || '')
@@ -24,7 +25,7 @@ export async function getStaticProps({ params }: { params: { fund: FundSlug } })
export function getStaticPaths() {
return {
paths: fundSlugs
.filter((fundSlug) => fileExists(`docs/${fundSlug}/apply_research.md`))
.filter((fundSlug) => fileExists(`docs/${sanitize(fundSlug)}/apply_research.md`))
.map((fundSlug) => `/${fundSlug}/apply_research`),
fallback: true,
}

View File

@@ -1,5 +1,6 @@
import xss from 'xss'
import { FundSlug } from '@prisma/client'
import sanitize from 'sanitize-filename'
import xss from 'xss'
import markdownToHtml from '../../utils/markdownToHtml'
import { fileExists, getSingleFile } from '../../utils/md'
@@ -15,7 +16,7 @@ export default function Faq({ content }: { content: string }) {
}
export async function getStaticProps({ params }: { params: { fund: FundSlug } }) {
const md = getSingleFile(`docs/${params.fund}/faq.md`)
const md = getSingleFile(`docs/${sanitize(params.fund)}/faq.md`)
const content = await markdownToHtml(md || '')
@@ -29,7 +30,7 @@ export async function getStaticProps({ params }: { params: { fund: FundSlug } })
export function getStaticPaths() {
return {
paths: fundSlugs
.filter((fundSlug) => fileExists(`docs/${fundSlug}/faq.md`))
.filter((fundSlug) => fileExists(`docs/${sanitize(fundSlug)}/faq.md`))
.map((fundSlug) => `/${fundSlug}/faq`),
fallback: true,
}

View File

@@ -26,12 +26,12 @@ const projectSlugsByFund: Record<FundSlug, string[]> = {
}
export function getSingleFile(path: string) {
const fullPath = join(process.cwd(), sanitize(path))
const fullPath = join(process.cwd(), path)
return fs.readFileSync(fullPath, 'utf8')
}
export function fileExists(path: string) {
const fullPath = join(process.cwd(), sanitize(path))
const fullPath = join(process.cwd(), path)
try {
fs.accessSync(fullPath, fs.constants.F_OK)
return true