├── .env ├── .gitignore ├── functions.php ├── public ├── favicon.png ├── index.html └── global.css ├── src ├── main.js ├── components │ ├── Footer.svelte │ ├── Header.svelte │ ├── PageView.svelte │ ├── Comments.svelte │ └── ListPost.svelte ├── stores │ ├── info │ │ └── store.js │ ├── author │ │ └── store.js │ └── category │ │ └── store.js ├── containers │ ├── Blog.svelte │ ├── Page.svelte │ ├── Author.svelte │ └── Category.svelte └── App.svelte ├── style.css ├── package.json ├── rollup.config.js ├── README.md └── index.php /.env: -------------------------------------------------------------------------------- 1 | SITE=https://blog.korolr.me 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | public/bundle.* 4 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | 2 |

3 | Site by korolr. 4 | Frontend this site 5 |

6 | 7 | -------------------------------------------------------------------------------- /src/stores/info/store.js: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | 3 | export const info = writable({}, function start(set) { 4 | fetch(process.env.SITE + "/wp-json/") 5 | .then(function(response) { 6 | return response.json(); 7 | }) 8 | .then(function(response) { 9 | set(response); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/stores/author/store.js: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | 3 | export const author = writable([], function start(set) { 4 | fetch(process.env.SITE + "/wp-json/wp/v2/users/") 5 | .then(function(response) { 6 | return response.json(); 7 | }) 8 | .then(function(response) { 9 | set(response); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/stores/category/store.js: -------------------------------------------------------------------------------- 1 | import { writable } from "svelte/store"; 2 | 3 | export const category = writable([], function start(set) { 4 | fetch(process.env.SITE + "/wp-json/wp/v2/categories") 5 | .then(function(response) { 6 | return response.json(); 7 | }) 8 | .then(function(response) { 9 | set(response); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/components/Header.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | {#if info.name !== undefined} 14 | 15 |

{info.name}

16 | 17 | 18 |

{info.description}

19 | {/if} 20 | -------------------------------------------------------------------------------- /src/containers/Blog.svelte: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /*! 2 | Theme Name: R2D2 React 3 | Theme URI: https://www.justinwhall.com 4 | Author: Justin W. Hall 5 | Author URI: https://www.justinwhall.com 6 | Description: A react-based theme, bringing single-page app goodness to your WordPress blog! 7 | Tags: blog, one-column, accessibility-ready, featured-images 8 | Version: 0.9.0 9 | License: GNU General Public License v2 or later 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | Text Domain: r2d2-react 12 | View the full source of this theme on Github: https://github.com/justinwhall/r2d2 13 | */ 14 | 15 | /* This file is not used for style, just for theme info for WordPress*/ 16 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Svelte app 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog-wordpress-svelte", 3 | "version": "1.0.0", 4 | "devDependencies": { 5 | "npm-run-all": "^4.1.5", 6 | "rollup": "^1.10.1", 7 | "rollup-plugin-commonjs": "^10.0.0", 8 | "rollup-plugin-livereload": "^1.0.0", 9 | "rollup-plugin-node-resolve": "^5.0.0", 10 | "rollup-plugin-svelte": "^5.0.3", 11 | "rollup-plugin-terser": "^5.0.0", 12 | "sirv-cli": "^0.4.0", 13 | "svelte": "^3.4.2", 14 | "dotenv": "^8.0.0", 15 | "rollup-plugin-dotenv": "^0.2.0" 16 | }, 17 | "scripts": { 18 | "build": "rollup -c", 19 | "autobuild": "rollup -c -w", 20 | "dev": "run-p start:dev autobuild", 21 | "start": "sirv public", 22 | "start:dev": "sirv public --dev" 23 | }, 24 | "dependencies": { 25 | "svero": "^0.5.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /public/global.css: -------------------------------------------------------------------------------- 1 | .row-cen { 2 | flex-direction: column !important; 3 | align-items: center; 4 | } 5 | 6 | .rev { 7 | display: flex; 8 | flex-direction: row-reverse; 9 | } 10 | 11 | * { 12 | margin: 0; 13 | padding: 0; 14 | } 15 | html, 16 | body { 17 | height: 100%; 18 | } 19 | .wrapper { 20 | display: flex; 21 | flex-direction: column; 22 | height: 100%; 23 | } 24 | .content { 25 | flex: 1 0 auto; 26 | } 27 | .footer { 28 | flex: 0 0 auto; 29 | } 30 | 31 | .row-footer { 32 | display: flex; 33 | flex-direction: column; 34 | padding: 0; 35 | width: 100%; 36 | } 37 | 38 | body { 39 | background-color: #fdf6e3; 40 | } 41 | 42 | a { 43 | color: #268bd2 !important; 44 | } 45 | 46 | button { 47 | background-color: #586e75 !important; 48 | } 49 | 50 | pre { 51 | background: #f4f5f6; 52 | border-left: 0.3rem solid #268bd2 !important; 53 | overflow-y: hidden; 54 | } 55 | -------------------------------------------------------------------------------- /src/App.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 | 28 |
29 |
30 | -------------------------------------------------------------------------------- /src/containers/Page.svelte: -------------------------------------------------------------------------------- 1 | 27 | 28 | {#if data.title} 29 | 30 | 31 | {/if} 32 | -------------------------------------------------------------------------------- /src/containers/Author.svelte: -------------------------------------------------------------------------------- 1 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/containers/Category.svelte: -------------------------------------------------------------------------------- 1 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/components/PageView.svelte: -------------------------------------------------------------------------------- 1 | 8 | 9 | 26 | 27 |

{post.title.rendered}

28 | 29 |
30 | {#each $author as auth} 31 | {#if post.author === auth.id} 32 |
33 |
34 | 35 |

{auth.name}

36 | 37 | 38 |

{new Date(post.date).toDateString()}

39 |
40 |
41 | {/if} 42 | {/each} 43 |
44 |
45 | {#each post.categories as id_cat} 46 | {#each $category as cat} 47 | {#if id_cat === cat.id} 48 | 49 |

{cat.name}

50 | 51 | {/if} 52 | {/each} 53 | {/each} 54 |
55 |
56 |
57 | 58 |

59 | {@html post.content.rendered} 60 |

61 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import svelte from "rollup-plugin-svelte"; 2 | import resolve from "rollup-plugin-node-resolve"; 3 | import commonjs from "rollup-plugin-commonjs"; 4 | import livereload from "rollup-plugin-livereload"; 5 | import dotenv from "rollup-plugin-dotenv"; 6 | import { terser } from "rollup-plugin-terser"; 7 | 8 | const production = !process.env.ROLLUP_WATCH; 9 | 10 | export default { 11 | input: "src/main.js", 12 | output: { 13 | sourcemap: true, 14 | format: "iife", 15 | name: "app", 16 | file: "public/bundle.js" 17 | }, 18 | plugins: [ 19 | svelte({ 20 | // enable run-time checks when not in production 21 | dev: !production, 22 | // we'll extract any component CSS out into 23 | // a separate file — better for performance 24 | css: css => { 25 | css.write("public/bundle.css"); 26 | } 27 | }), 28 | 29 | // If you have external dependencies installed from 30 | // npm, you'll most likely need these plugins. In 31 | // some cases you'll need additional configuration — 32 | // consult the documentation for details: 33 | // https://github.com/rollup/rollup-plugin-commonjs 34 | resolve(), 35 | commonjs(), 36 | dotenv(), 37 | // Watch the `public` directory and refresh the 38 | // browser on changes when not in production 39 | !production && livereload("public"), 40 | 41 | // If we're building for production (npm run build 42 | // instead of npm run dev), minify 43 | production && terser() 44 | ], 45 | watch: { 46 | clearScreen: false 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deploy 2 | 3 | 1. Clone this rep 4 | 2. Change env to tou url 5 | 3. Build 6 | 7 | ```bash 8 | npm i 9 | npm run build 10 | ``` 11 | 12 | 4. Send folder to server 13 | 14 | _Psst — looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)_ 15 | 16 | --- 17 | 18 | # svelte app 19 | 20 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template. 21 | 22 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit): 23 | 24 | ```bash 25 | npx degit sveltejs/template svelte-app 26 | cd svelte-app 27 | ``` 28 | 29 | _Note that you will need to have [Node.js](https://nodejs.org) installed._ 30 | 31 | ## Get started 32 | 33 | Install the dependencies... 34 | 35 | ```bash 36 | cd svelte-app 37 | npm install 38 | ``` 39 | 40 | ...then start [Rollup](https://rollupjs.org): 41 | 42 | ```bash 43 | npm run dev 44 | ``` 45 | 46 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes. 47 | 48 | ## Deploying to the web 49 | 50 | ### With [now](https://zeit.co/now) 51 | 52 | Install `now` if you haven't already: 53 | 54 | ```bash 55 | npm install -g now 56 | ``` 57 | 58 | Then, from within your project folder: 59 | 60 | ```bash 61 | now 62 | ``` 63 | 64 | As an alternative, use the [Now desktop client](https://zeit.co/download) and simply drag the unzipped project folder to the taskbar icon. 65 | 66 | ### With [surge](https://surge.sh/) 67 | 68 | Install `surge` if you haven't already: 69 | 70 | ```bash 71 | npm install -g surge 72 | ``` 73 | 74 | Then, from within your project folder: 75 | 76 | ```bash 77 | npm run build 78 | surge public 79 | ``` 80 | -------------------------------------------------------------------------------- /src/components/Comments.svelte: -------------------------------------------------------------------------------- 1 | 32 | 33 | 38 | 39 | {#if comments.length > 0} 40 |

{comments.length} comments

41 | 42 | {#each comments as com} 43 |
44 |
45 | 46 |

{com.author_name}

47 |

{new Date(com.date).toDateString()}

48 |
49 |
50 |

51 | {@html com.content.rendered} 52 |

53 |
54 |
55 | {/each} 56 | {:else} 57 |

Not comments

58 | {/if} 59 | 60 |

Write comment

61 | 62 | {#if error !== ''} 63 |

{error}

64 | {/if} 65 | 66 |
67 | 72 | 77 |