feat: Implement Algolia DocSearch, update build configurations, and refine UI components.

This commit is contained in:
gitfromwildan
2026-02-08 23:36:19 +07:00
parent d91f94b308
commit dff814e201
45 changed files with 1648 additions and 1146 deletions

162
styles/algolia.css Normal file
View File

@@ -0,0 +1,162 @@
/*
================================================================================
DocSearch Component Styling (Refactored Version)
================================================================================
*/
/* -- LANGKAH 1: Definisi Variabel Global --
Variabel tema DocSearch sekarang didefinisikan secara global di :root.
Ini menyederhanakan pewarisan tema dan memastikan konsistensi.
Mode gelap secara otomatis menimpa variabel ini karena .dark di globals.css.
*/
:root {
--docsearch-primary-color: hsl(var(--primary));
--docsearch-text-color: hsl(var(--muted-foreground));
--docsearch-spacing: 12px;
--docsearch-icon-stroke-width: 1.4;
--docsearch-highlight-color: var(--docsearch-primary-color);
--docsearch-muted-color: hsl(var(--muted-foreground));
--docsearch-container-background: rgba(0, 0, 0, 0.7);
--docsearch-logo-color: hsl(var(--primary-foreground));
/* Modal */
--docsearch-modal-width: 560px;
--docsearch-modal-height: 600px;
--docsearch-modal-background: hsl(var(--background));
--docsearch-modal-shadow: 0 0 0 1px hsl(var(--border)), 0 8px 20px rgba(0, 0, 0, 0.2);
/* SearchBox */
--docsearch-searchbox-height: 56px;
--docsearch-searchbox-background: hsl(var(--input));
--docsearch-searchbox-focus-background: hsl(var(--card));
--docsearch-searchbox-shadow: none;
/* Hit (Hasil Pencarian) */
--docsearch-hit-height: 56px;
--docsearch-hit-color: hsl(var(--foreground));
--docsearch-hit-active-color: hsl(var(--primary-foreground));
--docsearch-hit-background: hsl(var(--card));
--docsearch-hit-shadow: none;
/* Keys */
--docsearch-key-gradient: none;
--docsearch-key-shadow: none;
--docsearch-key-pressed-shadow: none;
/* Footer */
--docsearch-footer-height: 44px;
--docsearch-footer-background: hsl(var(--background));
--docsearch-footer-shadow: none;
}
/* -- LANGKAH 2: Gaya untuk Tombol Awal --
Gaya ini spesifik untuk tombol yang ada di Navbar,
yang dibungkus oleh <div class="docsearch">.
*/
.docsearch .DocSearch-Button {
background-color: hsl(var(--secondary));
border: 1px solid hsl(var(--border));
border-radius: 9999px;
width: 160px;
height: 40px;
color: hsl(var(--muted-foreground));
transition: width 0.3s ease;
margin: 0;
}
.docsearch .DocSearch-Button:hover {
border-color: var(--docsearch-primary-color);
box-shadow: none;
}
.docsearch .DocSearch-Search-Icon {
color: var(--docsearch-muted-color);
width: 1rem;
height: 1rem;
}
.docsearch .DocSearch-Button-Placeholder {
font-style: normal;
margin-left: 0.25rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--docsearch-muted-color);
}
.docsearch .DocSearch-Button-Key {
background: var(--docsearch-primary-color);
color: var(--docsearch-logo-color); /* Menggunakan variabel yg relevan */
border-radius: 6px;
font-size: 14px;
font-weight: 500;
height: 24px;
padding: 0 6px;
border: none;
box-shadow: none;
top: 0;
}
/* -- LANGKAH 3: Gaya untuk Modal dan Isinya --
Gaya ini menargetkan elemen-elemen modal yang dirender terpisah.
Karena variabel sudah global, kita hanya perlu menata elemennya.
*/
.DocSearch-Container .DocSearch-Modal {
backdrop-filter: blur(8px);
}
.DocSearch-Form {
border: 1px solid hsl(var(--border));
background-color: transparent;
}
.DocSearch-Input {
font-size: 15px !important;
}
.DocSearch-Footer {
border-top: 1px solid hsl(var(--border));
}
/* Gaya untuk tombol keyboard di footer */
.DocSearch-Footer--commands kbd {
background-color: hsl(var(--secondary));
border: 1px solid hsl(var(--border));
border-bottom-width: 2px;
border-radius: 6px;
color: var(--docsearch-muted-color);
padding: 4px 8px;
display: flex;
align-items: center;
justify-content: center;
}
/* Menghilangkan gaya default dari ikon di dalam tombol footer */
.DocSearch-Commands-Key {
background: none;
color: hsl(var(--muted-foreground));
border: 1px solid hsl(var(--border));
box-shadow: none;
padding: 2px 4px;
margin-right: 0.4em;
height: 20px;
width: 32px;
border-radius: 6px;
}
/* -- LANGKAH 4: Gaya Responsif --
Tidak ada perubahan, hanya mempertahankan fungsionalitas mobile.
*/
@media (max-width: 768px) {
.docsearch .DocSearch-Button {
width: 40px;
height: 40px;
padding: 0;
justify-content: center;
background: none;
border: none;
}
.docsearch .DocSearch-Button-Placeholder,
.docsearch .DocSearch-Button-Key {
display: none;
}
}

View File

@@ -1,67 +1,190 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import 'tailwindcss';
@plugin '@tailwindcss/typography';
@import url("../styles/syntax.css");
/* Modern Blue Theme with Primary #0353D3 */
@custom-variant dark (&:is(.dark *));
@utility container {
margin-inline: auto;
padding-inline: 2rem;
@media (width >=--theme(--breakpoint-sm)) {
max-width: none;
}
@media (width >=1440px) {
max-width: 1440px;
}
}
@theme {
--color-border: hsl(var(--border));
--color-input: hsl(var(--input));
--color-ring: hsl(var(--ring));
--color-background: hsl(var(--background));
--color-foreground: hsl(var(--foreground));
--color-primary: hsl(var(--primary));
--color-primary-foreground: hsl(var(--primary-foreground));
--color-secondary: hsl(var(--secondary));
--color-secondary-foreground: hsl(var(--secondary-foreground));
--color-destructive: hsl(var(--destructive));
--color-destructive-foreground: hsl(var(--destructive-foreground));
--color-muted: hsl(var(--muted));
--color-muted-foreground: hsl(var(--muted-foreground));
--color-accent: hsl(var(--accent));
--color-accent-foreground: hsl(var(--accent-foreground));
--color-popover: hsl(var(--popover));
--color-popover-foreground: hsl(var(--popover-foreground));
--color-card: hsl(var(--card));
--color-card-foreground: hsl(var(--card-foreground));
--color-sidebar: hsl(var(--sidebar-background));
--color-sidebar-foreground: hsl(var(--sidebar-foreground));
--color-sidebar-primary: hsl(var(--sidebar-primary));
--color-sidebar-primary-foreground: hsl(var(--sidebar-primary-foreground));
--color-sidebar-accent: hsl(var(--sidebar-accent));
--color-sidebar-accent-foreground: hsl(var(--sidebar-accent-foreground));
--color-sidebar-border: hsl(var(--sidebar-border));
--color-sidebar-ring: hsl(var(--sidebar-ring));
--radius-lg: var(--radius);
--radius-md: calc(var(--radius) - 2px);
--radius-sm: calc(var(--radius) - 4px);
--font-code: var(--font-geist-mono);
--font-regular: var(--font-geist-sans);
--animate-accordion-down: accordion-down 0.2s ease-out;
--animate-accordion-up: accordion-up 0.2s ease-out;
--animate-shiny-text: shiny-text 8s infinite;
@keyframes accordion-down {
from {
height: 0;
}
to {
height: var(--radix-accordion-content-height);
}
}
@keyframes accordion-up {
from {
height: var(--radix-accordion-content-height);
}
to {
height: 0;
}
}
@keyframes shiny-text {
0%,
90%,
100% {
background-position: calc(-100% - var(--shiny-width)) 0;
}
30%,
60% {
background-position: calc(100% + var(--shiny-width)) 0;
}
}
}
/*
The default border color has changed to `currentcolor` in Tailwind CSS v4,
so we've added these compatibility styles to make sure everything still
looks the same as it did with Tailwind CSS v3.
If we ever want to remove these styles, we need to add an explicit border
color utility to any element that depends on these defaults.
*/
@layer base {
:root {
--background: 210 40% 98%;
--foreground: 220 30% 15%;
--card: 0 0% 100%;
--card-foreground: 220 30% 15%;
--popover: 0 0% 100%;
--popover-foreground: 220 30% 15%;
--primary: 215 100% 42%; /* #0353D3 */
--primary-foreground: 0 0% 100%;
--secondary: 215 30% 90%;
--secondary-foreground: 220 30% 15%;
--muted: 215 20% 92%;
--muted-foreground: 220 15% 50%;
--accent: 215 100% 35%;
--accent-foreground: 0 0% 100%;
--destructive: 0 85% 60%;
--destructive-foreground: 0 0% 100%;
--border: 215 20% 85%;
--input: 215 20% 85%;
--ring: 215 100% 42%;
--radius: 0.5rem;
--chart-1: 215 100% 42%;
--chart-2: 200 100% 40%;
--chart-3: 220 76% 60%;
--chart-4: 190 90% 50%;
--chart-5: 230 86% 45%;
--line-number-color: rgba(0, 0, 0, 0.05);
}
.dark {
--background: 220 25% 8%;
--foreground: 210 30% 98%;
--card: 220 25% 12%;
--card-foreground: 210 30% 98%;
--popover: 220 25% 12%;
--popover-foreground: 210 30% 98%;
--primary: 217 91% 60%; /* Slightly adjusted for better visibility */
--primary-foreground: 0 0% 100%;
--secondary: 215 25% 18%;
--secondary-foreground: 210 30% 98%;
--muted: 215 20% 22%;
--muted-foreground: 215 20% 75%;
--accent: 215 100% 60%;
--accent-foreground: 0 0% 100%;
--destructive: 0 85% 65%;
--destructive-foreground: 0 0% 100%;
--border: 215 20% 28%;
--input: 215 20% 22%;
--ring: 217 91% 60%;
--chart-1: 217 91% 60%;
--chart-2: 200 100% 60%;
--chart-3: 220 90% 70%;
--chart-4: 190 100% 65%;
--chart-5: 230 90% 60%;
--line-number-color: rgba(255, 255, 255, 0.12);
}
*,
::after,
::before,
::backdrop,
::file-selector-button {
border-color: var(--color-gray-200, currentcolor);
}
}
@utility animate-shine {
--animate-shine: shine var(--duration) infinite linear;
animation: var(--animate-shine);
background-size: 200% 200%;
}
/* Modern Blue Theme */
@layer base {
:root {
--background: 210 40% 98%;
--foreground: 220 30% 15%;
--card: 0 0% 100%;
--card-foreground: 220 30% 15%;
--popover: 0 0% 100%;
--popover-foreground: 220 30% 15%;
--primary: 215 100% 42%;
/* #0353D3 */
--primary-foreground: 0 0% 100%;
--secondary: 215 30% 90%;
--secondary-foreground: 220 30% 15%;
--muted: 215 20% 92%;
--muted-foreground: 220 15% 50%;
--accent: 215 100% 35%;
--accent-foreground: 0 0% 100%;
--destructive: 0 85% 60%;
--destructive-foreground: 0 0% 100%;
--border: 215 20% 85%;
--input: 215 20% 85%;
--ring: 215 100% 42%;
--radius: 0.5rem;
--chart-1: 215 100% 42%;
--chart-2: 200 100% 40%;
--chart-3: 220 76% 60%;
--chart-4: 190 90% 50%;
--chart-5: 230 86% 45%;
--line-number-color: rgba(0, 0, 0, 0.05);
}
.dark {
--background: 220 25% 8%;
--foreground: 210 30% 98%;
--card: 220 25% 12%;
--card-foreground: 210 30% 98%;
--popover: 220 25% 12%;
--popover-foreground: 210 30% 98%;
--primary: 217 91% 60%;
/* Slightly adjusted for better visibility */
--primary-foreground: 0 0% 100%;
--secondary: 215 25% 18%;
--secondary-foreground: 210 30% 98%;
--muted: 215 20% 22%;
--muted-foreground: 215 20% 75%;
--accent: 215 100% 60%;
--accent-foreground: 0 0% 100%;
--destructive: 0 85% 65%;
--destructive-foreground: 0 0% 100%;
--border: 215 20% 28%;
--input: 215 20% 22%;
--ring: 217 91% 60%;
--chart-1: 217 91% 60%;
--chart-2: 200 100% 60%;
--chart-3: 220 90% 70%;
--chart-4: 190 100% 65%;
--chart-5: 230 90% 60%;
--line-number-color: rgba(255, 255, 255, 0.12);
}
}
@layer base {
@@ -74,66 +197,66 @@
}
}
.prose {
margin: 0 !important;
}
@layer utilities {
.prose {
margin: 0 !important;
}
pre {
padding: 2px 0 !important;
width: inherit !important;
overflow-x: auto;
}
pre {
padding: 2px 0 !important;
width: inherit !important;
overflow-x: auto;
}
pre>code {
display: grid;
max-width: inherit !important;
padding: 14px 0 !important;
}
pre>code {
display: grid;
max-width: inherit !important;
padding: 14px 0 !important;
border: 0 !important;
}
.code-line {
padding: 0.75px 16px;
@apply border-l-2 border-transparent
}
.code-line {
padding: 0.75px 16px;
@apply border-l-2 border-transparent;
}
.line-number::before {
display: inline-block;
width: 1rem;
margin-right: 22px;
margin-left: -2px;
color: rgb(110, 110, 110);
content: attr(line);
font-size: 13.5px;
text-align: right;
}
.line-number::before {
display: inline-block;
width: 1rem;
margin-right: 22px;
margin-left: -2px;
color: rgb(110, 110, 110);
content: attr(line);
font-size: 13.5px;
text-align: right;
}
.highlight-line {
@apply bg-primary/5 border-l-2 border-primary/30;
}
.highlight-line {
@apply bg-primary/5 border-l-2 border-primary/30;
}
.rehype-code-title {
@apply px-2 -mb-8 w-full text-sm pb-5 font-medium mt-5 font-code;
}
.rehype-code-title {
@apply px-2 -mb-8 w-full text-sm pb-5 font-medium mt-5 font-code;
}
.highlight-comp>code {
background-color: transparent !important;
.highlight-comp>code {
background-color: transparent !important;
}
}
@layer utilities {
.animate-shine {
--animate-shine: shine var(--duration) infinite linear;
animation: var(--animate-shine);
background-size: 200% 200%;
@keyframes shine {
0% {
background-position: 0% 0%;
}
@keyframes shine {
0% {
background-position: 0% 0%;
}
50% {
background-position: 100% 100%;
}
100% {
background-position: 0% 0%;
}
50% {
background-position: 100% 100%;
}
100% {
background-position: 0% 0%;
}
}
}

View File

@@ -1,19 +1,23 @@
/* Modern Blue Theme with Primary #0353D3 */
/* Modern Blue Theme */
/* Light Mode */
.keyword {
color: #1e40af; /* Darker blue for better contrast */
color: #1e40af;
/* Darker blue for better contrast */
}
.function {
color: #0369a1; /* Deep blue */
color: #0369a1;
/* Deep blue */
}
.punctuation {
color: #4b5563; /* Slate gray */
color: #4b5563;
/* Slate gray */
}
.comment {
color: #6b7280; /* Muted gray */
color: #6b7280;
/* Muted gray */
font-style: italic;
}
@@ -22,29 +26,35 @@
.annotation,
.boolean,
.number {
color: #0d9488; /* Teal for better distinction */
color: #0d9488;
/* Teal for better distinction */
}
.tag {
color: #1e40af; /* Matching keyword color */
color: #1e40af;
/* Matching keyword color */
}
.attr-name {
color: #1d4ed8; /* Slightly lighter blue */
color: #1d4ed8;
/* Slightly lighter blue */
}
.attr-value {
color: #2563eb; /* Primary blue */
color: #2563eb;
/* Primary blue */
}
/* Dark Mode */
.dark .keyword {
color: #60a5fa; /* Soft blue - good contrast on dark */
color: #60a5fa;
/* Soft blue - good contrast on dark */
font-weight: 500;
}
.dark .function {
color: #38bdf8; /* Sky blue */
color: #38bdf8;
/* Sky blue */
}
.dark .string,
@@ -52,47 +62,60 @@
.dark .annotation,
.dark .boolean,
.dark .number {
color: #2dd4bf; /* Teal - good visibility */
color: #2dd4bf;
/* Teal - good visibility */
}
.dark .tag {
color: #60a5fa; /* Matching keyword color */
color: #60a5fa;
/* Matching keyword color */
}
.dark .attr-name {
color: #7dd3fc; /* Lighter blue - better visibility */
color: #7dd3fc;
/* Lighter blue - better visibility */
}
.dark .attr-value {
color: #60a5ff; /* Brighter blue - better visibility */
color: #60a5ff;
/* Brighter blue - better visibility */
}
.dark .comment {
color: #94a3b8; /* Light gray - better contrast for dark mode */
color: #94a3b8;
/* Light gray - better contrast for dark mode */
font-style: italic;
}
.dark .punctuation {
color: #cbd5e1; /* Lighter gray - better visibility */
color: #cbd5e1;
/* Lighter gray - better visibility */
opacity: 0.8;
}
.dark .operator {
color: #cbd5e1; /* Light gray for operators */
color: #cbd5e1;
/* Light gray for operators */
}
.dark .selector {
color: #f472b6; /* Pink for selectors - better visibility */
color: #f472b6;
/* Pink for selectors - better visibility */
}
.youtube {
position: relative;
padding-bottom: 56.25%; /* Rasio aspek 16:9 */
padding-bottom: 56.25%;
/* Rasio aspek 16:9 */
height: 0;
overflow: hidden;
background: #000; /* Latar belakang hitam untuk memadukan player */
border-radius: 8px; /* Sudut melengkung */
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); /* Bayangan lembut */
background: #000;
/* Latar belakang hitam untuk memadukan player */
border-radius: 8px;
/* Sudut melengkung */
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
/* Bayangan lembut */
margin: 1.5rem 0;
}
.youtube iframe {
@@ -102,5 +125,95 @@
width: 100%;
height: 100%;
border: none;
border-radius: 8px; /* Sudut melengkung pada iframe */
border-radius: 8px;
/* Sudut melengkung pada iframe */
}
/* ======================================================================== */
/* Custom styling for code blocks */
/* ======================================================================== */
.code-block-container {
position: relative;
margin: 1.5rem 0;
border: 1px solid hsl(var(--border));
overflow: hidden;
font-size: 0.875rem;
border-radius: 0.75rem;
}
.code-block-header {
display: flex;
align-items: center;
gap: 0.5rem;
background-color: hsl(var(--muted));
padding: 0.5rem 1rem;
border-bottom: 1px solid hsl(var(--border));
color: hsl(var(--muted-foreground));
font-family: monospace;
font-size: 0.8rem;
}
.code-block-actions {
position: absolute;
top: 0.5rem;
right: 0.75rem;
z-index: 10;
}
.code-block-actions button {
color: hsl(var(--muted-foreground));
transition: color 0.2s ease-in-out;
}
.code-block-actions button:hover {
color: hsl(var(--foreground));
}
.code-block-body pre[class*="language-"] {
margin: 0 !important;
padding: 0 !important;
background: transparent !important;
}
.line-numbers-wrapper {
position: absolute;
top: 0;
left: 0;
width: 3rem;
padding-top: 1rem;
text-align: right;
color: var(--line-number-color);
user-select: none;
}
.line-highlight {
position: absolute;
left: 0;
right: 0;
background: hsl(var(--primary) / 0.1);
border-left: 2px solid hsl(var(--primary));
pointer-events: none;
}
.code-block-body pre[data-line-numbers="true"] .line-highlight {
padding-left: 3.5rem;
}
.code-block-body::-webkit-scrollbar {
height: 8px;
}
.code-block-body::-webkit-scrollbar-track {
background: transparent;
}
.code-block-body::-webkit-scrollbar-thumb {
background: hsl(var(--border));
border-radius: 4px;
}
.code-block-body::-webkit-scrollbar-thumb:hover {
background: hsl(var(--muted));
}