Skip to content

Commit

Permalink
Use elderjs to allow for SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Dec 16, 2023
1 parent 942da6a commit 17bb5a3
Show file tree
Hide file tree
Showing 55 changed files with 19,427 additions and 889 deletions.
13 changes: 13 additions & 0 deletions app/frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[package.json]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions app/frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
public/
/___ELDER___/
20 changes: 20 additions & 0 deletions app/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: {
node: true,
commonjs: false,
es2020: true,
},
plugins: ['prettier'],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],

rules: {
'prettier/prettier': 'error',
semi: ['error', 'always'],
'no-var': ['error'],
'no-console': ['off'],
'no-unused-vars': ['warn'],
'no-mixed-spaces-and-tabs': ['warn'],
'node/no-unpublished-require': ['off'],
},
};
28 changes: 4 additions & 24 deletions app/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
/___ELDER___/
/node_modules/
/public/
/build/
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.svelte-kit
11 changes: 11 additions & 0 deletions app/frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"svelteSortOrder": "scripts-styles-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": false,
"svelteAllowShorthand": true,
"svelteIndentScriptAndStyle": true
}
5 changes: 5 additions & 0 deletions app/frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"systemjs"
]
}
21 changes: 21 additions & 0 deletions app/frontend/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Elder Guide LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 39 additions & 28 deletions app/frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
<table>
<tr>
<td>
<a href="https://www.amazon.com/dp/B08D6T6BKS/"><img src="https://static.packt-cdn.com/products/9781839213625/cover/smaller" width="120" /></a>
</td>
<td>
<h3>Svelte 3 Up and Running</h3>
<p>Want to learn Svelte 3 and how to build a Single-Page App (SPA) with it (and with this router)? Check out my book <a href="https://www.amazon.com/dp/B08D6T6BKS/">Svelte 3 Up and Running</a> on Amazon.</p>
</td>
</table>
# Elder.js Template Project

# Svelte app with svelte-spa-router
<img src="https://img.shields.io/badge/dynamic/json?color=brightgreen&label=Node&query=engines.node&url=https%3A%2F%2Fraw.githubusercontent.com%2Felderjs%2Ftemplate%2Fmaster%2Fpackage.json" alt="node version" />

This is a project template for [Svelte 4](https://svelte.dev) apps that includes [svelte-spa-router](https://github.com/italypaleale/svelte-spa-router) for client-side routing, TypeScript, and Vite as bundler.
This is a project template for [Elder.js](https://elderguide.com/tech/elderjs/) apps. The template lives at https://github.com/elderjs/template and the Elder.js source is here: https://github.com/elderjs/elderjs

## About svelte-spa-router
Here is a demo of the template: [https://elderjs.pages.dev/](https://elderjs.pages.dev/)

svelte-spa-router is a client-side router for Svelte 4 apps that leverages hash-based routing (i.e. stores the current view in the URL after the `#` symbol).
## Get started

You can read more about the router, and the reasons why you might want to use hash-based routing (or not), in the [documentation](https://github.com/italypaleale/svelte-spa-router).
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):

## Get started
```bash
npx degit Elderjs/template elderjs-app
cd elderjs-app
```

Install the dependencies
### Install the dependencies:

```bash
cd svelte-app
npm install
npm install # or just yarn
```

…then start a dev server using [Vite](https://vite.dev):
### Start Project:

```bash
npm run dev
npm start # or npm run dev
```

Navigate to [http://localhost:5050](http://localhost:5050). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
Navigate to [localhost:3000](http://localhost:3000). You should see your app running.

You can add more routes by defining them in the [`src/routes.ts`](./src/routes.ts) file. More information can be found on the [documentation for svelte-spa-router](https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/README.md).
This spawns a development server, so simply edit a file in `src`, save it, and reload the page to see your changes.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `vite` commands in package.json to include the option `--host 0.0.0.0`.
You can also see a live demo of this template: [https://elderjs.pages.dev/](https://elderjs.pages.dev/)

If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
#### What to Expect

## Building and running in production mode
- A dev server is watching your files for changes. It will restart when it needs to.
- Rollup is watching your files for changes. It will restart when it needs to.
- If your `elder.config.js` has `@elderjs/plugin-browser-reload': {}` in it's plugins, your browser will automatically restart after the server restarts.

To create an optimized version of the app:
**esbuild**

If you are looking for a faster development experience run `npm run esbuild` this is experimental but will be improving rapidly.

### To Build HTML for Production:

```bash
npm run build
```

You can run the newly-built app with `npm run preview`.
Let the build finish. It will put all of your statically generated files in `./public`.

If you wish to preview you can use:

```bash
npx sirv-cli public
```

### To Run in SSR Mode for Production:

```bash
npm run serve
```
30 changes: 30 additions & 0 deletions app/frontend/assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.code,
code {
padding: 0 0.25rem;
background: #eee;
border-radius: 3px;
margin-right: 0.5rem;
font-family: monospace;
display: inline-block;
}

h1,
h2,
h3,
h4 {
font-family: Georgia, 'Times New Roman', Times, serif;
font-weight: bold;
line-height: 2.35rem;
}

body {
margin: 0;
font-size: 16px;
line-height: 22px;
color: #06395a;
border-top: 10px solid #06395a;
padding-top: 2rem;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
'Helvetica Neue', sans-serif;
background: #f4f7fb;
}
40 changes: 40 additions & 0 deletions app/frontend/elder.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require('dotenv').config();
module.exports = {
origin: 'https://example.com', // TODO: update this. The URL of your site's root, without a trailing slash
lang: 'en',
srcDir: 'src',
distDir: 'public',
rootDir: process.cwd(),
build: {},
prefix: '', // If you want your site to be built within a sub folder within your `distDir` you can use this.
server: {},
props: {
hydration: 'hybrid',
compress: false,
},
debug: {
stacks: false, // output details of the stack consolidation process.
hooks: false, // outputs the details of each hook as they are run.
performance: false, // outputs a full performance report of how long it took to run each page.
build: false, // gives additional details about the build process.
automagic: false,
},
hooks: {
// disable: ['elderWriteHtmlFileToPublic'], // this is used to disable internal hooks. Uncomment this hook to disabled writing your files during build.
},
plugins: {
'@elderjs/plugin-markdown': {
routes: ['blog'],
},
'@elderjs/plugin-browser-reload': {
// this reloads your browser when nodemon restarts your server.
port: 8080,
reload: true, // if you are having issues with reloading not working, change to true.
},
'@elderjs/plugin-seo-check': {
display: ['errors', 'warnings'], // If the errors are too verbose remove 'warnings'
//writeLocation: './report.json', // if you want to write a report of errors
},
},
shortcodes: { closePattern: '}}', openPattern: '{{' },
};
Loading

0 comments on commit 17bb5a3

Please sign in to comment.