astro_template_webpage
astro_template_webpage copied to clipboard
📦️ This repository that contains an Astro template ready for any website you can imagine. It's like a Swiss Army knife for developers, offering pre-built modules and flexible configurations to kickst...
Astro template webpage
📦 SETUP • ⚙️ CONFIGURATION • ️️️🛰️ FEATURES
About
|
Tired of sluggish websites and SEO headaches? Unleash the power of lightning-fast performance and built-in optimization with this Astro template builder! Crafted for developers who value speed and simplicity, this robust toolkit empowers you to build stunning websites that soar in search engines and captivate users. Ditch the struggle and focus on what matters most - crafting impactful content that drives engagement. Welcome to the future of web development - where SEO and performance work hand-in-hand.
(
|
Table of content
About
Features
Requirements
Installation
Configuration
- Site configuration
- Environment varaibles
- i18n configuration
Usage
Scripts
Browser support
(
Back to top
)
Features
Astro- Astro FrameworkTypescript- Extremely strict type checkingAbsolute imports- No more bad imports
Sass- Css framework for ui developmentBEMIT- Arquitecture for sassMobile firts- Best performance for cssReset- Reset css for match style between browsersJoin media queries- Join media queries for small file sizeVendor prefixes- Vendor prefixes for all supportRemove unused css- Remove unused css in build
Clean arquitecture- For clean code and scalablilitySEO- SEO meta data, open graph and moreSitemap- Sitemap generatorRSS- RSS generatorOpen graph- Advanced open graph SEORobot- Robot txt configurationCanonical- Auto canonical urlGoogle search console- For SEO stadisticsGoogle analytic- For analytics of the webpage
i18n- Internationalization and translationsLinter- Linter and formatting all kind of filesEslint- Litner and formatting ts and js filesStylelint- Linter css files
Git- Control version and moreGithub issue template- Github issues organizationGithooks- Git hook for validate code qualityChangelog- Changelog and realese for githubSematic release- Automatization of releases
Configuration- Vscode, env variables and moreVscode configuration- Vscode recommendations, extensions and moreEnv validation- Enviroment variables validationHtaccess snipets- Differents htaccess for all kind of situations
ComponentsImage- Ready to use optimize image componentShow- Ready to use conditional render componentFor- Ready to use for map componentsLink- Ready to use for redirect external and internal links
PerformanceWeb worker (partytown)- For lazy-loaded large librariesBundler analizer- Analize your bundle sizeCompress- Compress images, font, css, js, and htmlNon blocking- Non blocking js, css and moreFont optimization- Font transformation and declaration
Bun- Fast package managerPerfect lighthouse score- Because performance matters
(
Back to top
)
Requirements
node >= 20.10.0
git >= 2.38
bun >= 1.1.0
aws cli >= 2.17.8
(
Back to top
)
Installation
After cloning the repo run this command to install all the dependencies.
Bun
bun i
(
Back to top
)
Configuration
The configuration needed for this project is to set up the env variables and also the site configuration object here are the examples:
Site configuration
This file is located in src/global/configuration/site_configuration.ts
siteName- Global title of the webpagedescription- Global description of the webpageautor- Author object that appears in a meta tagauthor.name- Name of the authorauthor.email- Email of the authorauthor.web- Web of the author
copyright- Copyright of the owner of the websitegoogleAnalyticId- Id of the google analyticsdefaultLocale- Default locale of the webpagelanguages- Object with all the languages you want to supportexample-languages: { en: 'English' }
Evironment varaibles
This environment variables are located in src/global/env/**.env
file: .example.dev.env
PORT=4321
BASE_URL=http://localhost:$PORT
file: .example.prod.env
BASE_URL=
file: .example.staging.env
PORT=4321
BASE_URL=http://localhost:$PORT
i18n configuration
1.- To start using i18n in this project you have to add the languages you want to support in the configuration file src/global/configuration/site_configuration.ts, here you will find an object with the key languages, also remenber to ser the default language to your preferences, you can set the languages like this:
const siteConfiguration =
{
defaultLanguage: 'en',
languages:
{
en: 'English',
es: 'Español'
}
}
2.- Next you will create in the src/pages a directory called [language], here you will duplicate and put all the pages of your project, this is an example:
- /pages
- /[language]
- about-us.astro
- index.astro
- 404.astro
- about-us.astro
- index.astro
3.- The pages inside this directory will need to add an aditionnal validation for know if the language is correct and it is listeng in the configuration, you can add tis like this
pages/[language]/index.astro
---
import { getStaticLanguage } from '@global/util/language';
export const getStaticPaths = getStaticLanguage;
---
4.- Next you will create the translation files, we recommend to use ts files instead of json but you can aslo use json files
const aboutUsLocale =
{
en:
{
welcome: 'Hello world',
},
es:
{
welcome: 'Hola mundo',
}
};
export { aboutUsLocale };
5.- To end you will use this file and make the translation, use this inside you component page and not in the pages/** components
---
import { getI18n, getStaticLanguage, getLanguageFromUrl } from '@global/util/language';
import { aboutUsLocale } from '@module/landing/locale/about_us';
const language = getLanguageFromUrl(Astro.url);
const i18n = getI18n(language, aboutUsLocale);
---
<h1>{i18n.welcome}</h1>
6.- Create the file src/middleware.ts and add the following code, this will redirect the default language urls to the base urls, and examples of this is, /en/about-us redirect to /about-us
import { getLanguagePathname, validateDefaultLanguage } from '@global/util/language';
import { defineMiddleware } from 'astro/middleware';
const onRequest = defineMiddleware(async (context, next) =>
{
if(validateDefaultLanguage(context.url))
{
const pathname = getLanguagePathname(context.url);
const redirectCode = 302;
return Response.redirect(new URL(pathname, context.url), redirectCode);
}
return next();
});
export { onRequest };
That's all the configuration nedeed for i18n in this project.
(
Back to top
)
Usage
Before installing all the dependencies you can run the project with
pnpm dev
To see the production ready page you can run
pnpm staging
Builds the app for production to the dist folder.
It correctly bundles Solid in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes, also it compress all the assets and images in the dist folder.
Your app is ready to be deployed.
(
Back to top
)
Scripts
The following scripts are available in the package.json:
preinstall: This script is for only allow pnpm as package managerpostinstall: This script is for setting up the git hooks and validate the error after commit to githubdev: This script is for see the webpage in dev modestaging: This script is for see production, this run the env variables an set the webpage with all the settingsbuild-dev: This script compile the project in dev modebuild: This script is for build in productionlint: This script is for format and lint all the fileslint-eslint: This script is for lint ts, tsx and more fileslint-stylelint: This script is for lint css files
(
Back to top
)
Browser support
Here is the list of all the browser this website support
|
IE / Edge |
Firefox |
Safari |
Safari IOS |
Samsung |
Opera |
|
|
|
|
|
|
|
(
Back to top
)
Copyright © All rights reserved, developed by ElegantCoder and