├── .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 |{auth.name}
36 | 37 | 38 |{new Date(post.date).toDateString()}
39 |{cat.name}
50 | 51 | {/if} 52 | {/each} 53 | {/each} 54 |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 |{com.author_name}
47 |{new Date(com.date).toDateString()}
48 |51 | {@html com.content.rendered} 52 |
53 |loading...
42 | {/each} 43 |{auth.name}
56 | 57 | 58 |{new Date(post.date).toDateString()}
59 |{cat.name}
70 | 71 | {/if} 72 | {/each} 73 | {/each} 74 |79 | {@html post.excerpt.rendered} 80 |
81 |loading...
85 |