Skip to content

Commit c1f36e9

Browse files
committed
Better eslint configuration and format some files
1 parent da8ef74 commit c1f36e9

File tree

10 files changed

+37
-43
lines changed

10 files changed

+37
-43
lines changed

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/** @type {import("eslint").Linter.Config} */
12
module.exports = {
23
env: {
34
node: true,
45
es2022: true,
56
browser: true,
67
},
78
extends: ['eslint:recommended', 'plugin:astro/recommended'],
9+
parser: '@typescript-eslint/parser',
810
parserOptions: {
11+
tsconfigRootDir: __dirname,
912
ecmaVersion: 'latest',
1013
sourceType: 'module',
1114
},

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## Features
1111

12-
- ✅ Integration with **Tailwind CSS** ([@astrojs/tailwind](https://docs.astro.build/en/guides/integrations-guide/tailwind/)) supporting **Dark mode** and ***RTL***.
12+
- ✅ Integration with **Tailwind CSS** ([@astrojs/tailwind](https://docs.astro.build/en/guides/integrations-guide/tailwind/)) supporting **Dark mode** and **_RTL_**.
1313
-**Production-ready** scores in [Lighthouse](https://web.dev/measure/) and [PageSpeed Insights](https://pagespeed.web.dev/) reports.
1414
-**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**, ...
1515
-**Image Optimization** (using new [Astro Assets](https://astro.build/blog/images/) and [Unpic](https://unpic.pics/lib/) for Universal image CDN) and **Font optimization**.

astro.config.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import mdx from '@astrojs/mdx';
99
import partytown from '@astrojs/partytown';
1010
import compress from 'astro-compress';
1111
import icon from 'astro-icon';
12-
import tasks from "./src/utils/tasks";
12+
import tasks from './src/utils/tasks';
1313

1414
import { readingTimeRemarkPlugin } from './src/utils/frontmatter.mjs';
1515

@@ -32,7 +32,7 @@ export default defineConfig({
3232
output: 'static',
3333

3434
build: {
35-
inlineStylesheets: 'auto'
35+
inlineStylesheets: 'auto',
3636
},
3737

3838
integrations: [

public/decapcms/config.yml

+16-21
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,28 @@ backend:
22
name: git-gateway
33
branch: main
44

5-
media_folder: "src/assets/images"
6-
public_folder: "/_astro"
5+
media_folder: 'src/assets/images'
6+
public_folder: '/_astro'
77

88
collections:
9-
- name: "post"
10-
label: "Post"
11-
folder: "src/content/post"
9+
- name: 'post'
10+
label: 'Post'
11+
folder: 'src/content/post'
1212
create: true
1313
fields:
14-
- { label: "Title", name: "title", widget: "string" }
15-
- { label: "Excerpt", name: "excerpt", widget: "string" }
16-
- { label: "Category", name: "category", widget: "string" }
14+
- { label: 'Title', name: 'title', widget: 'string' }
15+
- { label: 'Excerpt', name: 'excerpt', widget: 'string' }
16+
- { label: 'Category', name: 'category', widget: 'string' }
1717
- {
18-
label: "Tags",
19-
name: "tags",
20-
widget: "list",
18+
label: 'Tags',
19+
name: 'tags',
20+
widget: 'list',
2121
allow_add: true,
2222
allow_delete: true,
2323
collapsed: false,
24-
field: { label: "Tag", name: "tag", widget: "string" },
24+
field: { label: 'Tag', name: 'tag', widget: 'string' },
2525
}
26-
- { label: "Image", name: "image", widget: "string" }
27-
- {
28-
label: "Publish Date",
29-
name: "publishDate",
30-
widget: "datetime",
31-
required: false,
32-
}
33-
- { label: "Author", name: "author", widget: "string" }
34-
- { label: "Content", name: "body", widget: "markdown" }
26+
- { label: 'Image', name: 'image', widget: 'string' }
27+
- { label: 'Publish Date', name: 'publishDate', widget: 'datetime', required: false }
28+
- { label: 'Author', name: 'author', widget: 'string' }
29+
- { label: 'Content', name: 'body', widget: 'markdown' }

public/decapcms/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />

src/content/post/astrowind-template-in-depth.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ The styling mechanism consists of the following files (all paths are prefixed wi
3737
header section. See next.
3838
</DListItem>
3939
<DListItem dt="layouts/Layout.astro">
40-
This layout is used for all of the pages rendered by _AstroWind_. The contents of _tailwind.css_ and _CustomStyles.astro_ component,
41-
described above, is injected into the html header.
40+
This layout is used for all of the pages rendered by _AstroWind_. The contents of _tailwind.css_ and
41+
_CustomStyles.astro_ component, described above, is injected into the html header.
4242
</DListItem>
4343

4444
### Dark Mode

src/pages/rss.xml.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const GET = async () => {
1414

1515
const posts = await fetchPosts();
1616

17-
const { body = "" } = await rss({
17+
const { body = '' } = await rss({
1818
title: `${SITE.name}’s Blog`,
19-
description: METADATA?.description || "",
19+
description: METADATA?.description || '',
2020
site: import.meta.env.SITE,
2121

2222
items: posts.map((post) => ({
@@ -27,12 +27,12 @@ export const GET = async () => {
2727
})),
2828

2929
trailingSlash: SITE.trailingSlash,
30-
})
30+
});
3131

3232
return new Response(body, {
3333
status: 200,
3434
headers: {
35-
"Content-Type": "application/xml"
36-
}
35+
'Content-Type': 'application/xml',
36+
},
3737
});
3838
};

src/utils/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface MetaDataConfig extends Omit<MetaData, 'title'> {
2020
export interface I18NConfig {
2121
language: string;
2222
textDirection: string;
23-
dateFormatter: unknown;
23+
dateFormatter?: Intl.DateTimeFormat;
2424
}
2525
export interface AppBlogConfig {
2626
isEnabled: boolean;

src/utils/images.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export const fetchLocalImages = async () => {
2121
};
2222

2323
/** */
24-
export const findImage = async (imagePath?: string | ImageMetadata | null): Promise<string | ImageMetadata | undefined | null> => {
24+
export const findImage = async (
25+
imagePath?: string | ImageMetadata | null
26+
): Promise<string | ImageMetadata | undefined | null> => {
2527
// Not string
2628
if (typeof imagePath !== 'string') {
2729
return imagePath;
@@ -94,4 +96,4 @@ export const adaptOpenGraphImages = async (
9496
);
9597

9698
return { ...openGraph, ...(adaptedImages ? { images: adaptedImages } : {}) };
97-
};
99+
};

src/utils/utils.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { I18N } from '~/utils/config';
22

3-
const formatter =
3+
const formatter: Intl.DateTimeFormat =
44
I18N?.dateFormatter ||
55
new Intl.DateTimeFormat('en', {
66
year: 'numeric',
@@ -9,13 +9,7 @@ const formatter =
99
timeZone: 'UTC',
1010
});
1111

12-
/* eslint-disable no-mixed-spaces-and-tabs */
13-
export const getFormattedDate = (date: Date) =>
14-
date
15-
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16-
/* @ts-ignore */
17-
formatter.format(date)
18-
: '';
12+
export const getFormattedDate = (date: Date): string => (date ? formatter.format(date) : '');
1913

2014
export const trim = (str = '', ch?: string) => {
2115
let start = 0,

0 commit comments

Comments
 (0)