Skip to content

Commit

Permalink
fixed workflow and improved README.md a little
Browse files Browse the repository at this point in the history
  • Loading branch information
mAmineChniti committed Mar 23, 2024
1 parent 09cb72f commit d5fb383
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
bun install
- name: Check code formatting
run: bun run checkFormat
run: bun run check
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Example:

### JavaScript

To add JavaScript to modify the page, edit the src/scripts/content.ts. It will be compiled to JavaScript when you build the extension. Look at **Build** for more information.
To add JavaScript to modify the page, edit the `src/scripts/content.ts`. It will be compiled to JavaScript when you build the extension. Look at **Build** for more information.

### What is a content.ts?

Expand All @@ -130,21 +130,21 @@ For additional information visit the [background script](https://developer.chrom

### CSS

To add CSS to the DOM, you need to create a CSS file in the public folder and reference it in the manifest.json. The above manifest example assumes there is a file called content.css in the public/assets/styles/ folder.
To add CSS to the DOM, you need to create a CSS file in the public folder and reference it in the `manifest.json`. The above manifest example assumes there is a file called `content.css` in the `public/assets/styles/` folder.

### HTML

For manipulating the DOM, HTML can be added or changed [programmatically](https://developer.mozilla.org/en-US/docs/Web/API/Document) using JavaScript. Your best friends for achieving this are most likely going to be [document.querySelector()](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector), [document.createElement()](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement) and [Node.insertBefore()](https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore).

## The Popup

You can modify the popup just like you would modify an Astro app. You can start by modifying the src/pages/index.astro file. When starting, there is a Placeholder component inside the body that you can modify at src/components/Placeholder.astro or remove.
You can modify the popup just like you would modify an Astro app. You can start by modifying the `src/pages/index.astro` file. When starting, there is a Placeholder component inside the body that you can modify at `src/components/Placeholder.astro` or remove.

### Changing the icon

You can generate the icons from an image.

1. Replace the public/assets/images/example.png
1. Replace the `public/assets/images/example.png`
2. Run the following command in the terminal:

```bash
Expand Down Expand Up @@ -185,16 +185,26 @@ This will build the extension in the dist folder.

## πŸ—οΈ Project structure

<pre>
```bash
root
β”œβ”€β”€ πŸ“ .github
└── πŸ“ workflows
β”œβ”€β”€ πŸ“ build-tools
β”œβ”€β”€ πŸ“ dist
β”œβ”€β”€ πŸ“ public
└── πŸ“ src
β”œβ”€β”€ πŸ“ pages
└── πŸ“ scripts
└── πŸ“ internal
</pre>
```

### .github

Contains a `dependabot.yml`, you only need to change the schedule interval to your liking and enable dependabot on github.

### .github/workflows

Contains workflows to verify the formatting, linting and building of your project.

### build-tools

Expand All @@ -203,6 +213,7 @@ Contains tools used for building the extension. You should not need to modify an
### dist

Contains the built extension. This folder can be loaded as an unpacked extension.
Can be changed by setting outDir in `astro.config.ts`d and changing any reference to `dist`.

### public

Expand All @@ -214,19 +225,19 @@ Contains the source files. This is where you will be doing most of your work.

### src/pages

Contains the index.astro. This is compiled to HTML when building the extension and functions as the popup. I find adding a folder src/components/ and importing them in the index.astro to be a good way to structure the popup.
Contains the `index.astro`. This is compiled to HTML when building the extension and functions as the popup. I find adding a folder src/components/ and importing them in the `index.astro` to be a good way to structure the popup.

### src/scripts

Contains the content.ts and background.ts. These are compiled to JavaScript when building the extension. The content.ts is injected into the DOM of the page.
Contains the `content.ts` and `background.ts`. These are compiled to JavaScript when building the extension. The content.ts is injected into the DOM of the page.

### src/scripts/internal

Not necessary although I find that a useful way to structure the scripts is to add files in this folder and import their functionality in the content.ts and background.ts.
Not necessary although I find that a useful way to structure the scripts is to add files in this folder and import their functionality in the `content.ts` and `background.ts`.

## πŸ’… Formatting

I added a .prettierrc for contributing. If building for your own purposes, feel free to remove it.
I added a `.prettierrc` for contributing. If building for your own purposes, feel free to remove it.
To format with the provided configuration, run:

```bash
Expand All @@ -235,7 +246,7 @@ bun run format

## πŸ‘• Linting

There's an .eslintrc.cjs for the linting configuration.
There's an `.eslintrc.cjs` for the linting configuration.
To lint with the provided configuration, run:

```bash
Expand Down

0 comments on commit d5fb383

Please sign in to comment.