@@ -17,6 +17,9 @@ const includes = (output, values) => {
1717const borderedPageTitle =
1818 '<h1 class="text-4xl mt-4 mb-8 font-medium font-display tracking-tight border-b border-rd-gray-alpha-400 pb-2">' ;
1919
20+ const getArticleToc = ( output ) =>
21+ output . match ( / < a s i d e i d = " a r t i c l e - t o c " [ \s \S ] * ?< \/ a s i d e > / ) ?. [ 0 ] || "" ;
22+
2023const readTemplates = ( directory ) => fs . readdirSync ( directory , { withFileTypes : true } )
2124 . flatMap ( ( entry ) => {
2225 const entryPath = path . join ( directory , entry . name ) ;
@@ -88,6 +91,15 @@ test("theme build and generation configurations", async (t) => {
8891 assert . ok ( outputExists ( "css/build/theme.css" ) ) ;
8992 } ) ;
9093
94+ await t . test ( "article TOC omits titles above the configured length" , ( ) => {
95+ const shortTitleToc = getArticleToc ( readOutput ( "2022/10/02/theme-demo/index.html" ) ) ;
96+ const longTitleToc = getArticleToc ( readOutput ( "2024/01/17/super-long-title-test/index.html" ) ) ;
97+
98+ assert . ok ( shortTitleToc . includes ( "主题样式 Demo" ) ) ;
99+ assert . ok ( ! longTitleToc . includes ( "This is an extremely long title" ) ) ;
100+ assert . ok ( longTitleToc . includes ( "Super Long Title Test" ) ) ;
101+ } ) ;
102+
91103 await t . test ( "archive renders an unframed semantic timeline" , ( ) => {
92104 const archive = readOutput ( "archives/index.html" ) ;
93105 includes ( archive , [
@@ -199,6 +211,7 @@ test("theme build and generation configurations", async (t) => {
199211 const nested = readOutput ( "2026/08/06/tab-folding-nesting-test/index.html" ) ;
200212 includes ( home , [ 'id="local-search"' , 'id="reading-progress"' , 'id="preloader"' , 'id="aplayer"' ] ) ;
201213 includes ( writing , [ "data-writing-button" , 'data-lazy-state="pending"' ] ) ;
214+ assert . ok ( ! getArticleToc ( writing ) . includes ( "主题样式 Demo" ) ) ;
202215 includes ( nested , [ "data-tabs" , 'role="tabpanel"' , 'class="folding' ] ) ;
203216 } ) ;
204217
0 commit comments