@@ -5,43 +5,7 @@ module.exports = {
55 layout : "pattern" ,
66 tags : "pattern" ,
77 eleventyComputed : {
8- published : ( data ) => {
9- // Use git last modified date for the pattern source file in the library submodule
10- const { execSync } = require ( "child_process" ) ;
11- const path = require ( "path" ) ;
12-
13- try {
14- // Get the pattern name from the input path
15- let filePath = data . page . inputPath ;
16-
17- // Extract pattern name from path like site/library/visual-hash/index.md
18- const pathParts = filePath . split ( "/" ) ;
19- const patternName = pathParts [ pathParts . length - 2 ] ; // Get the directory name before index.md
20-
21- // Check git history in the library submodule for the original pattern file
22- const libraryPatternPath = `patterns/${ patternName } /index.md` ;
23- const workingDir = path . join ( process . cwd ( ) , "library" ) ;
24- const gitCommand = `git log -1 --format="%ci" -- "${ libraryPatternPath } "` ;
25-
26- const result = execSync ( gitCommand , {
27- cwd : workingDir ,
28- encoding : "utf-8" ,
29- } ) . trim ( ) ;
30-
31- if ( result ) {
32- const date = new Date ( result ) ;
33- return date . toLocaleDateString ( "en-us" ) ;
34- }
35- } catch ( error ) {
36- console . warn (
37- `Could not get git date for pattern ${ data . page . inputPath } :` ,
38- error . message
39- ) ;
40- }
41-
42- // Fallback to file date
43- return data . page . date . toLocaleDateString ( "en-us" ) ;
44- } ,
8+ published : ( data ) => data . helpers . publishedDate ( data ) ,
459 relatedPatterns : ( data ) => data . helpers . relatedPatterns ( data ) ,
4610 categoryName : ( data ) => data . helpers . categoryName ( data ) ,
4711 } ,
0 commit comments