Code Monkey home page Code Monkey logo

www-1's Introduction

✍️ πŸ’» πŸ‘‹

Source code for my blog.

Overview

Next is used as a static site generator. Pages call the network service that triggers persistence to read a post or a project from an MDX file in the storage directory.

Translation dictionary collection, RSS generation and image optimization are performed by custom scripts located in ops. For optimizing images, Squoosh is used.

Jest is used as a test runner and Hygen as a code generator.

Deployed on static servers using GitHub Actions.

Installation

Clone the repo and install dependencies:

git clone https://github.com/bespoyasov/www.git
cd www

npm install

Development

For starting the development mode, run:

npm start

This command will start 3 daemons in parallel:

  • Next dev server for En version on 2001 port;
  • Next dev server for Ru version on 2002 port;
  • Translation dictionary watcher for live-updates of localization data.

Code Generation

To create a component, post, or a page, run:

npm run new:component
npm run new:post
npm run new:page

# After hitting any of these commands,
# an interactive CLI will guide you.

Testing

To run the tests while developing:

npm run test:dev

To run all tests once:

npm test

The latter command is also used in CI.

Project Build

The project can be built in 2 different languages:

npm run build:en
npm run build:ru

After the build, Next exports the generated site sources into the out directory. Then the static resources are cleaned up to contain only the media related to the current build locale. In the end, RSS is generated.

As a result, you will find sources for a static website in the out directory that can be deployed.

Devops

For operations that aren't included in Next by default, custom ops scripts are used.

Image Optimization

To optimize images in public/images using Squoosh, run:

npm run images:convert

Next's Image component doesn't support optimizations when using SSG, hence this script.

Also, generated images are kept in the repository to avoid too long deployments. Since all images require optimizations, without this every update would last for tens of minutes.

Translation

Instead of using a third-party library and a localization service, the custom translation β€œlibrary” is used.

It collects data from translations.json files in the src directory and creates a translation dictionary. Except the resulting dictionary, the script also creates the type definitions for the dictionary. The typings improve the IDE support and autocompletion.

To collect translations, run:

npm run dict:collect

This command is also run automatically after installing the dependencies and before project start and build.

To set up a watcher over the translation data that updates the dictionary on every translations.json file change, run:

npm run dict:watch

This command is run automatically before start of the project.

Plans and TODOs

Everything I consider implementing is located in the projects section on GitHub. If you have an idea of an improvement, please, let me know in the project issues.

License

The source code is distributed under the GNU GPL v3.0 license. You can use, modify, and redistribute it as long as you keep the license and disclose the source.

The content of the site is distributed under the CC BY-NC-SA 4.0 license. You can use and modify it as long as you mention the source and author, keep the license, and don't use the content in a commercial product.

www-1's People

Contributors

bespoyasov avatar sm1t avatar jblarriviere avatar verner-vladislav23 avatar zorin-e avatar grigorykazakov avatar notiv-nt avatar n1k1ta42 avatar bazai avatar vitalybaev avatar dotcypress avatar tetenyov avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.