Skip to content

Commit

Permalink
Added workflow. Removed srver dependant features
Browse files Browse the repository at this point in the history
  • Loading branch information
prjctimg committed Oct 15, 2023
1 parent 9fd9d08 commit 0caa145
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy
on:
push:
branches:
- api
- docs
jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand Down
6 changes: 0 additions & 6 deletions app/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Link from '@/components/Link'
import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
import { formatDate } from 'pliny/utils/formatDate'
import NewsletterForm from 'pliny/ui/NewsletterForm'

const MAX_DISPLAY = 5

Expand Down Expand Up @@ -81,11 +80,6 @@ export default function Home({ posts }) {
</Link>
</div>
)}
{siteMetadata.newsletter?.provider && (
<div className="flex items-center justify-center pt-4">
<NewsletterForm />
</div>
)}
</>
)
}
9 changes: 0 additions & 9 deletions app/api/newsletter/route.ts

This file was deleted.

2 changes: 1 addition & 1 deletion app/tag-data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"markdown":3,"code":3,"features":3,"next-js":5,"math":1,"ols":1,"github":1,"guide":4,"tailwind":2,"holiday":1,"canada":1,"images":1,"writings":1,"book":1,"reflection":1,"multi-author":1,"feature":1}
{}
6 changes: 4 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,25 @@ const securityHeaders = [
**/
module.exports = () => {
const plugins = [withContentlayer, withBundleAnalyzer]

return plugins.reduce((acc, next) => next(acc), {
reactStrictMode: true,
output: 'export',
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
eslint: {
dirs: ['app', 'components', 'layouts', 'scripts'],
},
images: {
domains: ['picsum.photos'],
},
async headers() {
/* async headers() {
return [
{
source: '/(.*)',
headers: securityHeaders,
},
]
},
}, */
webpack: (config, options) => {
config.module.rules.push({
test: /\.svg$/,
Expand Down
47 changes: 47 additions & 0 deletions scripts/postContentlayer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { writeFileSync } from 'fs'
import GithubSlugger from 'github-slugger'
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer.js'
import { allBlogs } from '../.contentlayer/generated/index.mjs'
import siteMetadata from '../data/siteMetadata.js'

const isProduction = process.env.NODE_ENV === 'production'

/**
* Count the occurrences of all tags across blog posts and write to json file
*/
export async function createTagCount() {
const tagCount = {}
allBlogs.forEach((file) => {
if (file.tags && (!isProduction || file.draft !== true)) {
file.tags.forEach((tag) => {
const formattedTag = GithubSlugger.slug(tag)
if (formattedTag in tagCount) {
tagCount[formattedTag] += 1
} else {
tagCount[formattedTag] = 1
}
})
}
})
writeFileSync('./app/tag-data.json', JSON.stringify(tagCount))
}

export async function createSearchIndex() {
if (
siteMetadata?.search?.provider === 'kbar' &&
siteMetadata.search.kbarConfig.searchDocumentsPath
) {
writeFileSync(
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`,
JSON.stringify(allCoreContent(sortPosts(allBlogs)))
)
console.log('Local search index generated...')
}
}

async function postContentlayer() {
await createTagCount()
await createSearchIndex()
}

postContentlayer()

0 comments on commit 0caa145

Please sign in to comment.