diff --git a/docgenerator/SDKDocGeneratorLib/Writers/BaseWriter.cs b/docgenerator/SDKDocGeneratorLib/Writers/BaseWriter.cs index 78871cfdd605..047886223cb3 100644 --- a/docgenerator/SDKDocGeneratorLib/Writers/BaseWriter.cs +++ b/docgenerator/SDKDocGeneratorLib/Writers/BaseWriter.cs @@ -132,9 +132,10 @@ public void Write() writer.WriteLine("", GetTitle()); writer.WriteLine("{0} | AWS SDK for .NET Version 4", GetTitle()); writer.WriteLine(""); - writer.WriteLine("", - FilenameGenerator.Escape(this.GenerateFilename()), - FilenameGenerator.Escape(this.GetTOCID())); + writer.WriteLine("", FilenameGenerator.Escape(this.GetTOCID())); + writer.WriteLine("", + FilenameGenerator.Escape(this.GenerateFilepath()), + FilenameGenerator.Escape(this.GenerateFilename())); writer.WriteLine(""); diff --git a/docgenerator/SDKDocGeneratorLib/output-files/resources/parentloader.js b/docgenerator/SDKDocGeneratorLib/output-files/resources/parentloader.js index bba04b241980..1a469b1926a2 100644 --- a/docgenerator/SDKDocGeneratorLib/output-files/resources/parentloader.js +++ b/docgenerator/SDKDocGeneratorLib/output-files/resources/parentloader.js @@ -31,31 +31,48 @@ } } else { - //This content page is not in the expected frameset which contains the TOC so - //reload the parent frame and cause it to reload this page in the frame. The - //canonical link element contains the link to reload the entire parent frameset - //and load this current content page. - var pageLink = jQuery("link[rel='canonical']").attr('href'); - if (pageLink !== '') { - //Canonical links look like this: http://docs.aws.amazon.com/sdkfornet/v4/apidocs/index.html?page=PAGE.html&tocid=TOCID - //Attempt to find where the relative path starts after the hostname. - var seekFrom = 0; - var protocolEndIndex = pageLink.indexOf('://'); - if (protocolEndIndex != -1) { - seekFrom = protocolEndIndex + 3; - } + //This content page is not in the expected frameset which contains the TOC so + //reload the parent frame and cause it to reload this page in the frame. - //Look for the start of the relative path. - var relPathIndex = pageLink.indexOf('/', seekFrom); - if (relPathIndex != -1) { - //Reload the parent frameset and this content page. Note the address bar URL will - //look like the canonical link in the address bar. The inFrame part of this script - //will run on release to replace the address bar URL with the actual friendly content - //frame page URL. - window.location.href = pageLink.substring(relPathIndex); + //First, try the new approach: read tocid from meta tag and build frameset URL + var tocid = jQuery("meta[name='aws-tocid']").attr('content'); + var pathname = window.location.pathname; + var itemsIndex = pathname.indexOf('/items/'); + + if (tocid && itemsIndex !== -1) { + //Build the frameset URL from the current path + var basePath = pathname.substring(0, itemsIndex); + var filename = pathname.substring(pathname.lastIndexOf('/') + 1); + //Reload the parent frameset and this content page. The inFrame part of this script + //will run on reload to replace the address bar URL with the actual friendly content + //frame page URL. + window.location.href = basePath + '/index.html?page=' + filename + '&tocid=' + tocid; + } + else { + //Fallback: try the old approach using the canonical link for backward compatibility. + //This handles pages that may have been generated with older code or cached versions. + var pageLink = jQuery("link[rel='canonical']").attr('href'); + if (pageLink && pageLink !== '') { + //Canonical links may look like: + // http://docs.aws.amazon.com/sdkfornet/v4/apidocs/index.html?page=PAGE.html&tocid=TOCID (old format) + // http://docs.aws.amazon.com/sdkfornet/v4/apidocs/items/S3/PAGE.html (new format) + //Attempt to find where the relative path starts after the hostname. + var seekFrom = 0; + var protocolEndIndex = pageLink.indexOf('://'); + if (protocolEndIndex != -1) { + seekFrom = protocolEndIndex + 3; + } + + //Look for the start of the relative path. + var relPathIndex = pageLink.indexOf('/', seekFrom); + if (relPathIndex != -1) { + //Check if this is the old format (contains index.html?page=) + if (pageLink.indexOf('index.html?page=') !== -1) { + //Old format: redirect to the canonical URL directly + window.location.href = pageLink.substring(relPathIndex); + } + } } - //Else do nothing because the link doesn't appear to be in a normal URL format where the - //hostname ends with a / starting the relative URL path. } } })(); \ No newline at end of file