-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06bdd57
commit 4c83380
Showing
11 changed files
with
77 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
to: ../transparent-info-app/gen/posts.js | ||
--- | ||
|
||
/********************* | ||
|
||
this is generated code ,donot edit me !!!!! | ||
|
||
****************************/ | ||
|
||
import withExtra from '../components/post/PostWrap'; | ||
|
||
<% h.posts.forEach( e => { %> | ||
import * as N<%= h.changeCase.constant(e) %> from '../pages/posts/<%- e %>'; <% }) %> | ||
|
||
export const posts = [ <% h.posts.forEach( e => { %> | ||
withExtra(N<%= h.changeCase.constant(e) %>.default,{fileName: '<%= e %>', title: N<%= h.changeCase.constant(e) %>.title , category: 'posts'}), <% }) %> | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/transparent-info-app/components/post/PostWrap.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FunctionComponent } from 'react'; | ||
|
||
type Category = 'posts'; | ||
|
||
export interface WrapExtra { | ||
fileName: string; | ||
title: string; | ||
category: Category; | ||
href?: string; | ||
} | ||
|
||
type PostProps = WrapExtra; | ||
|
||
export type WithExtra = [FunctionComponent<PostProps>, WrapExtra]; | ||
|
||
export default function withExtra( | ||
WrapComponent: FunctionComponent<PostProps>, | ||
extra: WrapExtra | ||
): WithExtra { | ||
const href = `/${extra.category}/${extra.fileName.split('.')[0]}`; | ||
return [ | ||
(props: any) => <WrapComponent {...extra} {...props} />, | ||
{ | ||
...extra, | ||
href, | ||
}, | ||
]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { PostList } from '../../components/post/PostList'; | ||
|
||
import { posts } from '../../gen/posts'; | ||
import Layout from '../../components/Layout'; | ||
|
||
export default () => { | ||
return ( | ||
<Layout title="文章列表"> | ||
<PostList posts={posts} /> | ||
</Layout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters