Skip to content

Commit

Permalink
Refactor package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Jieiku committed Sep 8, 2023
1 parent 288de9d commit 5e55301
Show file tree
Hide file tree
Showing 48 changed files with 489 additions and 181 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ themes
build
storage
node_modules
package-lock.json
static/demo.html
static/tinysearch_engine.js
static/tinysearch_engine.d.ts
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ The Abridge.css demo is simply using Abridge theme as a submodule: [config.toml]
## Features

- [X] Perfect [Lighthouse](https://pagespeed.web.dev/report?url=abridge.netlify.app), [YellowLabTools](https://yellowlab.tools/), and [Observatory](https://observatory.mozilla.org/analyze/abridge.netlify.app) scores.
- [X] [PWA support](#pwa-progressive-web-app) (Progressive Web Application).
- [X] [PWA support](https://abridge.netlify.app/overview-abridge/#pwa-progressive-web-app) (Progressive Web Application).
- [X] All JavaScript can be [fully disabled](https://abridge.netlify.app/overview-abridge/#javascript-files).
- [X] Dark, Light, Auto, and Switcher themes. (colors can be customized, css variables)
- [X] Code [syntax highlighting](https://abridge.netlify.app/overview-code-blocks/). (colors can be customized, css variables)
- [X] Numbered code blocks with [line highlighting](https://abridge.netlify.app/overview-code-blocks/#toml).
- [X] Entirely Offline Site by using the PWA **or** by setting `offline = true` in `config.toml` (full search support).
- [X] Multi-language support.
- [X] Search support. (elasticlunr, tinysearch, stork)
- [X] Search Suggestions navigation keys, `/` focus, `arrow` move, `enter` select, `escape` close.
- [X] Search Results Page, type search query then hit `Enter Key` or `click` the search button icon.
- [X] [SEO](#seo-and-header-tags) support. (Search Engine Optimization)
- [X] [Pagination](#pagination) with numbered paginator on index.
- [X] [SEO](https://abridge.netlify.app/overview-abridge/#seo-and-header-tags) support. (Search Engine Optimization)
- [X] [Pagination](https://abridge.netlify.app/overview-abridge/#pagination) with numbered paginator on index.
- [X] Title Based Previous and Next Article links at bottom of Article.
- [X] Table of Contents in page Index (Optional, clickable links)
- [X] Recent Posts Block. (Optional)
Expand All @@ -50,6 +51,8 @@ The Abridge.css demo is simply using Abridge theme as a submodule: [config.toml]
- [X] Media Shortcodes: [video](https://abridge.netlify.app/overview-rich-content/#video), [img](https://abridge.netlify.app/overview-images/#img-shortcode), [imgswap](https://abridge.netlify.app/overview-images/#imgswap-shortcode), [image](https://abridge.netlify.app/overview-rich-content/#image), [gif](https://abridge.netlify.app/overview-rich-content/#gif), [audio](https://abridge.netlify.app/overview-rich-content/#audio).
- [X] Other Shortcodes: [showdata](https://abridge.netlify.app/overview-showdata/), [katex](https://abridge.netlify.app/overview-math/#usage-1).

**[Complete Documentation is availabe here](https://abridge.netlify.app/overview-abridge/)**

## Quick Start

This theme requires version 0.17.2 or later of [Zola](https://www.getzola.org/documentation/getting-started/installation/)
Expand Down Expand Up @@ -97,17 +100,17 @@ rsync themes/abridge/config.toml config.toml
rsync themes/abridge/content/_index.md content/
rsync themes/abridge/COPY-TO-ROOT-SASS/* sass/
rsync themes/abridge/netlify.toml netlify.toml
rsync themes/abridge/package_abridge.js package_abridge.js
rsync themes/abridge/package.json package.json
rsync -r themes/abridge/content/static content/
```

- `templates/.gitkeep` the templates directory is required in your base site. [#2150](https://github.com/getzola/zola/issues/2150)
- `config.toml` base configuration with all config values.
- `content/_index.md` required to set pagination.
- `COPY-TO-ROOT-SASS/abridge.scss` overrides to customize Abridge variables.
- `netlify.toml` settings to deploy your repo with netlfiy.
- `package_abridge.js` node script to: update cache files list in PWA, minify js, bundle js
- `package.json` to switch between nosearch, elasticlunr, tinysearch, stork.
- `content/static` files for generating tinysearch and stork indexes.

Uncomment the theme line in your project's root config.toml:

Expand Down
68 changes: 42 additions & 26 deletions config.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# do NOT include a trailing slash on the base URL
base_url = "https://abridge.netlify.app"

#base_url = "/home/jieiku/.dev/abridge/public" # Usable site directly from disk, Including Search!
# Also set index_format = "elasticlunr_javascript", and in [extra] uglyurls = true, integrity = false, js_bundle = false
base_url="https://abridge.netlify.app"
# Usable site directly from disk, Including Search: "/home/jieiku/.dev/abridge/public"
# Also set index_format = "elasticlunr_javascript", and in [extra] uglyurls = true, integrity = false
# If you use the npm/node script then all you have to do is set offline = true, and everything else is automatic.

title = "Abridge"
description = "Abridge is a fast and lightweight Zola theme using semantic html, abridge.css class-light CSS, and No Mandatory JS."
default_language = "en"
#theme = "abridge"

default_language = "en"
compile_sass = true
minify_html = false
build_search_index = true
Expand All @@ -22,7 +23,21 @@ taxonomies = [
#ignored_content = ["*.{graphml,xlsx}", "temp.*"]
#hard_link_static = false # set to true to hard link instead of copying, useful for very large files.

#theme = "abridge"
[search] # Options specific to elasticlunr search.
index_format = "elasticlunr_json" # elasticlunr_json, elasticlunr_javascript
include_title = true # include title of page/section in index
include_description = true # include description of page/section in index
include_content = true # include rendered content of page/section in index
# truncate_content_length = 100 # Truncate at nth character. May be useful if index is getting too large.

[markdown]
highlight_code = true
highlight_theme = "css"
render_emoji = false
external_links_target_blank = true # rel="noopener"
external_links_no_follow = false # rel="nofollow"
external_links_no_referrer = false # rel="noreferrer"
smart_punctuation = false # `...` to `…`, `"quote"` to `“curly”` etc

# Any Extra language you do not use, delete or comment out the extra language sections:
[languages.fr]
Expand Down Expand Up @@ -63,22 +78,6 @@ copyright_override = '© $CURRENT_YEAR $SITE_TITLE • Le contenu du site Web es
#[languages.es.translations]
#flag = "🇪🇸"

[search] # Options specific to elasticlunr search.
index_format = "elasticlunr_json" # elasticlunr_json, elasticlunr_javascript
include_title = true # include title of page/section in index
include_description = true # include description of page/section in index
include_content = true # include rendered content of page/section in index
# truncate_content_length = 100 # Truncate at nth character. May be useful if index is getting too large.

[markdown]
highlight_code = true
highlight_theme = "css"
render_emoji = false
external_links_target_blank = true # rel="noopener"
external_links_no_follow = false # rel="nofollow"
external_links_no_referrer = false # rel="noreferrer"
smart_punctuation = false # `...` to `…`, `"quote"` to `“curly”` etc

[extra]
###############################################################################
### Language
Expand Down Expand Up @@ -113,7 +112,7 @@ menu_footer = [
]

recent = true # TOC / index
recent_items = 12
recent_items = 15

meta_index = { position="bottom", size="s90", author=false, readtime=false, readstring="min", date=true, updated=false, categories_tags=true, divider=" " }
meta_post = { position="top", size="s95", author=true, readtime=false, readstring="min read", date=true, updated=true, categories_tags=true, divider=" " }
Expand Down Expand Up @@ -202,9 +201,26 @@ researchgate = "your-profile-id"
### Resource Files
### You can load extra css files if you need to, just separate by comma:
### stylesheets = [ "abridge.css", "extra.css" ]
### search_library: library to use, valid values: false, "elasticlunr", "tinysearch", "stork"
### search_library, library to use. valid values:
### false, "elasticlunr", "tinysearch", "stork"
### offline: implies uglyurls=true and integrity=false, when true NPM/node will
### automatically set the path for the base_url, it will build the site,
### then set the base_url back to what it was. This is a way to build a completely
### offline site, a feature not possible with Zola alone.
### The PWA feature is another way to build an offline site, so there are now two
### different ways to build an offline site with Abridge.
###
### For most people the value of online_url will be the same as base_url.
### online_url is used to restore the base_url after generating an Offline site.
### When you set offline = true and run the npm script, the base_url is set to the absolute path on disk.
### Once you set offline = false, the base_url will be set back to the value of online_url when you run the npm script again.

###############################################################################

# do NOT include a trailing slash on the online URL
online_url="https://abridge.netlify.app"
offline = false # implies uglyurls=true and integrity=false, when true NPM/node will automatically set the path for the base_url, it will build the site, then set the base_url back to what it was.

uglyurls = false # if set to true then links are generated with the full path. eg https://abridge.netlify.app/index.html
integrity = true # increases site security, should normally be true. (setting to false is useful during js development)
js_bundle = true # multiple javascript files combined into a single file (setting to false is useful during js development)
Expand All @@ -219,7 +235,7 @@ search_library = 'elasticlunr'
stylesheets = ["abridge.css"]

pwa = true # true to load the service worker
webmanifest = "manifest.json" # Required for PWAs
webmanifest = "manifest.min.json" # Required for PWAs

###############################################################################
### Favicons, comment out a line to disable loading some or all of these if needed.
Expand Down Expand Up @@ -277,7 +293,7 @@ favicon16 = "favicon-16x16.png" # favicon-16x16.png

#security_header_referrer = "strict-origin-when-cross-origin"

#security_header_csp = "default-src 'none'; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; manifest-src 'self'; connect-src 'self'; form-action 'self'; script-src 'self'; img-src 'self' data: cdn.cloudflare.com; frame-src 'self' www.youtube-nocookie.com player.vimeo.com; media-src 'self' data: cdn.cloudflare.com www.youtube-nocookie.com player.vimeo.com; font-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.gstatic.com; style-src 'self' 'unsafe-inline' cdn.cloudflare.com cdn.jsdelivr.net fonts.googleapis.com;"
#security_header_csp = "default-src 'none'; object-src 'none'; base-uri 'self'; manifest-src 'self'; connect-src 'self'; form-action 'self'; script-src 'self'; img-src 'self' data: cdn.cloudflare.com; frame-src 'self' www.youtube-nocookie.com player.vimeo.com; media-src 'self' data: cdn.cloudflare.com www.youtube-nocookie.com player.vimeo.com; font-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.gstatic.com; style-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.googleapis.com;"


###############################################################################
Expand Down
18 changes: 8 additions & 10 deletions content/overview-abridge/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Un thème [Zola](https://getzola.org) rapide, léger et moderne utilisant [abrid
- [X] Thèmes sombre, clair, automatique et Switcher. (les couleurs peuvent être personnalisées, variables CSS)
- [X] Code [surlignage de la syntaxe](https://abridge.netlify.app/overview-code-blocks/). (les couleurs peuvent être personnalisées, variables CSS)
- [X] Blocs de code numérotés avec [mise en évidence des lignes](https://abridge.netlify.app/overview-code-blocks/#toml).
- [X] Site entièrement hors ligne en utilisant la PWA **ou** en définissant `offline = true` dans `config.toml` (prise en charge complète de la recherche).
- [X] Prise en charge multilingue.
- [X] Aide à la recherche. (elasticlunr, tinysearch, cigogne)
- [X] Suggestions de recherche touches de navigation, focus `/`, déplacement `flèche`, sélection `entrée`, fermeture `évasion`.
Expand Down Expand Up @@ -95,17 +96,17 @@ rsync themes/abridge/config.toml config.toml
rsync themes/abridge/content/_index.md content/
rsync themes/abridge/COPY-TO-ROOT-SASS/* sass/
rsync themes/abridge/netlify.toml netlify.toml
rsync themes/abridge/package_abridge.js package_abridge.js
rsync themes/abridge/package.json package.json
rsync -r themes/abridge/content/static content/
```

- `templates/.gitkeep` le répertoire des modèles est requis dans votre site de base. [#2150](https://github.com/getzola/zola/issues/2150)
- `config.toml` configuration de base avec toutes les valeurs de configuration.
- `content/_index.md` requis pour définir la pagination.
- `COPY-TO-ROOT-SASS/abridge.scss` remplace pour personnaliser les variables Abridge.
- `netlify.toml` paramètres pour déployer votre dépôt avec netlify
- `package_abridge.js` script de nœud pour: mettre à jour la liste des fichiers de cache dans PWA, réduire js, regrouper js
- `package.json` pour basculer entre nosearch, elasticlunr, tinysearch, stork.
- `content/static` fichiers pour générer des index tinysearch et stork.

Décommentez la ligne de thème dans le fichier racine config.toml de votre projet:
```bash
Expand Down Expand Up @@ -275,7 +276,7 @@ Si vous utilisez Chrome sur un ordinateur de bureau, regardez à la fin de la ba

Pour l'utiliser dans votre propre instance, vous devrez éditer `static/sw.js` pour la liste des fichiers à mettre en cache. Techniquement, vous n'avez pas besoin de modifier `sw.js`, mais si même un seul fichier est manquant dans la liste de cache, la liste ne sera pas pré-mise en cache, elle ne sera donc mise en cache que pendant votre navigation.

Il existe un script npm pour générer la liste de cache de fichiers et la minification `npm run pwa`. Mon fichier `netlify.toml` exécute automatiquement ce script npm lors du déploiement du site, donc tout est automatique. Si Zola était capable de modéliser un fichier js, il serait peut-être possible de générer dynamiquement la liste des fichiers cache lors de la construction.
Il existe un script npm pour générer la liste de cache de fichiers et la minification `npm run abridge`. Mon fichier `netlify.toml` exécute automatiquement ce script npm lors du déploiement du site, donc tout est automatique. Si Zola était capable de modéliser un fichier js, il serait peut-être possible de générer dynamiquement la liste des fichiers cache lors de la construction.

La fonctionnalité PWA est également facile à désactiver en définissant simplement `pwa = false` dans `config.toml`

Expand Down Expand Up @@ -310,16 +311,13 @@ Voici les fichiers javascript utilisés par Abridge :

#### option js_bundle

`js_bundle` lorsqu'il est défini sur true, il sert un fichier bundle au lieu de tous les fichiers js individuels.
`js_bundle` lorsqu'il est défini sur true sert un fichier bundle au lieu de tous les fichiers js individuels.
Tous les bundles sont définis dans [package.json](https://github.com/Jieiku/abridge/blob/master/package.json)
Tous les bundles nécessaires sont générés dynamiquement par le script de nœud [package_abridge.js](https://github.com/Jieiku/abridge/blob/master/package_abridge.js)
Un Bundle peut être généré à partir des scripts package.json en utilisant npm:
Le script de nœud analysera votre config.toml pour rechercher les valeurs de configuration pertinentes, puis, en fonction de votre config.tomnl, générera les bundles requis.
- `npm run nosearch` - génère un bundle sans recherche.
- `npm run elasticlunr` - génère un bundle de tous les js avec elasticlunr.
- `npm run tinysearch` - génère un bundle de tous les js avec tinysearch.
- `npm run stork` - génère un bundle de tous les js avec stork.
Tout ce qui est nécessaire est `zola build && npm run abridge`.
#### Changer de bibliothèque de recherche
Expand Down
16 changes: 7 additions & 9 deletions content/overview-abridge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A fast, lightweight, and modern [Zola](https://getzola.org) theme utilizing [abr
- [X] Dark, Light, Auto, and Switcher themes. (colors can be customized, css variables)
- [X] Code [syntax highlighting](https://abridge.netlify.app/overview-code-blocks/). (colors can be customized, css variables)
- [X] Numbered code blocks with [line highlighting](https://abridge.netlify.app/overview-code-blocks/#toml).
- [X] Entirely Offline Site by using the PWA **or** by setting `offline = true` in `config.toml` (full search support).
- [X] Multi-language support.
- [X] Search support. (elasticlunr, tinysearch, stork)
- [X] Search Suggestions navigation keys, `/` focus, `arrow` move, `enter` select, `escape` close.
Expand Down Expand Up @@ -93,17 +94,17 @@ rsync themes/abridge/config.toml config.toml
rsync themes/abridge/content/_index.md content/
rsync themes/abridge/COPY-TO-ROOT-SASS/* sass/
rsync themes/abridge/netlify.toml netlify.toml
rsync themes/abridge/package_abridge.js package_abridge.js
rsync themes/abridge/package.json package.json
rsync -r themes/abridge/content/static content/
```

- `templates/.gitkeep` the templates directory is required in your base site. [#2150](https://github.com/getzola/zola/issues/2150)
- `config.toml` base configuration with all config values.
- `content/_index.md` required to set pagination.
- `COPY-TO-ROOT-SASS/abridge.scss` overrides to customize Abridge variables.
- `netlify.toml` settings to deploy your repo with netlfiy.
- `package_abridge.js` node script to: update cache files list in PWA, minify js, bundle js
- `package.json` to switch between nosearch, elasticlunr, tinysearch, stork.
- `content/static` files for generating tinysearch and stork indexes.

Uncomment the theme line in your project's root config.toml:

Expand Down Expand Up @@ -274,7 +275,7 @@ If using Chrome on desktop then look at the end of the address bar for the insta

To use it in your own instance you will need to edit `static/sw.js` for the list of files to cache. Technically you do not need to edit `sw.js`, but if even a single file in the cache list is missing then it wont pre cache the list, so it will only cache as you browse.

There is an npm script to generate the file cache list and minification `npm run pwa`. My `netlify.toml` file automatically runs this npm script during site deployment, so everything is automatic. If Zola was able to template a js file then it might be possible to generate the list of cache files dynamically at build.
There is an npm script to generate the file cache list and minification `npm run abridge`. My `netlify.toml` file automatically runs this npm script during site deployment, so everything is automatic. If Zola was able to template a js file then it might be possible to generate the list of cache files dynamically at build instead of relying on node/npm.

The PWA feature is also easy to disable by simply setting `pwa = false` in `config.toml`

Expand Down Expand Up @@ -311,14 +312,11 @@ These are the javascript files used by Abridge:

`js_bundle` when set to true serves a bundle file instead of all of the individual js files.

All Bundles are defined in [package.json](https://github.com/Jieiku/abridge/blob/master/package.json)
All necessary bundles are dynamically generated by the node script [package_abridge.js](https://github.com/Jieiku/abridge/blob/master/package_abridge.js)

A Bundle can be generated from the package.json scripts using npm:
The node script will scan your config.toml for relevant config values, and then based on your config.tomnl generate your required bundles.

- `npm run nosearch` - generates a bundle without search.
- `npm run elasticlunr` - generates a bundle of all js with elasticlunr.
- `npm run tinysearch` - generates a bundle of all js with tinysearch.
- `npm run stork` - generates a bundle of all js with stork.
All that is necessary is `zola build && npm run abridge`.

#### Switch Search Library

Expand Down
Loading

0 comments on commit 5e55301

Please sign in to comment.