我正在使用 mvn site 来生成我网站的文档。在大多数情况下,我对默认站点感到满意,但我想从左侧菜单栏中删除“关于”链接,并将默认页面设置为“项目信息”页面。是否有捷径可寻?
4 回答
此处仅包含“关于”报告。所有其他标准报告都将被删除。
<reporting>
<plugins>
<!-- Add the Maven project information reports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<!--
<report>dependencies</report>
<report>project-team</report>
<report>mailing-list</report>
<report>cim</report>
<report>issue-tracking</report>
<report>license</report>
<report>scm</report>
-->
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
您可以修改源代码并将其注释掉或为其添加一个 css 选择器,或者您可以包含一个 JS 库(如 jQuery)并在页面加载时通过以下方式将其删除:
$(function () {
// untested
$('#navcolumn h5:contains("Maven")').hide(); // hide the header
$('#navcolumn h5:contains("Maven") + ul ').hide(); // hide the ul
})();
我最终根本没有使用那个插件,只使用了 maven-site-plugin。Maven 3 有一个 maven pom 的 reportPlugins 配置部分,可让您指定要显示的报告http://maven.apache.org/plugins/maven-site-plugin/maven-3.html
org.apache.maven.plugins maven-site-plugin 3.0 org.codehaus.mojo cobertura-maven-plugin
我还提供了自己的 index.apt(在 src/site/apt 中)文件来自定义索引页面文本。
我知道这是一个老问题,但我一直觉得它很烦人。“关于”部分是多余的,更重要的是,当您访问该站点时,默认情况下会展开“项目信息”菜单。由于我在网上没有找到任何解决方案,我不得不自己弄清楚。
使用以下解决方法,“项目信息”菜单下的“关于”项将从站点中完全消失。只需将其添加到site.xml
文件中:
...
<body>
<head>
<![CDATA[
<script type="text/javascript">
$(document).ready(function () {
var linkAbout = $('a').filter(function(index) { return $(this).text() === "About"; });
var projectInformationMenu = $('a').filter(function(index) { return $(this).text() === "Project Information"; });
linkAbout.hide();
if (!projectInformationMenu.parent().hasClass('active')) {
projectInformationMenu.parent().children('ul').hide();
projectInformationMenu.children('span').removeClass('icon-chevron-down').addClass('icon-chevron-right');
}
});
</script>
]]>
</head>
...
</body>