Project Titan - Document
Github: Project Titan
- Fork and STAR it, please.
- Go to Vercel, Login and click 'New Project'
- Import your forked repo
- Click
Continue
- Finger crossed and wait it to deploy
Then you can add/update the post and push to github.Vercel will handle all CI / CD works for you.
- Fork and STAR it, please.
- Clone it locally
npm install
oryarn
npm run dev
oryarn dev
You can set your favourite homepage background on data\jumbotron.ts:
const backgroundPictureLib = [
"https://i.picsum.photos/id/311/1600/900.jpg?hmac=yUS02Bgwg81GbTpDuG813r871akJWNv-_Oem7a6PtWY",
"https://i.picsum.photos/id/83/1600/900.jpg?hmac=R9BQdLAPaGw27suOHRBe6G6xb7m1XzQlbsx7as1N7-s",
"https://i.picsum.photos/id/667/1600/900.jpg?hmac=JScRHUs-2c2rX10nkdYL8sWamAcZM0ax0n18X_N4s0Y",
"https://i.picsum.photos/id/888/1600/900.jpg?hmac=hw_TgE4fAZhZAjM5W_sTVY3_SpRrZU7vKw42ZtQt6mo",
"https://i.picsum.photos/id/649/1600/900.jpg?hmac=MfwiBIOCS7_7zBii3bCvlKJIUO7rxdhOtDPhgvnn8tk",
];
Before you add background picture, add the picture domain into config file, see: WebP Pictures Integration
Pictures are serves as webP and may display randomly on each build.
You may see different homepage background on each
git push
to your site.
You can set your favourite quotation ondata\showcaseContent.ts:
Quotations are displayed randomly on each visit.
You may see different show case content on each access to your site.
Header is required for all posts.
For post file posts/jekyllmarkdowntoc.md
with below YAML Header:
---
title: 'Post Title' // (Required)
categories: 'Life' // (Optional)
date : '2017-05-19' // (Required)
tags: ['A', 'B'] // (Optional, array of string)
color?: "primary" | "secondary" // (Optional) Determines the color in post list, default to grey
hide: true | false // (Optional as false, hide the post in Post List?)
---
Above post will be routed as:
/Life/2017/05/19/jekyllmarkdowntoc
/Life/2017/05/19/jekyllmarkdowntoc.html // Auto-redirect to above one
Check the files in /posts
then you may understand everything.
All images in posts will be progressed and serve as webP picture.
You may need to put the image hosts into next.config.js
images: {
domains: [
"szhshp.org",
"titan.szhshp.org",
// "yourImageDomain.com",
"i.picsum.photos",
"i.imgur.com",
],
},
You don't need to care about it, at all.
It may show the lightbox on click of a image in any post.
Implements with react - image - lightbox
You don't need to care about it, at all.
Example:
const a = 100;
console.log(a);
const f = (v) => v + 5;
f(a);
Implements with highlight.js
Change the css in _app.tsx
:
import "highlight.js/styles/monokai.css";
You don't need to care about it, at all.
A responsive TOC will be automatically rendered in the sidebar.
An extra TOC will be automatically rendered at the top of each post.
Check the attributes in Sidebar.tsx
:
tocbot.init({
tocSelector: ".sidebarMid-Toc",
contentSelector: ".main",
headingSelector: "h1, h2, h3, h4, h5",
hasInnerContainers: true,
});
You can add translation set in locale.ts
export const locale = {
siteTitle: {
zh: "泰坦計劃",
en: "Project Titan",
},
}
Usage with translate function translationString
:
console.log(translationString({
textKey: "siteTitle",
}))
Usage with hook useTranslator
:
const Example = (): JSX.Element => {
const { translate, locale } = useTranslator();
return <div>{`${ translate(locale.siteTitle) } `}</div>;
};
const Example = (): JSX.Element => {
const { setLanguage } = useTranslator();
return <div onClick={() => setLanguage("zh")}>Change Language</div>;
};
Here is an example of a static page with React components as content:
const About = (): JSX.Element => (
<PostTemplate
title={`${
translationString({
textKey: "about",
})
} `}
content={(
<Box>
<Box>JSX Here</Box>
</Box>
)}
/>
);
export default About;
Put these snippets to /pages/about.tsx
then NextJS will route it as /about
(example)
See more about Dynamic Routes
Here is an example of a static page with pure markdown as content:
const markdown = `
## Title
## Title ?
### Title!
### Title~
#### Title -
`;
const CustomPage = (): JSX.Element => (
<PostTemplate
title="404"
showTOC={false}
content={(
<>
<MarkdownRenderer content={markdown} />
</>
)}
/>
);
export default CustomPage;
That is easy to migrate
Provide all posts with valid date in the post header
--- title: 'Post Title' // You already have this in Jekyll categories: 'Life' date : '2017-05-19' // Make sure you have this attribute, date should be in format YYYY-MM-DD tags: ['A', 'B'] ---
NextJS is different from Jekyll, you may need to build before deploy.
- Run
yarn run build
ornpm run build
to create a production version - Upload to your pages service
- Run
For the build step, you can use Github Action, Jenkins for CI / CD or Vercel to simplify the build process
- You can follow these steps to deploy on Vercel in 5 mins
- Vercel
- NextJS
- Material UI
- tocbot
- react - markdown
- react - image - lightbox
- Doctor Jones
About this article
- Post Title: Project Titan - Document
- Create Date: 2021-05-30
- Category: Tech
- Tags: ProjectGaia
Messager
Put your comment box here