@@ -85,19 +85,36 @@ const globalUnlockKey = `javaguide_site_unlocked_${config.unlockVersion ?? "v1"}
8585const normalizePath = (path : string ) =>
8686 path .replace (/ \/ $ / , " " ).replace (" .html" , " " ).toLowerCase ();
8787
88+ const isPathInPrefix = (currentPath : string , prefix : string ) => {
89+ return currentPath === prefix || currentPath .startsWith (` ${prefix }/ ` );
90+ };
91+
8892const isLockedPage = computed (() => {
8993 const currentPath = normalizePath (pageData .value .path );
90- return Object .keys (config .protectedPaths )
94+ const byExactPath = Object .keys (config .protectedPaths )
9195 .map ((p ) => normalizePath (p ))
9296 .includes (currentPath );
97+ if (byExactPath ) return true ;
98+
99+ const prefixes = Object .keys (config .protectedPrefixes ?? {}).map ((p ) =>
100+ normalizePath (p ),
101+ );
102+ return prefixes .some ((prefix ) => isPathInPrefix (currentPath , prefix ));
93103});
94104
95105const visibleHeight = computed (() => {
96106 const currentPath = normalizePath (pageData .value .path );
97- const matched = Object .keys (config .protectedPaths ).find (
107+ const matchedPath = Object .keys (config .protectedPaths ).find (
98108 (p ) => normalizePath (p ) === currentPath ,
99109 );
100- return matched ? config .protectedPaths [matched ] : PREVIEW_HEIGHT .LONG ;
110+ if (matchedPath ) return config .protectedPaths [matchedPath ];
111+
112+ const matchedPrefix = Object .keys (config .protectedPrefixes ?? {}).find (
113+ (prefix ) => isPathInPrefix (currentPath , normalizePath (prefix )),
114+ );
115+ if (matchedPrefix ) return config .protectedPrefixes [matchedPrefix ];
116+
117+ return PREVIEW_HEIGHT .LONG ;
101118});
102119
103120const toPx = (value : string ) => {
0 commit comments