npx @shack-js/cli init blog-site -t react-typescript
cd blog-site
npm i
yarn dev
now check localhost:3000 to see if it's working
let's use sequelize, and example codes can help
npm i sequelize sqlite3 -S
npm i @types/sequelize @types/express -D
add sequelize files
common/sequelize.ts
the instancecommon/User.ts
the user modelcommon/Article.ts
the Article model
and we need to create tables when we first start
apis/_init.ts
create tables if needed
// apis/_init.ts
await sequelize.sync()
nothing changed yet
npm i react-router-dom semantic-ui-react semantic-ui-css -S
npm i @types/react-router-dom css-loader mini-css-extract-plugin -D
apis/_init.ts
route all 404 to index.htmlshack.config.mjs
add css/file loaderweb/index.tsx
basic htmls and basic routes
suppose using md5 for hash, and jwt for token
npm i md5 jsonwebtoken -S
npm i @types/md5 @types/jsonwebtoken -D
apis/user.ts
register and login
to add register and login page, we first need to add router and ui
apis/_auth.ts
try get user from jwt headerapis/user.ts
addinfo
method so login user can get his infoweb/stores.ts
add stores for token and user, sync token from/to localstorageweb/Navbar.tsx
render menus based on login stateweb/Content.tsx
render components based on routeweb/login.tsx
login/register pageweb/home.tsx
home page unfinishedweb/write.tsx
write page unfinished
let's use react-mde
for markdown editor
npm i react-mde showdown -S
npm i @types/showdown -D
apis/authed/_auth.ts
allow only user already loginapis/authed/article.ts
addadd
method to store markdownweb/write.tsx
edit markdown and save
load old blogs when you scroll to bottom
npm i react-infinite-scroll-component react-showdown -S
apis/article.ts
load articles from dbweb/home.tsx
show articles
and yes it's done!
npm i
npm run dev