Skip to content

Commit

Permalink
refactoring and added header to index
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Huggett committed Aug 11, 2020
1 parent 8f42b60 commit f52c99e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
4 changes: 2 additions & 2 deletions content/packages.json
Expand Up @@ -61,8 +61,8 @@
"link": "https://github.com/tinacms/tinacms/tree/master/packages/gatsby-tinacms-remark"
},
{
"name": "tinacms",
"link": "https://github.com/tinacms/tinacms/tree/master/packages/tinacms"
"name": "@tinacms/alerts",
"link": "https://github.com/tinacms/tinacms/tree/master/packages/%40tinacms/alerts"
}
]
}
32 changes: 8 additions & 24 deletions pages/packages/index.tsx
@@ -1,20 +1,11 @@
import DocTemplate, { DocsGrid, DocGridHeader, DocsPageTitle, DocGridToc, DocGridContent } from '../docs/[...slug]'
import { getDocProps } from '../../utils/docs/getDocProps'
import { DocsGrid, DocGridContent } from '../docs/[...slug]'
import { GetStaticProps } from 'next'
import { GithubError } from 'next-tinacms-github'
import { useGithubMarkdownForm } from 'react-tinacms-github'
import React, { useState } from 'react'
import { createTocListener } from 'utils'
import { usePlugin } from 'tinacms'
import { useLastEdited } from 'utils/useLastEdited'
import { InlineGithubForm } from 'components/layout/InlineGithubForm'
import { NextSeo } from 'next-seo'
import { openGraphImage } from 'utils/open-graph-image'
import { DocsLayout, MarkdownContent } from 'components/layout'
import { InlineTextareaField } from 'react-tinacms-inline'
import Toc from 'components/toc'
import { InlineWysiwyg } from 'react-tinacms-editor'
import { LastEdited, DocsPagination } from 'components/ui'
import { getJsonPreviewProps, readJsonFile } from 'utils/getJsonPreviewProps'
import path from 'path'

Expand Down Expand Up @@ -53,6 +44,8 @@ export default function PackageIndex(props) {
<DocsLayout navItems={props.docsNav}>
<DocsGrid>
<DocGridContent ref={contentRef}>
<h1>TinaCMS Packages</h1>
<hr />
<ul>
{props.packages.map( p => {
return (
Expand All @@ -70,7 +63,6 @@ export default function PackageIndex(props) {

export const getStaticProps: GetStaticProps = async function(props) {
try {

const { preview, previewData }: any = props

const previewProps = await getJsonPreviewProps(
Expand All @@ -84,19 +76,11 @@ export const getStaticProps: GetStaticProps = async function(props) {
const file = await readJsonFile(
path.resolve(process.cwd(), './content/packages.json')
)
const packagePages = file.packages.map( p => {
if (p.readme) {
return {
name: p.name,
link: `https://tinacms.org/packages/${p.name}`
}
} else {
return {
name: p.name,
link: p.link
}
}
})

const packagePages = file.packages.map( p => ({
name: p.name,
link: p.readme ? `https://tinacms.org/packages/${p.name}` : p.link
}))

return {
props: {
Expand Down

0 comments on commit f52c99e

Please sign in to comment.