Make a tina project for github pages.
Repository should name like foloinfo.github.io, use your account name.
Using the tina project name same as the repository name maybe a good idea.
npx create-tina-app@latestSee if it works fine on http://localhost:3000 .
yarn
yarn devFollow the steps on Moving from Local-Mode to Prod-Mode | TinaCMS Docs .
- Sign up to tina cloud
- Connect with github account
- Pick a github pages repository
- Copy your
Client IDand paste to.envasNEXT_PUBLIC_TINA_CLIENT_ID - Navigate to
Tokensand create new token, copy&paste asTINA_TOKEN NEXT_PUBLIC_TINA_BRANCH=mainif not
Next, you need to setup Github Actions, maybe now it's a good time to commit & push to remote.
Reference the official documentation here: Connecting the site | TinaCMS Docs
- Open your github pages repository settings page (
https://github.com/foloinfo/foloinfo.github.io/settingsfor me) - Open
Pagespanel and setBuild and deploymentsettings toGithubActions - Select
Next.jsand configure. - Open
Secrets and variablesand chooseActions - Set
NEXT_PUBLIC_TINA_CLIENT_ID,TINA_TOKEN,NEXT_PUBLIC_TINA_BRANCH
In the official documentation, it uses environment variables like TINA_PUBLIC_CLIENT_ID.
I changed those to NEXT_PUBLIC_TINA_CLIENT_ID to keep it consistent.
Here is the code for yml file for the github actions.
foloinfo.github.io/nextjs_tina.yml at main · foloinfo/foloinfo.github.io
Next, you need to modify tina project code to run yarn next export, since tina's default example uses getServerSideProps and it's not comatible with static site export.
You need to change it to getStaticProps and getStaticPaths.
/pages/[slug].js
code: foloinfo.github.io/[slug].js at main · foloinfo/foloinfo.github.io
export const getStaticPaths = async () => {
const { data } = await client.queries.pageConnection();
const paths = data.pageConnection.edges.map((x) => {
return { params: { slug: x.node._sys.filename } };
});
return {
paths,
fallback: "blocking",
};
};
export const getStaticProps = async ({ params }) => {
const { data, query, variables } = await client.queries.page({
relativePath: `${params.slug}.mdx`,
});
return {
props: {
data,
query,
variables,
},
};
};Now, you should be able to run yarn build && yarn next export in the local env.
You can push to github with main branch and it should build & release your github pages.