This project provides a server-based solution to search for and display information on how to center a div using Google Custom Search API.
.vercel/
: Contains Vercel configuration files.api/
: Contains the serverless function for handling the search requests.search.ts
: Main serverless function for querying Google Custom Search API.
public/
: Public assets for the project.asset/
: Contains image assets.avatar.png
: An example image.
src/
: Source files for the project.index.html
: Main HTML file.manifest.json
: Web app manifest file.output.css
: Compiled CSS file.script.js
: Main JavaScript file.style.css
: Main CSS file.
.env
: Environment variables file (not included in the repository)..gitignore
: Specifies files and directories to be ignored by Git.package.json
: Contains project metadata and dependencies.tsconfig.json
: TypeScript configuration file.tailwind.config.js
: Configuration file for Tailwind CSS.
-
Clone the repository:
git clone https://github.com/Invalid8/how-to-center-a-div.git cd how-to-center-a-div
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your Google Custom Search API credentials:API_KEY=your_google_api_key CX=your_google_custom_search_engine_id
-
Deploy the project on Vercel:
vercel
Once deployed, the serverless function will handle requests to fetch search results related to centering a div. The function is defined in api/search.ts
and works as follows:
- Extracts the
limit
andpage
query parameters from the request. - Constructs the search URL using Google Custom Search API credentials.
- Fetches the search results and returns them in the response.
GET /api/search?limit=10&page=1
If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes and commit them (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.