Skip to content

Commit

Permalink
Trim URL slash and fix TW reset
Browse files Browse the repository at this point in the history
  • Loading branch information
barvian committed Nov 24, 2024
1 parent 275bdcb commit 80d6c8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions site/src/lib/framework.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { trimSlash } from './url'

export type FrameworkData = {
name: string | undefined
sandbox: string
Expand Down Expand Up @@ -56,8 +58,9 @@ export const toFrameworkPath = (
// New prefix to prepend, based on new framework:
const prefix = id === DEFAULT_FRAMEWORK ? '' : '/' + id

if (firstSegment && Object.keys(FRAMEWORKS).includes(firstSegment))
return prefix + '/' + segments.join('/')
if (firstSegment && Object.keys(FRAMEWORKS).includes(firstSegment)) {
return trimSlash(prefix + '/' + segments.join('/'))
}
// It was on the default framework
return prefix + path
return trimSlash(prefix + path)
}
2 changes: 2 additions & 0 deletions site/src/lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const isActive = (
toFrameworkPath(path, DEFAULT_FRAMEWORK),
toFrameworkPath(urlOrPathname, DEFAULT_FRAMEWORK)
)

export const trimSlash = (path: string | undefined) => path?.replace(/(.)\/$/, '$1')
5 changes: 1 addition & 4 deletions site/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import type { PluginUtils } from 'tailwindcss/types/config'
const sans = ['Inter', '_font_fallback_732902278794', 'sans-serif']

export default {
presets: [reset],
future: {
hoverOnlyWhenSupported: true
},
presets: [reset({ hoverOnlyWhenSupported: true })],
content: {
files: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
transform: {
Expand Down

0 comments on commit 80d6c8e

Please sign in to comment.