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
193 changes: 118 additions & 75 deletions packages/docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import react from "@astrojs/react";
import starlight from "@astrojs/starlight";
import { defineConfig } from "astro/config";
import starlightSidebarTopics from "starlight-sidebar-topics";
import { Application, PageEvent } from "typedoc";
import {} from "typedoc-plugin-markdown";

/** @type {import('typedoc').TypeDocOptions & import('typedoc-plugin-markdown').PluginOptions} */
const typeDocConfigBaseOptions = {
Expand Down Expand Up @@ -113,13 +113,96 @@ async function generateDoc() {
}

// https://astro.build/config
const docsSidebar = [
{
label: "核心组件",
items: [{ slug: "guides/core/introduction" }],
},
{
label: "React 绑定",
items: [
{ slug: "guides/react/introduction" },
{ slug: "guides/react/quick-start" },
{ slug: "guides/react/lyric-player" },
{ slug: "guides/react/bg-render" },
],
},
{
label: "AMLL TTML Tools",
items: [
{ slug: "guides/ttml-tools/introduction" },
{ slug: "guides/ttml-tools/tips" },
],
},
];

const referenceSidebar = [
{
label: "Core 核心",
collapsed: true,
autogenerate: {
directory: "reference/core",
collapsed: true,
},
},
{
label: "React 绑定",
collapsed: true,
autogenerate: {
directory: "reference/react",
collapsed: true,
},
},
{
label: "React Full 组件库",
collapsed: true,
autogenerate: {
directory: "reference/react-full",
collapsed: true,
},
},
{
label: "Vue 绑定",
collapsed: true,
autogenerate: {
directory: "reference/vue",
collapsed: true,
},
},
{
label: "Lyric 歌词处理",
collapsed: true,
autogenerate: {
directory: "reference/lyric",
collapsed: true,
},
},
];

const contributeSidebar = [
{
label: "开发指南",
items: [
{ slug: "contribute/development/environments" },
{ slug: "contribute/development/structure" },
],
},
{
label: "仓库规范",
items: [
{ slug: "contribute/guidelines/pr" },
{ slug: "contribute/guidelines/publishing" },
],
},
];

export default defineConfig({
base: "/",
site: "https://amll.dev",
integrations: [
react(),
starlight({
favicon: "favicon.ico",
title: "Apple Music-like Lyrics",
title: "AppleMusic-like Lyrics",
customCss: ["./src/styles/custom.css"],
locales: {
root: {
Expand All @@ -139,6 +222,38 @@ export default defineConfig({
},
],
plugins: [
starlightSidebarTopics([
{
id: "docs",
label: {
"zh-CN": "使用文档",
en: "Guides",
},
link: "/guides/",
icon: "open-book",
items: docsSidebar,
},
{
id: "reference",
label: {
"zh-CN": "API 参考",
en: "API Reference",
},
link: "/reference/",
icon: "information",
items: referenceSidebar,
},
{
id: "contribute",
label: {
"zh-CN": "贡献指南",
en: "Contributing",
},
link: "/contribute/",
icon: "rocket",
items: contributeSidebar,
},
]),
{
name: "typedoc",
hooks: {
Expand All @@ -150,78 +265,6 @@ export default defineConfig({
},
},
],
sidebar: [
{
label: "核心组件",
items: [{ slug: "guides/core/introduction" }],
},
{
label: "React 绑定",
items: [
{ slug: "guides/react/introduction" },
{ slug: "guides/react/quick-start" },
{ slug: "guides/react/lyric-player" },
{ slug: "guides/react/bg-render" },
],
},
{
label: "AMLL TTML Tools",
items: [
{ slug: "guides/ttml-tools/introduction" },
{ slug: "guides/ttml-tools/tips" },
],
},
{
label: "接口参考",
items: [
{
label: "Core 核心模块",
collapsed: true,
autogenerate: {
directory: "reference/core",
collapsed: true,
},
},
{
label: "React 绑定模块",
collapsed: true,
autogenerate: {
directory: "reference/react",
collapsed: true,
},
},
{
label: "React Full 组件库模块",
collapsed: true,
autogenerate: {
directory: "reference/react-full",
collapsed: true,
},
},
{
label: "Vue 绑定模块",
collapsed: true,
autogenerate: {
directory: "reference/vue",
collapsed: true,
},
},
{
label: "Lyric 歌词模块",
collapsed: true,
autogenerate: {
directory: "reference/lyric",
collapsed: true,
},
},
// coreTypeDocSidebarGroup,
// reactTypeDocSidebarGroup,
// vueTypeDocSidebarGroup,
// reactFullTypeDocSidebarGroup,
// lyricTypeDocSidebarGroup,
],
},
],
}),
],
});
9 changes: 5 additions & 4 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"@applemusic-like-lyrics/core": "workspace:^",
"@applemusic-like-lyrics/react": "workspace:^",
"@applemusic-like-lyrics/react-full": "workspace:^",
"@astrojs/react": "^5.0.1",
"@astrojs/starlight": "^0.38.1",
"@astrojs/react": "^5.0.2",
"@astrojs/starlight": "^0.38.2",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"astro": "^6.0.6",
"astro": "^6.1.3",
"react": "catalog:",
"react-dom": "catalog:",
"sharp": "catalog:"
"sharp": "catalog:",
"starlight-sidebar-topics": "^0.7.1"
},
"devDependencies": {
"typedoc": "catalog:",
Expand Down
33 changes: 14 additions & 19 deletions packages/docs/src/components/AMLLPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import { useLayoutEffect, useRef, useState } from "react";

const buildLyricLines = (
lyric: string,
startTime = 1000,
startTime: number,
otherParams: Partial<LyricLine> = {},
): LyricLine => {
let curTime = startTime;
const words = [];
for (const word of lyric.split("|")) {
const [text, duration] = word.split(",");
const endTime = curTime + Number.parseInt(duration);
const endTime = curTime + Number(duration);
words.push({
word: text,
romanWord: "",
startTime: curTime,
endTime,
obscene: false,
Expand All @@ -24,7 +23,7 @@ const buildLyricLines = (
}
return {
startTime,
endTime: curTime + 3000,
endTime: curTime + 500,
translatedLyric: "",
romanLyric: "",
isBG: false,
Expand All @@ -37,31 +36,27 @@ const buildLyricLines = (
const DEMO_LYRICS: LyricLine[][] = [
[
buildLyricLines(
"Apple ,750|Music ,500|Like ,500|Ly,400|ri,500|cs ,250",
1000,
{
translatedLyric: "类苹果歌词",
},
"Apple ,350|Music ,300|Like ,300|Ly,500|ri,900|cs ,250",
2000,
{ translatedLyric: "类苹果歌词" },
),
// A lyric component library for the web
buildLyricLines(
"A ,400|ly,500|ric ,250|com,500|po,500|nent ,500|li,500|bra,500|ry ,500|for ,500|the ,500|web ,500",
7000,
{
translatedLyric: "为 Web 而生的歌词组件库",
},
"A ,200|ly,100|ric ,250|com,200|po,200|nent ,200|li,100|bra,200|ry ,100|for ,100|the ,200|web ,600",
5000,
{ translatedLyric: "为 Web 而生的歌词组件库" },
),
// Brought to you with
buildLyricLines("Brought ,500|to ,250|you ,800|with ,600", 16000, {
buildLyricLines("Brought ,300|to ,250|you ,800|with ,600", 8000, {
translatedLyric: "为你带来",
}),
// Background Lyric Line
buildLyricLines("Background ,750|Lyric ,300|Line ,500", 16500, {
buildLyricLines("Background ,750|lyric ,300|line ,500", 8500, {
translatedLyric: "背景歌词行",
isBG: true,
}),
// And Duet Lyric Line
buildLyricLines("And ,300|Duet ,500|Lyric ,500|Line ,750", 21150, {
buildLyricLines("And ,300|Duet ,300|lyric ,500|line ,650", 10500, {
translatedLyric: "还有对唱歌词行",
isDuet: true,
}),
Expand Down Expand Up @@ -118,15 +113,15 @@ export const AMLLPreview = () => {
filter: "blur(0px)",
},
{
duration: 500,
duration: 300,
easing: "ease-in-out",
fill: "forwards",
},
).onfinish = () => {
if (canceled) return;
requestAnimationFrame(onFrame);
};
}, 1000);
}, 600);
};
} else {
setCurrentTime((time - startTime) | 0);
Expand Down
Loading
Loading