Fix highlighting and get tag pages
This commit is contained in:
@@ -19,7 +19,7 @@ exports.createPages = async ({ graphql, actions }) => {
|
||||
|
||||
const result = await graphql(`
|
||||
query {
|
||||
allMarkdownRemark {
|
||||
postsRemark: allMarkdownRemark {
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
@@ -28,10 +28,15 @@ exports.createPages = async ({ graphql, actions }) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
tagsGroup: allMarkdownRemark {
|
||||
group(field: frontmatter___tags) {
|
||||
fieldValue
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
|
||||
result.data.postsRemark.edges.forEach(({ node }) => {
|
||||
createPage({
|
||||
path: node.fields.slug,
|
||||
component: path.resolve(`./src/templates/post.js`),
|
||||
@@ -40,4 +45,14 @@ exports.createPages = async ({ graphql, actions }) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
result.data.tagsGroup.group.forEach((tag) => {
|
||||
createPage({
|
||||
path: `/tags/${tag.fieldValue}/`,
|
||||
component: path.resolve(`./src/templates/tag.js`),
|
||||
context: {
|
||||
tag: tag.fieldValue
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -10,7 +10,7 @@ We wanted an easy solution to open every document in a SharePoint from a documen
|
||||
|
||||
I don’t know of any way to do this via a setting in SharePoint, but a little JavaScript employing jQuery does the job just perfectly.
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
$(document).ready(
|
||||
function () {
|
||||
// has to be on an interval for grouped doc libraries
|
||||
|
||||
@@ -9,7 +9,7 @@ tags: [sitecore]
|
||||
## Problem
|
||||
I got the error message (in my Firebug console) in the Sitecore Page Editor on a page where I had a nested sublayout. I had a basic two-column layout for the main sublayout of the page. Then, in the right column, I had another sublayout that further divided up the right column as I needed. Here is what the nested sublayout looked like:
|
||||
|
||||
```html %}
|
||||
```html
|
||||
<sc:Placeholder runat="server" Key="blogRightColumnTop"/>
|
||||
|
||||
<div class="sidebar-blog">
|
||||
@@ -26,7 +26,7 @@ This was a Javascript error that was preventing the Page Editor from fully loadi
|
||||
## Solution
|
||||
The error message (surprise, surprise) was a little mystifying, but it gave me enough of a clue to think that there was some type of nesting issue. I noticed that I had a sc:Placeholder element at the top of my nested sub-layout with nothing wrapping it. Perhaps this was the issue? I tried this edit to my nested sub-layout:
|
||||
|
||||
```html %}
|
||||
```html
|
||||
<div>
|
||||
<sc:Placeholder runat="server" Key="blogRightColumnTop"/>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ I am using a WidgetDesigner in which I have the PagesSelector control. My goal i
|
||||
Everything works fine. Except, once I save a selection in the PagesSelector, on subsequent edits, the currently selected items would not show up, as described above.
|
||||
|
||||
Here is the bug I found in the Sitefinity code. The set_selectedItemIds function is really simple. It looks like this:
|
||||
```javascript %}
|
||||
```javascript
|
||||
set_selectedItemIds: function(ids) {
|
||||
this._selectedItemIds = ids;
|
||||
this._updateGridSelection();
|
||||
@@ -29,7 +29,7 @@ set_selectedItemIds: function(ids) {
|
||||
|
||||
It updates a property (_selectedItemIds) and then updates the grid (not sure what that is) and then the tree (of page nodes). The _updateTreeSelection method is what we’re looking for–this is where the bug is. The method looks like this:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
_updateTreeSelection: function () {
|
||||
if (this._treeIsBound == false) {
|
||||
this._treeMustBeUpdated = true;
|
||||
@@ -59,7 +59,7 @@ The problem is on line 13. tree.get_selectedItems() returns an empty array when
|
||||
|
||||
The beauty (and danger!) of javascript is that you can easily fix something like this in your own code by simply redefining their method. Here is my code that fixes this bug:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
var wrapper = this.get_pagesSelector();
|
||||
var selector = this.get_pagesSelector().get_pageSelector();
|
||||
var selecting = false;
|
||||
|
||||
@@ -8,7 +8,7 @@ tags: [sharepoint]
|
||||
---
|
||||
I ran across an issue today in SharePoint 2010 where the Page Layout button would not open. It would throw the following error in Internet Explorer:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
SCRIPT5007: Unable to get property ‘nodeName’ of undefined or null reference
|
||||
cui.js, line 2 character 6422
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ tags: [sitefinity]
|
||||
|
||||
When you use Sitefinity Thunder (a great help, by the way) to generate a Widget Designer for an existing widget that has a boolean property, you get this javascript in the auto-generated javascript file (let’s say my boolean field is named HasSubMenu):
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
/* RefreshUI HasSubMenu */
|
||||
jQuery(this.get_hasSubMenu()).attr("checked", controlData.HasSubMenu);
|
||||
```
|
||||
@@ -24,7 +24,7 @@ This means, no matter what you do with the checkbox, the next time you click “
|
||||
|
||||
The solution is pretty simple. Instead of using controlData.HasSubMenu for the expression by itself, update your Javascript so that you check if the string is “true” or not: controlData.HasSubMenu === "true". The line in the refreshUI method should now look like this:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
/* RefreshUI HasSubMenu */
|
||||
jQuery(this.get_hasSubMenu()).attr("checked", controlData.HasSubMenu === "true");
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ I noticed a goofy issue today while working with a jQuery countdown plugin. Thi
|
||||
|
||||
I was setting the date like this:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
element.countdown({
|
||||
until: new Date(’10/13/14 00:00:00′)
|
||||
});
|
||||
@@ -21,7 +21,7 @@ In Chrome, this worked just fine. The string “10/13/14 00:00:00″ parsed to
|
||||
|
||||
In IE, however (versions10, 9 and 8 at least) it parsed as October 13th, 1914. Why? Who knows. Updating my string to “10/13/2014 00:00:00″ fixed it. My final javascript looked like this:
|
||||
|
||||
```javascript %}
|
||||
```javascript
|
||||
element.countdown({
|
||||
until: new Date(’10/13/2014 00:00:00′)
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ Eventually, I found a solution online that worked. Instead of setting up a custo
|
||||
|
||||
Here is my custom AuthorizeAttribute:
|
||||
|
||||
```csharp %}
|
||||
```csharp
|
||||
public class AuthorizeADAttribute : AuthorizeAttribute
|
||||
{
|
||||
private bool _authenticated;
|
||||
@@ -111,7 +111,7 @@ Notice that I also included a little code to distinguish between the user not be
|
||||
|
||||
The this.Log() code uses a Nuget package called this.Log. The LDAPHelper class is something I wrote. The code is below:
|
||||
|
||||
```csharp %}
|
||||
```csharp
|
||||
public static class LDAPHelper
|
||||
{
|
||||
public static string GetLDAPContainer()
|
||||
@@ -177,7 +177,7 @@ My code is mostly based on example code I found on a very helpful [StackOverflow
|
||||
|
||||
To use this code, all you have to do is use your custom AuthorizeAttribute instead of the built-in one. Something like this:
|
||||
|
||||
```csharp %}
|
||||
```csharp
|
||||
[AuthorizeAD(Groups="Some AD group name")]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import { graphql } from "gatsby";
|
||||
import Layout from "../components/layout"
|
||||
|
||||
export default function Page({ headerInfo, pageTitle, children }) {
|
||||
|
||||
50
src/templates/tag.js
Normal file
50
src/templates/tag.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import React from "react";
|
||||
import { graphql } from "gatsby";
|
||||
import Page from "./page";
|
||||
|
||||
export default function Tag({ data, pageContext }) {
|
||||
var { tag } = pageContext;
|
||||
var siteMetadata = data.site.siteMetadata;
|
||||
var totalCount = data.allMarkdownRemark.totalCount;
|
||||
var postListItems = data.allMarkdownRemark.edges.map(function(edge) {
|
||||
return (
|
||||
<li><a href={edge.node.fields.slug}>{edge.node.frontmatter.title}</a></li>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<Page headerInfo={siteMetadata} pageTitle={'Tag: ' + tag + ' (' + totalCount + ')'}>
|
||||
<p>
|
||||
All posts tagged with "{tag}";
|
||||
</p>
|
||||
<ul>
|
||||
{postListItems}
|
||||
</ul>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
export const query = graphql`
|
||||
query($tag: String!) {
|
||||
allMarkdownRemark(
|
||||
sort: { fields: [frontmatter___date], order: DESC }
|
||||
filter: { frontmatter: { tags: { in: [$tag] } } }
|
||||
)
|
||||
{
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
slug
|
||||
}
|
||||
frontmatter {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
site {
|
||||
...HeaderInfo
|
||||
}
|
||||
}
|
||||
`
|
||||
Reference in New Issue
Block a user