Skip to content

Commit

Permalink
move back to content, attempt to debug via code reference
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Apr 11, 2024
1 parent 22f2255 commit b1e6abb
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 50 deletions.
5 changes: 5 additions & 0 deletions app/county/[county]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react"
import path from "path"
import { getSummaryStats } from "utils/data/summaryStats"
import fs from "fs"

type CountyRouteProps = {
params: {
Expand Down Expand Up @@ -38,6 +39,10 @@ type CountyDataMap = Map<CountyDataKeys, CountyDataValues>
const CountyPage: React.FC<CountyRouteProps> = async ({ params }) => {
const county = params.county
const countyDataPath = path.join(process.cwd(), "public", "data", `county_summary_stats.msgpack`)
const contentPath = path.join(process.cwd(), "public", "content", `page`)
console.log(contentPath)
// fs read files in contentPath
const files = fs.readdirSync(contentPath)
const countyStats = await getSummaryStats<CountyDataMap>(countyDataPath, county)

return (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions hooks/useMdxContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ export const getMdxContent = async <T extends any>(contentType: keyof typeof cli
const r = await client.queries[contentType]({ relativePath })
return r
} else {
const filepath = path.join(process.cwd(), 'public', 'content', contentType, relativePath)
const filepath = path.join(process.cwd(), 'content', contentType, relativePath)
// log dirs in current dirxx
const dirs = fs.readdirSync(path.join(process.cwd()))
console.log('dirs', dirs)
if (dirs.includes('public')) {
const publicDirs = fs.readdirSync(path.join(process.cwd(), 'public'))
console.log('publicDirs', publicDirs)
if (publicDirs.includes('content')) {
const contentDirs = fs.readdirSync(path.join(process.cwd(), 'public', 'content'))
console.log('contentDirs', contentDirs)
if (contentDirs.includes(contentType)) {
const typeDirs = fs.readdirSync(path.join(process.cwd(), 'public', 'content', contentType))
console.log('typeDirs', typeDirs)
}
}
}
// if (dirs.includes('public')) {
// const publicDirs = fs.readdirSync(path.join(process.cwd(), 'public'))
// console.log('publicDirs', publicDirs)
// if (publicDirs.includes('content')) {
// const contentDirs = fs.readdirSync(path.join(process.cwd(), 'public', 'content'))
// console.log('contentDirs', contentDirs)
// if (contentDirs.includes(contentType)) {
// const typeDirs = fs.readdirSync(path.join(process.cwd(), 'public', 'content', contentType))
// console.log('typeDirs', typeDirs)
// }
// }
// }
const mdxContent = fs.readFileSync(filepath, 'utf-8')
const frontMatter = matter(mdxContent)
const data: any = {
Expand Down
71 changes: 42 additions & 29 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,51 @@ import path from "path"
*/
const config = withPlugins([[new NodePolyFillPlugin(), withBundleAnalyzer({ enabled: env.ANALYZE })]], {
reactStrictMode: true,
// webpack: (config, { isServer }) => {
// if (!isServer) {
// config.resolve.fallback = { fs: false }
webpack: (config, { isServer }) => {
if (isServer) {
config.externals = config.externals.map((external) => {
if (typeof external !== "function") return external
return ({ context, request }, callback) => {
// Check if the request starts with the path to your assets
if (request.startsWith("/content")) {
// Do not externalize if the request is for server-assets, thus including it in the bundle
return callback()
}
// Use the external function as default for other requests
return external({ context, request }, callback)
}
})
}
return config
},
// const _config = {
// ...config,
// experiments: {
// ...config.experiments,
// asyncWebAssembly: true,
// },
// resolve: {
// ...config.resolve,
// fallback: {
// ...config.resolve.fallback,
// modules: ['node_modules'],
// util: path.resolve("node_modules/util/")
// }
// }
// const _config = {
// ...config,
// experiments: {
// ...config.experiments,
// asyncWebAssembly: true,
// },
// resolve: {
// ...config.resolve,
// fallback: {
// ...config.resolve.fallback,
// modules: ['node_modules'],
// util: path.resolve("node_modules/util/")
// }
// }
// }
// return config
// }
// return config
// },
experimental: {
instrumentationHook: true,
},
rewrites() {
return [
{ source: "/healthz", destination: "/api/health" },
{ source: "/api/healthz", destination: "/api/health" },
{ source: "/health", destination: "/api/health" },
{ source: "/ping", destination: "/api/health" },
]
experimental: {
instrumentationHook: true,
},
// rewrites() {
// return [
// { source: "/healthz", destination: "/api/health" },
// { source: "/api/healthz", destination: "/api/health" },
// { source: "/health", destination: "/api/health" },
// { source: "/ping", destination: "/api/health" },
// ]
// },
})

export default config
2 changes: 1 addition & 1 deletion tina/__generated__/_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tina/__generated__/config.prebuild.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tina/collections/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default {
label: "Navigation",
name: "nav",
path: "public/content/nav",
path: "content/nav",
format: "mdx",
create: true,
fields: [
Expand Down
2 changes: 1 addition & 1 deletion tina/collections/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default {
label: "Page Content",
name: "page",
path: "public/content/page",
path: "content/page",
format: "mdx",
fields: [
{
Expand Down
2 changes: 1 addition & 1 deletion tina/collections/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default {
label: "Blog Posts",
name: "post",
path: "public/content/post",
path: "content/post",
fields: [
{
type: "string",
Expand Down
2 changes: 1 addition & 1 deletion tina/tina-lock.json

Large diffs are not rendered by default.

0 comments on commit b1e6abb

Please sign in to comment.