0.0.69 • Published 25 days ago

astral-spg v0.0.69

Weekly downloads
-
License
-
Repository
-
Last release
25 days ago

ASTRAL - static pages generator

based on https://astro.build/

Requirements

npm version: 18.17

install

npm i astral-spg@latest

Scripts

npm run start: Opens a selected project in development server.

npm run build {PROJECT_NAME}: Creates a production build of the specified project.

npm run buildAll: Generates production builds for all projects in the projects folder.

Built-in features

Reset.css

import "astral-spg/reset.css";

import reset.css into layout component to reset default browser styles

Helpers

Importing:

import { helperName } from "astral-spg";
  1. debounce:

    Reduces the rate of function calls. Accepts a function and a delay in milliseconds.

Usage example:

import { debounce } from "astral-spg";
const debouncedFunction = debounce(() => console.log("Function call"), 200);
window.addEventListener("resize", debouncedFunction);
  1. isElementInView

    Checks if an HTML element is within the viewport. Returns true or false.

Usage example:

import { isElementInView } from "astral-spg";
const isVisible = isElementInView(document.getElementById("elementId"));

Custom Helpers and UI-Kit

Adding Custom Helpers and UI Elements

  • You can add your own helper functions or common UI elements by creating a ui-kit or helpers folder at the root folder. Importing
  • Utilize absolute imports to integrate these custom components or helpers into your project.

Example:

import Heading from "ui-kit/Heading/Heading.astro"; // should be an astro component
import { isDesktopView } from "helpers/helpers"; //should be js code
import Slider from "components/Slider/Slider.astro"; //should be an astro component

With this approach, you can easily extend the functionality of the Static Pages Generator by incorporating your own utilities and UI components, enhancing the customizability and versatility of your projects.

To include new folders (such as a shared folder for components or modules at the root) in absolute imports, you need to modify the tsconfig.json file located at the root of your project.

Working with Translations

Translations are stored in the translations folder within the project directory as JSON files. Additionally, you need to create a utility file responsible for importing these translation files, accepting the locale selected by the user, and returning the appropriate translation. An example of how to organize such a file can be found in the template_project, which is generated during the initial project setup.

Next, in your .astro file, you use this utility in the following manner, treating the object t as a standard JavaScript object with keys and values.

import { getLangSettings } from "path-to-your-translate-folder";
const { t } = getLangSettings(Astro.url);

In your .astro file, you can then use the t object to dynamically render translated text based on the user's locale. This approach ensures that your application can support multiple languages efficiently, adapting to the preferences of different users.

If your default language is different from English, pass it as the second argument:

const { localePrefix } = getLangSettings(Astro.url, "es");

Next, create a translations .json file in the translations folder, as well as a folder within the pages folder with the same name.

For example, if you need a Spanish version, the translations file can be named es, and a folder with the same name should be created within the pages folder to hold the files.

0.0.69

25 days ago

0.0.68

3 months ago

0.0.67

3 months ago

0.0.62

4 months ago

0.0.63

4 months ago

0.0.64

4 months ago

0.0.65

4 months ago

0.0.66

4 months ago

0.0.61

4 months ago

0.0.59

4 months ago

0.0.53

4 months ago

0.0.54

4 months ago

0.0.55

4 months ago

0.0.56

4 months ago

0.0.57

4 months ago

0.0.58

4 months ago

0.0.51

4 months ago

0.0.52

4 months ago

0.0.50

4 months ago

0.0.48

4 months ago

0.0.49

4 months ago

0.0.40

4 months ago

0.0.41

4 months ago

0.0.42

4 months ago

0.0.20

4 months ago

0.0.43

4 months ago

0.0.21

4 months ago

0.0.44

4 months ago

0.0.22

4 months ago

0.0.45

4 months ago

0.0.23

4 months ago

0.0.46

4 months ago

0.0.24

4 months ago

0.0.25

4 months ago

0.0.37

4 months ago

0.0.38

4 months ago

0.0.39

4 months ago

0.0.17

4 months ago

0.0.18

4 months ago

0.0.19

4 months ago

0.0.30

4 months ago

0.0.31

4 months ago

0.0.32

4 months ago

0.0.33

4 months ago

0.0.34

4 months ago

0.0.35

4 months ago

0.0.36

4 months ago

0.0.26

4 months ago

0.0.27

4 months ago

0.0.28

4 months ago

0.0.29

4 months ago

0.0.16

4 months ago

0.0.15

4 months ago

0.0.14

4 months ago

0.0.13

4 months ago

0.0.12

4 months ago

0.0.11

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago