Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Deploy VitePress site to GitHub Pages
name: Deploy Starlight site to GitHub Pages

on:
push:
branches:
- master
paths:
- 'docs/**'
- 'astro.config.mjs'
- '.github/workflows/deploy-docs.yml'
workflow_dispatch:

Expand All @@ -24,13 +25,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 'lts/*'
cache: npm

- name: Setup Pages
Expand All @@ -39,20 +38,23 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build with VitePress
- name: Build with Astro
run: npm run docs:build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
path: pages

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
cache/
coverage/
dist/
pages/
node_modules/

# Astro
.astro/
88 changes: 88 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

export default defineConfig({
outDir: './pages',
srcDir: './docs',
site: 'https://knowledgecode.github.io',
base: '/date-and-time',
trailingSlash: 'never',
devToolbar: {
enabled: false,
},
markdown: {
shikiConfig: {
themes: {
light: 'github-light',
dark: 'github-dark',
},
},
},
integrations: [
starlight({
customCss: [
'./docs/styles/custom.css',
],
title: 'date-and-time',
description: 'The simplest, most intuitive date and time library',
logo: {
src: './docs/assets/logo.png',
alt: 'date-and-time',
},
social: [
{ icon: 'github', label: 'GitHub', href: 'https://github.com/knowledgecode/date-and-time' },
{ icon: 'npm', label: 'npm', href: 'https://www.npmjs.com/package/date-and-time' },
],
sidebar: [
{
label: 'Getting Started',
items: [
{ label: 'Introduction', link: '/guide' },
{ label: 'Installation', link: '/guide/installation' },
{ label: 'Quick Start', link: '/guide/quick-start' },
],
},
{
label: 'API Reference',
collapsed: true,
items: [
{ label: 'Overview', link: '/api' },
{
label: 'Core Functions',
items: [
{ label: 'format()', link: '/api/format' },
{ label: 'parse()', link: '/api/parse' },
{ label: 'compile()', link: '/api/compile' },
{ label: 'preparse()', link: '/api/preparse' },
{ label: 'isValid()', link: '/api/isvalid' },
{ label: 'transform()', link: '/api/transform' },
{ label: 'addYears()', link: '/api/addyears' },
{ label: 'addMonths()', link: '/api/addmonths' },
{ label: 'addDays()', link: '/api/adddays' },
{ label: 'addHours()', link: '/api/addhours' },
{ label: 'addMinutes()', link: '/api/addminutes' },
{ label: 'addSeconds()', link: '/api/addseconds' },
{ label: 'addMilliseconds()', link: '/api/addmilliseconds' },
{ label: 'subtract()', link: '/api/subtract' },
],
},
{
label: 'Utility Functions',
items: [
{ label: 'isLeapYear()', link: '/api/utils/isleapyear' },
{ label: 'isSameDay()', link: '/api/utils/issameday' },
{ label: 'getDaysInMonth()', link: '/api/utils/getdaysinmonth' },
{ label: 'getISOWeekYear()', link: '/api/utils/getisoweekyear' },
{ label: 'getISOWeek()', link: '/api/utils/getisoweek' },
],
},
],
},
{ label: 'Locales', link: '/locales' },
{ label: 'Timezones', link: '/timezones' },
{ label: 'Plugins', link: '/plugins' },
{ label: 'Migration Guide', link: '/migration' },
],
}),
],
});
98 changes: 0 additions & 98 deletions docs/.vitepress/config.ts

This file was deleted.

4 changes: 3 additions & 1 deletion docs/api/addDays.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addDays()
---
title: addDays()
---

Adds or subtracts days from a Date object. Handles month boundaries, leap years, and daylight saving time transitions properly.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addHours.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addHours()
---
title: addHours()
---

Adds or subtracts hours from a Date object.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addMilliseconds.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addMilliseconds()
---
title: addMilliseconds()
---

Adds or subtracts milliseconds from a Date object.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addMinutes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addMinutes()
---
title: addMinutes()
---

Adds or subtracts minutes from a Date object.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addMonths.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addMonths()
---
title: addMonths()
---

Adds or subtracts months from a Date object. Handles month boundaries, leap years, and varying month lengths appropriately.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addSeconds.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addSeconds()
---
title: addSeconds()
---

Adds or subtracts seconds from a Date object.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/addYears.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# addYears()
---
title: addYears()
---

Adds or subtracts years from a Date object. Handles leap years and edge cases appropriately.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/compile.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# compile()
---
title: compile()
---

Precompiles a format string into a reusable compiled object for improved performance when the same format pattern is used repeatedly.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/format.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# format()
---
title: format()
---

Formats a Date object according to the specified format string.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# API Reference
---
title: API Reference
---

Welcome to the comprehensive API reference for date-and-time v4.x. This section provides detailed documentation for all available functions, types, and options.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/isValid.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# isValid()
---
title: isValid()
---

Validates whether a date string conforms to the specified format pattern and represents a valid date.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/parse.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# parse()
---
title: parse()
---

Parses a formatted date string into a Date object according to the specified format pattern.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/preparse.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# preparse()
---
title: preparse()
---

Pre-parses date strings and returns intermediate parsing results. This function is useful when you need to examine parsing details before creating a final Date object.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/subtract.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# subtract()
---
title: subtract()
---

Calculates the difference between two Date objects and returns a rich Duration object with multiple time units and formatting options.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/transform.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# transform()
---
title: transform()
---

Transforms date strings from one format to another. This is a convenience function that combines parse() and format() operations.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/utils/getDaysInMonth.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# getDaysInMonth()
---
title: getDaysInMonth()
---

Returns the number of days in a given month of a specific year. Correctly handles leap years when calculating February.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/utils/getISOWeek.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# getISOWeek()
---
title: getISOWeek()
---

Returns the ISO 8601 week number (1–53) for a given date. ISO weeks start on Monday, and week 1 is the week containing the first Thursday of the year.

Expand Down
4 changes: 3 additions & 1 deletion docs/api/utils/getISOWeekYear.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# getISOWeekYear()
---
title: getISOWeekYear()
---

Returns the ISO 8601 week year for a given date. The ISO week year may differ from the calendar year near the start and end of the year, because ISO weeks always start on Monday and the first week of the year is the one containing the first Thursday of the year.

Expand Down
Loading
Loading