{`_html:${marked(article.body)}`}
42 | 50 |├── logo.png ├── .editorconfig ├── tslint.json ├── api-test.http ├── jest.config.js ├── .prettierrc ├── src ├── components │ ├── error-list.tsx │ ├── page-list.tsx │ ├── modal.tsx │ ├── article-list.tsx │ ├── header.tsx │ ├── article-meta.tsx │ ├── comment-list.tsx │ ├── register.tsx │ ├── signin.tsx │ ├── editor.tsx │ ├── settings.tsx │ ├── article.tsx │ ├── profile.tsx │ └── home.tsx ├── main.ts ├── models.ts ├── fetch.ts └── api.ts ├── .gitignore ├── tsconfig.json ├── tests ├── home.view.spec.ts ├── mocks.ts ├── home.spec.ts ├── auto-events.spec.ts └── snapshot.spec.ts ├── webpack.config.js ├── .vscode └── launch.json ├── package.json ├── .eslintrc.js ├── index.html ├── readme.md ├── app.js └── app.js.map /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gothinkster/apprun-realworld-example-app/HEAD/logo.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 2 7 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-unused-expression": true, 4 | "no-duplicate-variable": true, 5 | "class-name": true 6 | } 7 | } -------------------------------------------------------------------------------- /api-test.http: -------------------------------------------------------------------------------- 1 | ### Old 2 | GET https://conduit.productionready.io/api/articles?limit=10&offset=0 3 | 4 | 5 | ### New 6 | GET https://api.realworld.io/api/articles?limit=10&offset=0 -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 3 | module.exports = { 4 | preset: 'ts-jest', 5 | testEnvironment: 'jsdom', 6 | 'extensionsToTreatAsEsm': ['.esm.js'] 7 | }; -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "bracketSpacing": true, 8 | "jsxBracketSameLine": true, 9 | "arrowParens": "avoid" 10 | } 11 | -------------------------------------------------------------------------------- /src/components/error-list.tsx: -------------------------------------------------------------------------------- 1 | import app from 'apprun'; 2 | 3 | export default function ({ errors }) { 4 | return ( 5 |
10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /bower_components 6 | 7 | # IDEs and editors 8 | /.idea 9 | .project 10 | .classpath 11 | *.launch 12 | .settings/ 13 | 14 | #System Files 15 | .DS_Store 16 | Thumbs.db 17 | 18 | coverage 19 | __snapshots__ 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "es2015", 5 | "moduleResolution": "node", 6 | "jsx": "react", 7 | "jsxFactory": "app.h", 8 | "jsxFragmentFactory": "app.Fragment", 9 | "lib": ["dom", "es2015", "es5"], 10 | "sourceMap": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "esModuleInterop": true 14 | } 15 | } -------------------------------------------------------------------------------- /tests/home.view.spec.ts: -------------------------------------------------------------------------------- 1 | import home from '../src/components/home'; 2 | 3 | describe('home component', () => { 4 | it('view test', () => { 5 | const state = { 6 | type: 'feed', 7 | articles: [], 8 | tags: ['1', '2', '3'], 9 | max: 10, 10 | page: 1 11 | } 12 | const vdom = home['view'](state); 13 | expect(JSON.stringify(vdom, undefined, 2)).toMatchSnapshot(); 14 | }) 15 | }); 16 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import app from 'apprun'; 2 | 3 | import './components/header'; 4 | import './components/home'; 5 | import './components/signin'; 6 | import './components/register'; 7 | import './components/profile'; 8 | import './components/settings'; 9 | import './components/editor'; 10 | import './components/article'; 11 | 12 | app.on('#', (route, ...p) => { 13 | app.run(`#/${route || ''}`, ...p); 14 | }); 15 | 16 | app.once('/set-user', () => { 17 | app.route(location.hash); 18 | }); 19 | 20 | app.run('/get-user'); -------------------------------------------------------------------------------- /src/components/page-list.tsx: -------------------------------------------------------------------------------- 1 | import app from 'apprun'; 2 | 3 | export default function ({ max, selected, link }) { 4 | const pages = new Array(max).fill(0); 5 | return ( 6 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /src/models.ts: -------------------------------------------------------------------------------- 1 | export interface IUser { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | } 7 | 8 | export interface IProfile extends IUser { 9 | email: string; 10 | token: string; 11 | } 12 | 13 | export interface IArticle { 14 | slug: string; 15 | title: string; 16 | description: string; 17 | body: string; 18 | createdAt: Date; 19 | updatedAt: Date; 20 | favorited: boolean; 21 | favoritesCount: number; 22 | author: IUser; 23 | tagList: Array10 |
{`_html:${marked(comment.body)}`}
11 | 12 |{`_html:${marked(article.body)}`}
42 | 50 |\n
{`_html:${marked(comment.body)}`}
\n \n{`_html:${marked(article.body)}`}
\n \n