Skip to content

Commit

Permalink
SPA mode
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Jan 21, 2024
1 parent 7c48b69 commit 52fc304
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 27 deletions.
26 changes: 14 additions & 12 deletions astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'dotenv/config'
Object.assign(process.env, { ASTRO_TELEMETRY_DISABLED: 1 })

import process from 'node:process'
import sentry from '@sentry/astro'
import tailwind from '@astrojs/tailwind'
import starlight from '@astrojs/starlight'
import spotlightjs from '@spotlightjs/astro'
import moonlightTheme from './public/theme/moonlight-ii.json'
import starlightLinksValidator from 'starlight-links-validator'
import moonlightTheme from './src/assets/theme/moonlight-ii.json'
import { defineConfig, passthroughImageService } from 'astro/config'

const SITE_URL = 'https://docs.ethfollow.xyz'
Expand All @@ -21,7 +19,7 @@ export default defineConfig({
starlight({
title: 'EFP Docs',
tagline: 'Ethereum Follow Protocol',
description: 'Technical documentation',
description: 'Ethereum Follow Protocol technical documentation',
favicon: '/favicon.ico',
lastUpdated: true,
expressiveCode: {
Expand All @@ -37,6 +35,9 @@ export default defineConfig({
discord: 'https://discord.ethfollow.xyz',
'x.com': 'https://x.com/ethfollowpr'
},
components: {
Head: './src/components/Head.astro'
},
locales: {
root: {
label: 'English',
Expand Down Expand Up @@ -100,21 +101,18 @@ export default defineConfig({
{
label: 'EFP Indexer API',
collapsed: false,
// badge: {
// text: 'v1',
// variant: 'note'
// },
badge: { text: '/api/v1', variant: 'tip' },
items: [
{
label: '/api/v1/leaderboard',
label: 'Leaderboard',
link: '/api/leaderboard'
},
{
label: '/api/v1/lists',
label: 'Lists',
link: '/api/lists'
},
{
label: '/api/v1/users',
label: 'Users',
link: '/api/users'
}
]
Expand Down Expand Up @@ -167,6 +165,10 @@ export default defineConfig({
'@fontsource/inter/900.css',
'@fontsource/ibm-plex-mono/400.css',
'@fontsource/ibm-plex-mono/600.css'
],
plugins: [
// https://starlight-links-validator.vercel.app/configuration/#configuration-options
starlightLinksValidator()
]
}),
tailwind({
Expand Down
Binary file modified bun.lockb
Binary file not shown.
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "docs",
"version": "0.0.1",
"description": "Ethereum Follow Protocol Documentation",
"repository": "github:ethereumfollowprotocol/docs",
"homepage": "https://docs.ethfollow.xyz",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"build": "astro build",
Expand All @@ -17,40 +18,40 @@
},
"devDependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/starlight": "^0.15.3",
"@astrojs/starlight": "^0.16.0",
"@astrojs/starlight-tailwind": "^2.0.1",
"@astrojs/tailwind": "^5.1.0",
"@astrojs/ts-plugin": "^1.4.0",
"@fontsource/ibm-plex-mono": "^5.0.8",
"@fontsource/inter": "^5.0.16",
"@sentry/astro": "^7.93.0",
"@spotlightjs/astro": "^1.0.9",
"@sentry/astro": "^7.94.1",
"@spotlightjs/astro": "^1.0.10",
"@tailwindcss/typography": "^0.5.10",
"@total-typescript/ts-reset": "^0.5.1",
"@types/bun": "^1.0.2",
"@types/eslint": "^8.56.2",
"@types/node": "^20.11.4",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"astro": "^4.1.3",
"bun": "^1.0.23",
"astro": "^4.2.1",
"bun": "^1.0.24",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^0.31.3",
"eslint-plugin-jsonc": "^2.12.2",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^50.0.1",
"prettier": "^3.2.2",
"prettier-plugin-astro": "^0.12.3",
"prettier": "^3.2.4",
"prettier-plugin-astro": "^0.13.0",
"prettier-plugin-tailwindcss": "^0.5.11",
"sharp": "^0.33.2",
"shikiji-twoslash": "0.10.0-beta.4",
"shikiji-twoslash": "^0.10.0-beta.9",
"starlight-links-validator": "^0.5.2",
"tailwindcss": "^3.4.1",
"typed-query-selector": "^2.11.0",
"typescript": "^5.3.3"
},
"repository": "github:ethereumfollowprotocol/docs",
"sideEffects": false,
"private": true
}
106 changes: 106 additions & 0 deletions scripts/update-dependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env bun
/**
* Update outdated dependencies
*/

import bun from 'bun'
import packageJson from '../package.json' with { type: 'json' }

const {
name,
version,
description,
repository,
type,
scripts,
// dependencies,
devDependencies,
...rest
} = packageJson

main().catch(error => {
console.error(error)
process.exit(1)
})

async function main() {
const updated = await bumpDependencies()
if (updated) console.log('Dependencies updated')
else console.log('Dependencies are up to date')

const { stdout, success } = bun.spawnSync(['bun', 'install', '--no-cache', '--force'])
console.log(`success: ${success}`, stdout.toString())
}

async function bumpDependencies() {
// const unstableDependenciesNames = getUnstableDependencies(dependencies)
const unstableDevelopmentDependenciesNames = getUnstableDependencies(devDependencies)

// filter out packages whose version is beta or alpha
// const dependenciesNames = Object.keys(dependencies).filter(
// name => !Object.hasOwn(unstableDependenciesNames, name)
// )
// const latestDependenciesVersions = await Promise.all(
// dependenciesNames.map(name => fetchPackageLatestVersion(name))
// )

// const updatedDependencies = Object.fromEntries(
// dependenciesNames.map((name, index) => [name, `^${latestDependenciesVersions[index]}`])
// )

// for (const [name, version] of Object.entries(unstableDependenciesNames)) {
// updatedDependencies[name] = version
// }

const developmentDependenciesNames = Object.keys(devDependencies).filter(
name => !Object.hasOwn(unstableDevelopmentDependenciesNames, name)
)

const latestDevelopmentDependenciesVersions = await Promise.all(
developmentDependenciesNames.map(name => fetchPackageLatestVersion(name))
)

const updatedDevelopmentDependencies = Object.fromEntries(
developmentDependenciesNames.map((name, index) => [
name,
`^${latestDevelopmentDependenciesVersions[index]}`
])
)

for (const [name, version] of Object.entries(unstableDevelopmentDependenciesNames)) {
updatedDevelopmentDependencies[name] = version
}

const updatedPackageJson = {
name,
version,
description,
repository,
type,
scripts,
// dependencies: updatedDependencies,
devDependencies: updatedDevelopmentDependencies,
...rest
}

const write = await bun.write(
`${import.meta.dir}/../package.json`,
`${JSON.stringify(updatedPackageJson, undefined, 2)}\n`
)

return Boolean(write)
}

async function fetchPackageLatestVersion(name: string) {
const response = await fetch(`https://registry.npmjs.org/${name}/latest`)
const { version } = (await response.json()) as { version: string }
return version
}

function getUnstableDependencies(dependencies: Record<string, string>) {
return Object.fromEntries(
Object.entries(dependencies)
.filter(([, version]) => /alpha|beta/.test(version))
.map(([name, version]) => [name, version])
) as Record<string, string>
}
File renamed without changes.
5 changes: 5 additions & 0 deletions src/components/Head.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import { ViewTransitions } from 'astro:transitions'
---

<ViewTransitions />
2 changes: 1 addition & 1 deletion src/content/docs/api/leaderboard/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: /api/v1/leaderboard
title: Leaderboard
description: Ethereum Follow Protocol API v1
---

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/api/lists/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: /api/v1/lists
title: Lists
description: Ethereum Follow Protocol API v1
---

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/api/users/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: /api/v1/users
title: Users
description: Ethereum Follow Protocol API v1
---

Expand Down
2 changes: 1 addition & 1 deletion src/styles/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
--overlay-blurple: hsla(var(--overlay-hsl), 0.4);
--sl-font: 'Inter', sans-serif;
--sl-content-margin-inline: auto !important;
--sl-sidebar-width: 14rem;
--sl-sidebar-width: 18rem;
--sl-color-bg-sidebar: unset;
--sl-color-text: #fafafafa;
--sl-color-accent-low: #2c230a;
Expand Down

0 comments on commit 52fc304

Please sign in to comment.