upstream #1

Merged
jblu merged 1007 commits from upstream into main 2024-11-04 22:35:57 -06:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit fba98a0b74 - Show all commits

View File

@ -7,14 +7,15 @@ import BlogSeo from '@/components/BlogSeo'
import Tag from '@/components/Tag' import Tag from '@/components/Tag'
import siteMetdata from '@/data/siteMetadata' import siteMetdata from '@/data/siteMetadata'
const editUrl = (slug) => `${siteMetdata.github}/edit/master/data/blog/${slug}.mdx` const editUrl = (fileName) => `${siteMetdata.siteRepo}/blob/master/data/blog/${fileName}`
const discussUrl = (slug) => const discussUrl = (slug) =>
`https://mobile.twitter.com/search?q=${encodeURIComponent(`${siteMetdata.siteUrl}/blog/${slug}`)}` `https://mobile.twitter.com/search?q=${encodeURIComponent(`${siteMetdata.siteUrl}/blog/${slug}`)}`
const postDateTemplate = tinytime('{dddd}, {MMMM} {DD}, {YYYY}') const postDateTemplate = tinytime('{dddd}, {MMMM} {DD}, {YYYY}')
export default function PostLayout({ children, frontMatter, next, prev }) { export default function PostLayout({ children, frontMatter, next, prev }) {
const { slug, date, title, tags } = frontMatter const { slug, fileName, date, title, tags } = frontMatter
console.log(fileName)
return ( return (
<SectionContainer> <SectionContainer>
@ -65,13 +66,11 @@ export default function PostLayout({ children, frontMatter, next, prev }) {
<div className="divide-y divide-gray-200 dark:divide-gray-700 xl:pb-0 xl:col-span-3 xl:row-span-2"> <div className="divide-y divide-gray-200 dark:divide-gray-700 xl:pb-0 xl:col-span-3 xl:row-span-2">
<div className="prose dark:prose-dark max-w-none pt-10 pb-8">{children}</div> <div className="prose dark:prose-dark max-w-none pt-10 pb-8">{children}</div>
<div className="text-sm pt-6 pb-6 text-gray-700 dark:text-gray-300"> <div className="text-sm pt-6 pb-6 text-gray-700 dark:text-gray-300">
<a href={discussUrl(slug)} target="_blank" rel="noopener noreferrer"> <Link href={discussUrl(slug)} rel="nofollow">
{'Discuss on Twitter'} {'Discuss on Twitter'}
</a> </Link>
{``} {``}
<a href={editUrl(slug)} target="_blank" rel="noopener noreferrer"> <Link href={editUrl(fileName)}>{'View on GitHub'}</Link>
{'Edit on GitHub'}
</a>
</div> </div>
</div> </div>
<footer className="text-sm font-medium leading-5 xl:divide-y divide-gray-200 dark:divide-gray-700 xl:col-start-1 xl:row-start-2"> <footer className="text-sm font-medium leading-5 xl:divide-y divide-gray-200 dark:divide-gray-700 xl:col-start-1 xl:row-start-2">

View File

@ -76,6 +76,7 @@ export async function getFileBySlug(type, slug) {
wordCount: content.split(/\s+/gu).length, wordCount: content.split(/\s+/gu).length,
readingTime: readingTime(content), readingTime: readingTime(content),
slug: slug || null, slug: slug || null,
fileName: fs.existsSync(mdxPath) ? `${slug}.mdx` : `${slug}.md`,
...data, ...data,
}, },
} }
@ -87,7 +88,6 @@ export async function getAllFilesFrontMatter(type) {
const allFrontMatter = files.reduce((allPosts, postSlug) => { const allFrontMatter = files.reduce((allPosts, postSlug) => {
const source = fs.readFileSync(path.join(root, 'data', type, postSlug), 'utf8') const source = fs.readFileSync(path.join(root, 'data', type, postSlug), 'utf8')
const { data } = matter(source) const { data } = matter(source)
return [ return [
{ {
...data, ...data,