Better eslint configuration and format some files
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
/** @type {import("eslint").Linter.Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
env: {
|
env: {
|
||||||
node: true,
|
node: true,
|
||||||
@ -5,7 +6,9 @@ module.exports = {
|
|||||||
browser: true,
|
browser: true,
|
||||||
},
|
},
|
||||||
extends: ['eslint:recommended', 'plugin:astro/recommended'],
|
extends: ['eslint:recommended', 'plugin:astro/recommended'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
ecmaVersion: 'latest',
|
ecmaVersion: 'latest',
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- ✅ Integration with **Tailwind CSS** ([@astrojs/tailwind](https://docs.astro.build/en/guides/integrations-guide/tailwind/)) supporting **Dark mode** and ***RTL***.
|
- ✅ Integration with **Tailwind CSS** ([@astrojs/tailwind](https://docs.astro.build/en/guides/integrations-guide/tailwind/)) supporting **Dark mode** and **_RTL_**.
|
||||||
- ✅ **Production-ready** scores in [Lighthouse](https://web.dev/measure/) and [PageSpeed Insights](https://pagespeed.web.dev/) reports.
|
- ✅ **Production-ready** scores in [Lighthouse](https://web.dev/measure/) and [PageSpeed Insights](https://pagespeed.web.dev/) reports.
|
||||||
- ✅ **Fast and SEO friendly blog** with automatic **RSS feed** ([@astrojs/rss](https://docs.astro.build/en/guides/rss/)), [**MDX** support](https://docs.astro.build/en/guides/integrations-guide/mdx/), **Categories & Tags**, **Social Share**, ...
|
- ✅ **Fast and SEO friendly blog** with automatic **RSS feed** ([@astrojs/rss](https://docs.astro.build/en/guides/rss/)), [**MDX** support](https://docs.astro.build/en/guides/integrations-guide/mdx/), **Categories & Tags**, **Social Share**, ...
|
||||||
- ✅ **Image Optimization** (using new [Astro Assets](https://astro.build/blog/images/) and [Unpic](https://unpic.pics/lib/) for Universal image CDN) and **Font optimization**.
|
- ✅ **Image Optimization** (using new [Astro Assets](https://astro.build/blog/images/) and [Unpic](https://unpic.pics/lib/) for Universal image CDN) and **Font optimization**.
|
||||||
|
@ -9,7 +9,7 @@ import mdx from '@astrojs/mdx';
|
|||||||
import partytown from '@astrojs/partytown';
|
import partytown from '@astrojs/partytown';
|
||||||
import compress from 'astro-compress';
|
import compress from 'astro-compress';
|
||||||
import icon from 'astro-icon';
|
import icon from 'astro-icon';
|
||||||
import tasks from "./src/utils/tasks";
|
import tasks from './src/utils/tasks';
|
||||||
|
|
||||||
import { readingTimeRemarkPlugin } from './src/utils/frontmatter.mjs';
|
import { readingTimeRemarkPlugin } from './src/utils/frontmatter.mjs';
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ export default defineConfig({
|
|||||||
output: 'static',
|
output: 'static',
|
||||||
|
|
||||||
build: {
|
build: {
|
||||||
inlineStylesheets: 'auto'
|
inlineStylesheets: 'auto',
|
||||||
},
|
},
|
||||||
|
|
||||||
integrations: [
|
integrations: [
|
||||||
|
@ -2,33 +2,28 @@ backend:
|
|||||||
name: git-gateway
|
name: git-gateway
|
||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
media_folder: "src/assets/images"
|
media_folder: 'src/assets/images'
|
||||||
public_folder: "/_astro"
|
public_folder: '/_astro'
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
- name: "post"
|
- name: 'post'
|
||||||
label: "Post"
|
label: 'Post'
|
||||||
folder: "src/content/post"
|
folder: 'src/content/post'
|
||||||
create: true
|
create: true
|
||||||
fields:
|
fields:
|
||||||
- { label: "Title", name: "title", widget: "string" }
|
- { label: 'Title', name: 'title', widget: 'string' }
|
||||||
- { label: "Excerpt", name: "excerpt", widget: "string" }
|
- { label: 'Excerpt', name: 'excerpt', widget: 'string' }
|
||||||
- { label: "Category", name: "category", widget: "string" }
|
- { label: 'Category', name: 'category', widget: 'string' }
|
||||||
- {
|
- {
|
||||||
label: "Tags",
|
label: 'Tags',
|
||||||
name: "tags",
|
name: 'tags',
|
||||||
widget: "list",
|
widget: 'list',
|
||||||
allow_add: true,
|
allow_add: true,
|
||||||
allow_delete: true,
|
allow_delete: true,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
field: { label: "Tag", name: "tag", widget: "string" },
|
field: { label: 'Tag', name: 'tag', widget: 'string' },
|
||||||
}
|
}
|
||||||
- { label: "Image", name: "image", widget: "string" }
|
- { label: 'Image', name: 'image', widget: 'string' }
|
||||||
- {
|
- { label: 'Publish Date', name: 'publishDate', widget: 'datetime', required: false }
|
||||||
label: "Publish Date",
|
- { label: 'Author', name: 'author', widget: 'string' }
|
||||||
name: "publishDate",
|
- { label: 'Content', name: 'body', widget: 'markdown' }
|
||||||
widget: "datetime",
|
|
||||||
required: false,
|
|
||||||
}
|
|
||||||
- { label: "Author", name: "author", widget: "string" }
|
|
||||||
- { label: "Content", name: "body", widget: "markdown" }
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
@ -37,8 +37,8 @@ The styling mechanism consists of the following files (all paths are prefixed wi
|
|||||||
header section. See next.
|
header section. See next.
|
||||||
</DListItem>
|
</DListItem>
|
||||||
<DListItem dt="layouts/Layout.astro">
|
<DListItem dt="layouts/Layout.astro">
|
||||||
This layout is used for all of the pages rendered by _AstroWind_. The contents of _tailwind.css_ and _CustomStyles.astro_ component,
|
This layout is used for all of the pages rendered by _AstroWind_. The contents of _tailwind.css_ and
|
||||||
described above, is injected into the html header.
|
_CustomStyles.astro_ component, described above, is injected into the html header.
|
||||||
</DListItem>
|
</DListItem>
|
||||||
|
|
||||||
### Dark Mode
|
### Dark Mode
|
||||||
|
@ -14,9 +14,9 @@ export const GET = async () => {
|
|||||||
|
|
||||||
const posts = await fetchPosts();
|
const posts = await fetchPosts();
|
||||||
|
|
||||||
const { body = "" } = await rss({
|
const { body = '' } = await rss({
|
||||||
title: `${SITE.name}’s Blog`,
|
title: `${SITE.name}’s Blog`,
|
||||||
description: METADATA?.description || "",
|
description: METADATA?.description || '',
|
||||||
site: import.meta.env.SITE,
|
site: import.meta.env.SITE,
|
||||||
|
|
||||||
items: posts.map((post) => ({
|
items: posts.map((post) => ({
|
||||||
@ -27,12 +27,12 @@ export const GET = async () => {
|
|||||||
})),
|
})),
|
||||||
|
|
||||||
trailingSlash: SITE.trailingSlash,
|
trailingSlash: SITE.trailingSlash,
|
||||||
})
|
});
|
||||||
|
|
||||||
return new Response(body, {
|
return new Response(body, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/xml"
|
'Content-Type': 'application/xml',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ export interface MetaDataConfig extends Omit<MetaData, 'title'> {
|
|||||||
export interface I18NConfig {
|
export interface I18NConfig {
|
||||||
language: string;
|
language: string;
|
||||||
textDirection: string;
|
textDirection: string;
|
||||||
dateFormatter: unknown;
|
dateFormatter?: Intl.DateTimeFormat;
|
||||||
}
|
}
|
||||||
export interface AppBlogConfig {
|
export interface AppBlogConfig {
|
||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
|
@ -21,7 +21,9 @@ export const fetchLocalImages = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
export const findImage = async (imagePath?: string | ImageMetadata | null): Promise<string | ImageMetadata | undefined | null> => {
|
export const findImage = async (
|
||||||
|
imagePath?: string | ImageMetadata | null
|
||||||
|
): Promise<string | ImageMetadata | undefined | null> => {
|
||||||
// Not string
|
// Not string
|
||||||
if (typeof imagePath !== 'string') {
|
if (typeof imagePath !== 'string') {
|
||||||
return imagePath;
|
return imagePath;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { I18N } from '~/utils/config';
|
import { I18N } from '~/utils/config';
|
||||||
|
|
||||||
const formatter =
|
const formatter: Intl.DateTimeFormat =
|
||||||
I18N?.dateFormatter ||
|
I18N?.dateFormatter ||
|
||||||
new Intl.DateTimeFormat('en', {
|
new Intl.DateTimeFormat('en', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
@ -9,13 +9,7 @@ const formatter =
|
|||||||
timeZone: 'UTC',
|
timeZone: 'UTC',
|
||||||
});
|
});
|
||||||
|
|
||||||
/* eslint-disable no-mixed-spaces-and-tabs */
|
export const getFormattedDate = (date: Date): string => (date ? formatter.format(date) : '');
|
||||||
export const getFormattedDate = (date: Date) =>
|
|
||||||
date
|
|
||||||
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
/* @ts-ignore */
|
|
||||||
formatter.format(date)
|
|
||||||
: '';
|
|
||||||
|
|
||||||
export const trim = (str = '', ch?: string) => {
|
export const trim = (str = '', ch?: string) => {
|
||||||
let start = 0,
|
let start = 0,
|
||||||
|
Reference in New Issue
Block a user