File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
33 reactStrictMode : true ,
4- output : 'export' ,
54 pageExtensions : [ 'page.tsx' ] ,
65 images : {
76 unoptimized : true ,
@@ -44,7 +43,7 @@ const nextConfig = {
4443
4544 fileLoaderRule . exclude = / \. s v g $ / i;
4645 return config ;
47- } ,
46+ } ,
4847} ;
4948
5049module . exports = nextConfig ;
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ const getCategories = (frontmatter: any): blogCategories[] => {
3535 return Array . isArray ( cat ) ? cat : [ cat ] ;
3636} ;
3737
38- export async function getStaticProps ( { query } : { query : any } ) {
38+ export async function getStaticProps ( ) {
3939 const files = fs . readdirSync ( PATH ) ;
4040 const blogPosts = files
4141 . filter ( ( file ) => file . substr ( - 3 ) === '.md' )
@@ -54,15 +54,12 @@ export async function getStaticProps({ query }: { query: any }) {
5454 } ) ;
5555
5656 await generateRssFeed ( blogPosts ) ;
57-
58- const filterTag : string = query ?. type || 'All' ;
59-
6057 return {
6158 props : {
6259 blogPosts,
63- filterTag,
6460 } ,
65- } ;
61+ } ;
62+
6663}
6764
6865function isValidCategory ( category : any ) : category is blogCategories {
@@ -86,10 +83,11 @@ export default function StaticMarkdownPage({
8683} ) {
8784 const router = useRouter ( ) ;
8885 // Initialize the filter as an array. If "All" or not specified, we show all posts.
89- const initialFilters =
90- filterTag && filterTag !== 'All'
91- ? filterTag . split ( ',' ) . filter ( isValidCategory )
92- : [ 'All' ] ;
86+ const initialFilters = router . query . type
87+ ? ( ( router . query . type as string )
88+ . split ( ',' )
89+ . filter ( isValidCategory ) as blogCategories [ ] )
90+ : [ 'All' ] as blogCategories [ ] ;
9391
9492 const [ currentFilterTags , setCurrentFilterTags ] =
9593 useState < blogCategories [ ] > ( initialFilters ) ;
You can’t perform that action at this time.
0 commit comments