Skip to content

Commit f0becc1

Browse files
committed
feat: implement GitHub Actions for automated deployment and enhance Disqus integration
- Added a GitHub Actions workflow for deploying the application to GitHub Pages on push to the main branch. - Updated package.json to streamline the build process for pages and set up predeploy scripts. - Enhanced Disqus integration by passing the post slug and title for improved comment functionality. - Modified PostSingle and DisqussEmbed components to support the new Disqus configuration.
1 parent a691f89 commit f0becc1

6 files changed

Lines changed: 68 additions & 6 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: pages
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: pnpm
29+
30+
- run: pnpm install --frozen-lockfile
31+
32+
- run: pnpm run build:pages
33+
34+
- name: Publish to gh-pages
35+
uses: peaceiris/actions-gh-pages@v4
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
publish_dir: ./out
39+
publish_branch: gh-pages
40+
force_orphan: true

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"build": "next build",
2323
"export": "next build",
2424
"postexport": "echo 'frontchapter.ir' > out/CNAME",
25-
"predeploy": "npm run export && touch out/.nojekyll",
25+
"build:pages": "next build && echo 'frontchapter.ir' > out/CNAME && touch out/.nojekyll",
26+
"predeploy": "pnpm run build:pages",
2627
"deploy": "gh-pages -d out --dotfiles",
2728
"lint": "next lint",
2829
"start": "next start"

‎src/app/posts/[single]/page.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const Article = async ({ params }: { params: { single: string } }) => {
3838
<JsonLd data={jsonLd} />
3939
<GSAPWrapper>
4040
<PostSingle
41+
slug={single}
4142
frontmatter={{
4243
title: frontmatter.title,
4344
date: frontmatter.date,

‎src/config/config.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
},
5454
"disqus": {
5555
"enable": true,
56-
"shortname": "themefisher-template",
57-
"settings": {}
56+
"shortname": "frontchapter",
57+
"settings": {
58+
"language": "fa"
59+
}
5860
}
5961
}

‎src/layouts/PostSingle.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ interface RecentPost {
3838
}
3939

4040
interface PostSingleProps {
41+
slug: string;
4142
frontmatter: Frontmatter;
4243
content: string;
4344
recentPosts: RecentPost[];
4445
}
4546

4647
const PostSingle: React.FC<PostSingleProps> = ({
48+
slug,
4749
frontmatter,
4850
content,
4951
recentPosts,
@@ -155,7 +157,7 @@ const PostSingle: React.FC<PostSingleProps> = ({
155157
{disqus.enable && (
156158
<div className="fade row justify-center ">
157159
<div className="lg:col-8">
158-
<DisqussEmbed />
160+
<DisqussEmbed slug={slug} title={title} />
159161
</div>
160162
</div>
161163
)}

‎src/layouts/partials/DisqussEmbed.tsx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
'use client';
22
import config from '@config/config.json';
3+
import { SITE_URL } from '@lib/seo/constants';
34
import { DiscussionEmbed } from 'disqus-react';
45

5-
const DisqussEmbed = () => {
6+
interface DisqussEmbedProps {
7+
slug: string;
8+
title: string;
9+
}
10+
11+
const DisqussEmbed = ({ slug, title }: DisqussEmbedProps) => {
612
const { disqus } = config;
13+
const url = `${SITE_URL}/posts/${slug}`;
14+
715
return (
8-
<DiscussionEmbed shortname={disqus.shortname} config={disqus.settings} />
16+
<DiscussionEmbed
17+
shortname={disqus.shortname}
18+
config={{
19+
...disqus.settings,
20+
url,
21+
identifier: slug,
22+
title,
23+
}}
24+
/>
925
);
1026
};
1127

0 commit comments

Comments
 (0)